Bug 15523

Summary: wic cp corrupts ext4 journal
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Thomas Roos <thomas>
Component: devtools / tool chainAssignee: Thomas Roos <thomas>
Status: RESOLVED NOTABUG QA Contact:
Severity: normal    
Priority: Medium CC: meta.mr.watcher, meta.watcher, ross.burton
Version: 4.0.20   
Target Milestone: 5.1   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know

Description Thomas Roos 2024-06-19 19:49:26 UTC
When copying files into a ext4 partition in an image it seems that the journal is getting corrupt.

When booting I see errors like this, and sometimes the files are just not there despite "wic ls" did show them.
ext4_lookup:1857: inode #2: comm ls: deleted inode referenced:

Workaround (to fix the journal is to do this after copying)
sync
e2fsck -y tmp/deploy/images/qemuarm64/image-qemuarm64.ext4
Comment 1 Ross Burton 2024-06-20 14:51:42 UTC
That workaround feels reasonable enough, can you send a patch?
Comment 2 Thomas Roos 2024-06-21 08:25:17 UTC
Sorry for the noise - could not reproduce it.
Here is a snipplet of my idea to disable journal - but hence it disappeared I close the bug.

diff --git a/scripts/lib/wic/engine.py b/scripts/lib/wic/engine.py
index 674ccfc244..03cd508386 100644
--- a/scripts/lib/wic/engine.py
+++ b/scripts/lib/wic/engine.py
@@ -280,7 +280,7 @@ class Disk:
     def __getattr__(self, name):
         """Get path to the executable in a lazy way."""
         if name in ("mdir", "mcopy", "mdel", "mdeltree", "sfdisk", "e2fsck",
-                    "resize2fs", "mkswap", "mkdosfs", "debugfs","blkid"):
+                    "resize2fs", "tune2fs", "mkswap", "mkdosfs", "debugfs","blkid"):
             aname = "_%s" % name
             if aname not in self.__dict__:
                 setattr(self, aname, shutil.which(name, path=self.paths))
@@ -332,9 +332,12 @@ class Disk:
 
         if self.partitions[pnum].fstype.startswith('ext'):
             if isinstance(src, str):
+                # disable journal, since this is not proper updated
+                exec_cmd("{} -fO ^has_journal  {}".format(self.tune2fs, self._get_part_image(pnum)))
+                # creating copy cmd