fs: ext4: do not write on filesystem with metadata_csum feature
PATCH 1/1 fs: ext4: do not write on filesystem with metadata_csum feature
U-Boot doesn't support metadata_csum feature. Writing to filesystem with metadata_csum feature makes the filesystem corrupted and unbootable by Linux:
[ 2.527495] EXT4-fs (mmcblk0p2): ext4_check_descriptors: Checksum for group 0 failed (52188!=0) [ 2.537421] EXT4-fs (mmcblk0p2): ext4_check_descriptors: Checksum for group 1 failed (5262!=0) ... [ 2.653308] EXT4-fs (mmcblk0p2): ext4_check_descriptors: Checksum for group 14 failed (42611!=0) [ 2.662179] EXT4-fs (mmcblk0p2): ext4_check_descriptors: Checksum for group 15 failed (21527!=0) [ 2.687920] JBD2: journal checksum error [ 2.691982] EXT4-fs (mmcblk0p2): error loading journal [ 2.698292] VFS: Cannot open root device "mmcblk0p2" or unknown-block(179,2): error -74
Don't write to filesystem with meatadata_csum feature to not corrupt the filesystem.
Signed-off-by Sébastien Szymanski <[email protected]>
--- fs/ext4/ext4_write.c | 6 ++++++ include/ext4fs.h | 1 + 2 files changed, 7 insertions(+)
fs/ext4/ext4_write.c +6 -0
@@ -864,6 +864,12 @@ int ext4fs_write(const char *fname, unsigned char *buffer,printf ("error in File System init\n" );return -1 ; } + +if (le32_to_cpu (fs->sb->feature_ro_compat) &EXT4_FEATURE_RO_COMPAT_METADATA_CSUM ) { +printf ("Unsupported feature metadata_csum found, not writing.\n" ); +return -1 ; + } + inodes_per_block = fs->blksz / fs->inodesz; parent_inodeno =ext4fs_get_parent_inode_num (fname, filename,F_FILE );if (parent_inodeno ==-1 )
include/ext4fs.h +1 -0
@@ -32,6 +32,7 @@#define EXT4_EXTENTS_FL 0x00080000/* Inode uses extents */ #define EXT4_EXT_MAGIC 0xf30a#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010 +#define EXT4_FEATURE_RO_COMPAT_METADATA_CSUM 0x0400#define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080#define EXT4_INDIRECT_BLOCKS 12
Signature · 1 line
2.19.2
PATCH 1/1 fs: ext4: do not write on filesystem with metadata_csum feature
Quoted 13 lines · Sébastien Szymanski
U-Boot doesn't support
metadata_csumfeature. Writing to filesystem withmetadata_csumfeature makes the filesystem corrupted and unbootable by Linux:[ 2.527495] EXT4-fs (mmcblk0p2): ext4_check_descriptors: Checksum for group 0 failed (52188!=0) [ 2.537421] EXT4-fs (mmcblk0p2): ext4_check_descriptors: Checksum for group 1 failed (5262!=0) ... [ 2.653308] EXT4-fs (mmcblk0p2): ext4_check_descriptors: Checksum for group 14 failed (42611!=0) [ 2.662179] EXT4-fs (mmcblk0p2): ext4_check_descriptors: Checksum for group 15 failed (21527!=0) [ 2.687920] JBD2: journal checksum error [ 2.691982] EXT4-fs (mmcblk0p2): error loading journal [ 2.698292] VFS: Cannot open root device "mmcblk0p2" or unknown-block(179,2): error -74
Quoted 4 lines
Don't write to filesystem with
meatadata_csumfeature to not corrupt the filesystem.Signed-off-by Sébastien Szymanski <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190322/ffc9dc9f/attachment.sig>