From: Theodore Ts'o Date: Mon, 25 Jun 2018 01:09:59 +0000 (-0400) Subject: e2fsck: only retry to open the file system when the superblock is corrupt X-Git-Tag: v1.44.3-rc1~7 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=51a3b0b3dcce2e35091292c33fcc88bd4ddf6bd8;p=tools%2Fe2fsprogs.git e2fsck: only retry to open the file system when the superblock is corrupt Previously we were always retrying the ext2fs_open2() call with the EXT2_FLAG_IGNORE_SB_ERRORS flag. It only makes sense to do this if the superblock is reported as corrupt. Otherwise, it's a waste of time, and results in printing an extra set of error messages to annoy the user. Signed-off-by: Theodore Ts'o --- diff --git a/e2fsck/unix.c b/e2fsck/unix.c index 42eef75..90065b3 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -1584,7 +1584,8 @@ failure: * so that we are able to recover from more errors * (e.g. some tool messing up some value in the sb). */ - if (!(flags & EXT2_FLAG_IGNORE_SB_ERRORS)) { + if ((retval == EXT2_ET_CORRUPT_SUPERBLOCK) && + !(flags & EXT2_FLAG_IGNORE_SB_ERRORS)) { if (fs) ext2fs_close_free(&fs); log_out(ctx, _("%s: Trying to load superblock " diff --git a/tests/f_detect_xfs/expect b/tests/f_detect_xfs/expect index f91010b..fb510d9 100644 --- a/tests/f_detect_xfs/expect +++ b/tests/f_detect_xfs/expect @@ -2,10 +2,6 @@ ext2fs_open2: Bad magic number in super-block ../e2fsck/e2fsck: Superblock invalid, trying backup blocks... ../e2fsck/e2fsck: Bad magic number in super-block while trying to open test.img -../e2fsck/e2fsck: Trying to load superblock despite errors... -ext2fs_open2: Bad magic number in super-block -../e2fsck/e2fsck: Superblock invalid, trying backup blocks... -../e2fsck/e2fsck: Bad magic number in super-block while trying to open test.img The superblock could not be read or does not describe a valid ext2/ext3/ext4 filesystem. If the device is valid and it really contains an ext2/ext3/ext4 diff --git a/tests/j_ext_dumpe2fs/expect b/tests/j_ext_dumpe2fs/expect index a703bcf..db77a36 100644 --- a/tests/j_ext_dumpe2fs/expect +++ b/tests/j_ext_dumpe2fs/expect @@ -1,7 +1,5 @@ e2fsck external journal ../e2fsck/e2fsck: Filesystem has unsupported feature(s) while trying to open test.img -../e2fsck/e2fsck: Trying to load superblock despite errors... -../e2fsck/e2fsck: Filesystem has unsupported feature(s) while trying to open test.img The superblock could not be read or does not describe a valid ext2/ext3/ext4 filesystem. If the device is valid and it really contains an ext2/ext3/ext4