e2fsck: Check for cases where EOFBLOCKS_FL is unnecessarily set
PATCH 1/1 e2fsck: Check for cases where EOFBLOCKS_FL is unnecessarily set
Some kernels will crash if EOFBLOCKS_FL is set when it is it not needed, and this if it is left set when it isn't needed, it is a sign of a kernel bug.
Addresses-Google-Bug: #2604224
--- e2fsck/pass1.c | 13 +++++++++++++ e2fsck/problem.c | 5 +++++ e2fsck/problem.h | 3 +++ tests/f_bad_disconnected_inode/expect.1 | 9 +++++++++ 4 files changed, 30 insertions(+), 0 deletions(-)
e2fsck/pass1.c +13 -0
@@ -2000,6 +2000,19 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx, ((1ULL << (32 + EXT2_BLOCK_SIZE_BITS(fs->super))) - 1))/* too big for an extent-based file - 32bit ee_block */ bad_size =6 ; + +/* +* Check to see if the EOFBLOCKS flag is set where it +* doesn't need to be. +*/ +if ((inode->i_flags &EXT4_EOFBLOCKS_FL ) && + (size <= (((__u64 )pb.last_block +1 ) * fs->blocksize))) { + pctx->blkcount = pb.last_block; +if (fix_problem (ctx,PR_1_EOFBLOCKS_FL_SET , pctx)) { + inode->i_flags &= ~EXT4_EOFBLOCKS_FL ; + dirty_inode++; + } + } }/* i_size for symlinks is checked elsewhere */ if (bad_size && !LINUX_S_ISLNK (inode->i_mode)) {
e2fsck/problem.c +5 -0
@@ -885,6 +885,11 @@ static struct e2fsck_problem problem_table[] = { N_("@i %i has an invalid extent node (blk %b, lblk %c)\n"), PROMPT_CLEAR, 0 }, + {PR_1_EOFBLOCKS_FL_SET , +N_ ("@i %i should not have EOFBLOCKS_FL set " +"(size %Is, lblk %r)\n" ), + PROMPT_CLEAR, PR_PREEN_OK }, +/* Pass 1b errors */ /* Pass 1B: Rescan for duplicate/bad blocks */
e2fsck/problem.h +3 -0
@@ -517,6 +517,9 @@ struct problem_context {/* Extent node header invalid */ #define PR_1_EXTENT_HEADER_INVALID 0x01005F +/* EOFBLOCKS flag set when not necessary */ +#define PR_1_EOFBLOCKS_FL_SET 0x010060 +/* * Pass 1b errors */
tests/f_bad_disconnected_inode/expect.1 +9 -0
@@ -2,12 +2,21 @@ Pass 1: Checking inodes, blocks, and sizes Inode 1 has EXTENTS_FL flag set on filesystem without extents support. Clear? yes +Inode 9 should not have EOFBLOCKS_FL set (size 0, lblk -1) +Clear? yes + +Inode 10 should not have EOFBLOCKS_FL set (size 0, lblk -1) +Clear? yes + Inode 15 has EXTENTS_FL flag set on filesystem without extents support. Clear? yes Inode 16 has EXTENTS_FL flag set on filesystem without extents support. Clear? yes +Inode 13 should not have EOFBLOCKS_FL set (size 0, lblk -1) +Clear? yes + Pass 2: Checking directory structure Pass 3: Checking directory connectivity /lost+found not found. Create? yes
Signature · 1 line
1.6.6.1.1.g974db.dirty
Quoted 1 line · Theodore Ts'o
Some kernels will crash if
EOFBLOCKS_FLis set when it is it not
Is there a kernel fix to go with this, then?
Thanks,
-Eric
Quoted 93 lines
needed, and this if it is left set when it isn't needed, it is a sign of a kernel bug.
Addresses-Google-Bug: #2604224
Signed-off-by "Theodore Ts'o" <[email protected]>--- e2fsck/pass1.c | 13 +++++++++++++ e2fsck/problem.c | 5 +++++ e2fsck/problem.h | 3 +++ tests/f_bad_disconnected_inode/expect.1 | 9 +++++++++ 4 files changed, 30 insertions(+), 0 deletions(-)e2fsck/pass1.c +13
-0@@ -2000,6 +2000,19 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx, ((1ULL << (32 + EXT2_BLOCK_SIZE_BITS(fs->super))) - 1))/* too big for an extent-based file - 32bit ee_block */ bad_size =6 ; + +/* +* Check to see if the EOFBLOCKS flag is set where it +* doesn't need to be. +*/ +if ((inode->i_flags &EXT4_EOFBLOCKS_FL ) && + (size <= (((__u64 )pb.last_block +1 ) * fs->blocksize))) { + pctx->blkcount = pb.last_block; +if (fix_problem (ctx,PR_1_EOFBLOCKS_FL_SET , pctx)) { + inode->i_flags &= ~EXT4_EOFBLOCKS_FL ; + dirty_inode++; + } + } }/* i_size for symlinks is checked elsewhere */ if (bad_size && !LINUX_S_ISLNK (inode->i_mode)) {e2fsck/problem.c +5
-0@@ -885,6 +885,11 @@ static struct e2fsck_problem problem_table[] = { N_("@i %i has an invalid extent node (blk %b, lblk %c)\n"), PROMPT_CLEAR, 0 }, + {PR_1_EOFBLOCKS_FL_SET , +N_ ("@i %i should not have EOFBLOCKS_FL set " +"(size %Is, lblk %r)\n" ), + PROMPT_CLEAR, PR_PREEN_OK }, +/* Pass 1b errors */ /* Pass 1B: Rescan for duplicate/bad blocks */ e2fsck/problem.h +3
-0@@ -517,6 +517,9 @@ struct problem_context {/* Extent node header invalid */ #define PR_1_EXTENT_HEADER_INVALID 0x01005F +/* EOFBLOCKS flag set when not necessary */ +#define PR_1_EOFBLOCKS_FL_SET 0x010060 +/* * Pass 1b errors */ tests/f_bad_disconnected_inode/expect.1 +9
-0@@ -2,12 +2,21 @@ Pass 1: Checking inodes, blocks, and sizes Inode 1 has EXTENTS_FL flag set on filesystem without extents support. Clear? yes +Inode 9 should not have EOFBLOCKS_FL set (size 0, lblk -1) +Clear? yes + +Inode 10 should not have EOFBLOCKS_FL set (size 0, lblk -1) +Clear? yes + Inode 15 has EXTENTS_FL flag set on filesystem without extents support. Clear? yes Inode 16 has EXTENTS_FL flag set on filesystem without extents support. Clear? yes +Inode 13 should not have EOFBLOCKS_FL set (size 0, lblk -1) +Clear? yes + Pass 2: Checking directory structure Pass 3: Checking directory connectivity /lost+found not found. Create? yes
Quoted 4 lines · Eric Sandeen
Quoted 1 line · Theodore Ts'o
Some kernels will crash if
EOFBLOCKS_FLis set when it is it notIs there a kernel fix to go with this, then?
There will be; Dmitry sent a patch in the ext4 patch a while back.
http://patchwork.ozlabs.org/patch/50469/
The fix to prevent the crash is tiny. The rest of the patch I need to review more carefully.... I'll get to it RSN.
- Ted
Quoted 11 lines · [email protected] wrote:
Quoted 3 lines · Eric Sandeen
Quoted 1 line · Theodore Ts'o
Some kernels will crash if
EOFBLOCKS_FLis set when it is it notIs there a kernel fix to go with this, then?
There will be; Dmitry sent a patch in the ext4 patch a while back.
http://patchwork.ozlabs.org/patch/50469/
The fix to prevent the crash is tiny. The rest of the patch I need to review more carefully.... I'll get to it RSN.
Ok sorry, I didn't put 2 & 2 together, there. :)
Thanks for the reminder,
-Eric
Quoted 1 line
- Ted
Quoted 8 lines · Eric Sandeen
Quoted 7 lines · [email protected] wrote:
Quoted 3 lines · Eric Sandeen
Quoted 1 line · Theodore Ts'o
Some kernels will crash if
EOFBLOCKS_FLis set when it is it notIs there a kernel fix to go with this, then?
There will be; Dmitry sent a patch in the ext4 patch a while back.
Quoted 8 lines
Quoted 4 lines
http://patchwork.ozlabs.org/patch/50469/
The fix to prevent the crash is tiny. The rest of the patch I need to review more carefully.... I'll get to it RSN.
Ok sorry, I didn't put 2 & 2 together, there. :)
Thanks for the reminder,
To be clear, the fix to prevent the crash is:
EXT4_ERROR_INODE(inode, "eh->eh_entries == 0 ee_block %d",
ex->ee_block);
to:
EXT4_ERROR_INODE(inode, "eh->eh_entries == 0, iblock = %u" iblock);
(this is the quick fix that we dropped into our production kernels, anyway; the problem is that ex is NULL, which means instead of marking the file system as needing repair, we Oops the system instead.)
I just haven't had the time to analyze the rest of the patch yet.
One of the things I've been considering is whether we should be trying to test for this failure at all. Is there a downside if EOFBLOCKS_FL is set when it shouldn't matter? Should we simply not try to check for the case? Or if we do check, should we just clear the flag and print a warning? The other side of the argument is if this is wrong, then either we have a kernel bug (see the first patch) or we had a hardware error, in which case something else might be wrong and maybe we should force a file system check.
- Ted