e2fsck: check xattr 'system.data' before setting inline_data feature
PATCH v2 1/1 e2fsck: check xattr 'system.data' before setting inline_data feature
ext2fs_inline_data_size will happy return 0 and set size to EXT4_MIN_INLINE_DATA_SIZE even when inode doesn't have xattr 'system.data', a corrupted i_flags could make e2fsck enable the inline_data on the superblock.
We should only offer to enable inline_data when i_flags is set and xattr 'system.data' can be found.
Also use correct prompt for PR_1_INLINE_DATA_FEATURE.
--- e2fsck/pass1.c | 4 ++-- e2fsck/problem.c | 2 +- tests/f_inlinedata_flags/expect.1 | 26 ++++++++++++++++++++++++++ tests/f_inlinedata_flags/expect.2 | 7 +++++++ tests/f_inlinedata_flags/image.gz | Bin 0 -> 11226 bytes tests/f_inlinedata_flags/name | 1 + 6 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 tests/f_inlinedata_flags/expect.1 create mode 100644 tests/f_inlinedata_flags/expect.2 create mode 100644 tests/f_inlinedata_flags/image.gz create mode 100644 tests/f_inlinedata_flags/name
v2:
- Add tests/f_inlinedata_flags
e2fsck/pass1.c +2 -2
@@ -1496,8 +1496,8 @@ void e2fsck_pass1(e2fsck_t ctx) (ino >= EXT2_FIRST_INODE(fs->super))) {size_t size =0 ; - pctx.errcode =ext2fs_inline_data_size (fs, ino, &size); -if (!pctx.errcode && size && + pctx.errcode =get_inline_data_ea_size (fs, ino, &size); +if (!pctx.errcode &&fix_problem (ctx,PR_1_INLINE_DATA_FEATURE , &pctx)) {ext2fs_set_feature_inline_data (sb);ext2fs_mark_super_dirty (fs);
e2fsck/problem.c +1 -1
@@ -1063,7 +1063,7 @@ static struct e2fsck_problem problem_table[] = {/* Inode has inline data, but superblock is missing INLINE_DATA feature */ {PR_1_INLINE_DATA_FEATURE ,N_ ("@i %i has inline data, but @S is missing INLINE_DATA feature\n" ), - PROMPT_CLEAR, PR_PREEN_OK, 0, 0, 0 }, + PROMPT_FIX, PR_PREEN_OK, 0, 0, 0 },/* inode has INLINE_DATA_FL flag on filesystem without inline data */ { PR_1_INLINE_DATA_SET,
tests/f_inlinedata_flags/expect.1 new file +26 -0
@@ -0,0 +1,26 @@ +Pass 1: Checking inodes, blocks, and sizes +Inode 12 has INLINE_DATA_FL flag on filesystem without inline data support. +Clear? yes + +Inode 13 has inline data, but superblock is missing INLINE_DATA feature +Fix? yes + +Pass 2: Checking directory structure +Entry '1' in / (2) has deleted/unused inode 12. Clear? yes + +Pass 3: Checking directory connectivity +Pass 4: Checking reference counts +Pass 5: Checking group summary information +Inode bitmap differences: -12 +Fix? yes + +Free inodes count wrong for group #0 (243, counted=244). +Fix? yes + +Free inodes count wrong (243, counted=244). +Fix? yes + + +test_filesys: ***** FILE SYSTEM WAS MODIFIED ***** +test_filesys: 12/256 files (0.0% non-contiguous), 1143/8192 blocks +Exit status is 1
tests/f_inlinedata_flags/expect.2 new file +7 -0
@@ -0,0 +1,7 @@ +Pass 1: Checking inodes, blocks, and sizes +Pass 2: Checking directory structure +Pass 3: Checking directory connectivity +Pass 4: Checking reference counts +Pass 5: Checking group summary information +test_filesys: 12/256 files (0.0% non-contiguous), 1143/8192 blocks +Exit status is 0
tests/f_inlinedata_flags/image.gz new file binary +0 -0
tests/f_inlinedata_flags/name new file +1 -0
@@ -0,0 +1 @@ +check incorrect inline_data flags
Signature · 1 line
2.19.1
Theodore Y. Ts'o
AppliedQuoted 11 lines · Li Dongyang
ext2fs_inline_data_sizewill happy return 0 and set size toEXT4_MIN_INLINE_DATA_SIZEeven when inode doesn't have xattr 'system.data', a corruptedi_flagscould make e2fsck enable theinline_dataon the superblock.We should only offer to enable
inline_datawheni_flagsis set and xattr 'system.data' can be found.Also use correct prompt for
PR_1_INLINE_DATA_FEATURE.Signed-off-by Li Dongyang <[email protected]>
Thanks, applied.
- Ted