From: Li Dongyang Date: Tue, 13 Nov 2018 04:46:03 +0000 (+1100) Subject: e2fsck: check xattr 'system.data' before setting inline_data feature X-Git-Tag: v1.44.5~13 X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fe2fsprogs.git;a=commitdiff_plain;h=4a11f499573c71fde91623f45146fdc60a4bb89c 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. Signed-off-by: Li Dongyang --- diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index 8abf0c33a..45534388a 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -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); diff --git a/e2fsck/problem.c b/e2fsck/problem.c index 932cad3cd..4082e373e 100644 --- a/e2fsck/problem.c +++ b/e2fsck/problem.c @@ -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, diff --git a/tests/f_inlinedata_flags/expect.1 b/tests/f_inlinedata_flags/expect.1 new file mode 100644 index 000000000..86eba8833 --- /dev/null +++ b/tests/f_inlinedata_flags/expect.1 @@ -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 diff --git a/tests/f_inlinedata_flags/expect.2 b/tests/f_inlinedata_flags/expect.2 new file mode 100644 index 000000000..87b3f18b0 --- /dev/null +++ b/tests/f_inlinedata_flags/expect.2 @@ -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 diff --git a/tests/f_inlinedata_flags/image.gz b/tests/f_inlinedata_flags/image.gz new file mode 100644 index 000000000..4344a0a8c Binary files /dev/null and b/tests/f_inlinedata_flags/image.gz differ diff --git a/tests/f_inlinedata_flags/name b/tests/f_inlinedata_flags/name new file mode 100644 index 000000000..66b7676a8 --- /dev/null +++ b/tests/f_inlinedata_flags/name @@ -0,0 +1 @@ +check incorrect inline_data flags