LU-5949 e2fsck: simplify inode badness handling
Move the badness increment into fix_problem() so that code does
not need to be spread across the code and explicitly set. Instead,
take advantage of the fact that pctx->ino is almost always pointing
at the bad inode and increment badness whenever fix_problem() is
called on the inode. This also handles new problems in the future.
That leaves only a handful of places in the code that need special
handling to either set a higher badness (e.g. inode blocks that are
directly referencing filesystem metadata or have wildly incorrect
timestamps), or should not contribute to inode badness at all.
The main exceptions are when reprocessing duplicate blocks in the
inode (badness already set), and cleaning bad entries in a directory
leaf block in check_dir_block(), which uses pctx->ino to reference
the parent directory inode number. In such cases, fix_problem_bad()
is called with 0 badness, since the leaf block was been repaired,
and clearing the directory inode in this case is unnecessary.
This patch should be merged into original badness patch on rebase.
Fixes:
92a85a3ced2c ("e2fsck: track errors/badness found for each inode")
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I96cd21b5976991f0bb1c63fc99857c80e23ebbe5
Reviewed-on: https://review.whamcloud.com/41328
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Wang Shilong <wshilong@whamcloud.com>
Reviewed-by: Artem Blagodarenko <artem.blagodarenko@hpe.com>
Change-Id: Ie3f1f33a1e227cd241632e1506344f53788b3109
Signed-off-by: Girish Shilamkar <girish@clusterfs.com>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
--- /dev/null
+Pass 1: Checking inodes, blocks, and sizes
+e2fsck_pass1_run: increase inode 13 badness 0 to 1 for 10005
+Inode 13 is in use, but has dtime set. Fix? yes
+
+e2fsck_pass1_run: increase inode 13 badness 1 to 2 for 2000f
+e2fsck_pass1_run: increase inode 13 badness 2 to 3 for 20044
+add_encrypted_file: increase inode 13 badness 3 to 4 for 1008a
+Inode 13 has encrypt flag but no encryption extended attribute.
+Clear flag? yes
+
+e2fsck_pass1_run: increase inode 13 badness 4 to 6 for 10084
+check_ext_attr: increase inode 13 badness 6 to 7 for 2000e
+process_block: increase inode 13 badness 7 to 8 for 1000e
+Inode 13 has illegal block(s). Clear? yes
+
+Illegal block #0 (4294967295) in inode 13. CLEARED.
+process_block: increase inode 13 badness 8 to 9 for 1000e
+Illegal block #1 (4294967295) in inode 13. CLEARED.
+process_block: increase inode 13 badness 9 to 10 for 1000e
+Illegal block #7 (12345678) in inode 13. CLEARED.
+process_block: increase inode 13 badness 10 to 11 for 1000e
+Illegal triple indirect block (1234567) in inode 13. CLEARED.
+check_blocks: increase inode 13 badness 11 to 12 for 1000d
+Inode 13, i_blocks is 3453453, should be 138. Fix? yes
+
+Pass 2: Checking directory structure
+e2fsck_process_bad_inode: increase inode 13 badness 12 to 13 for 2000e
+i_file_acl for inode 13 (/testfile) is 345, should be zero.
+Clear? yes
+
+e2fsck_process_bad_inode: increase inode 13 badness 13 to 14 for 2000d
+i_faddr for inode 13 (/testfile) is 34534, should be zero.
+Clear? yes
+
+Inode 13 is badly corrupt (badness value = 14). Clear? yes
+
+Entry 'testfile' in / (2) has deleted/unused inode 13. Clear? yes
+
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+Block bitmap differences: -(1368--1369) -1375
+Fix? yes
+
+Free blocks count wrong for group #0 (6822, counted=6825).
+Fix? yes
+
+Free blocks count wrong (14690, counted=14693).
+Fix? yes
+
+Free inodes count wrong for group #0 (2039, counted=2037).
+Fix? yes
+
+Free inodes count wrong (4087, counted=4085).
+Fix? yes
+
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 11/4096 files (9.1% non-contiguous), 1691/16384 blocks
+Exit status is 1
--- /dev/null
+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: 11/4096 files (0.0% non-contiguous), 1691/16384 blocks
+Exit status is 0
--- /dev/null
+Inode with badness over threshold
--- /dev/null
+FSCK_OPT="-fyd"
+SECOND_FSCK_OPT=-yf
+
+. $cmd_dir/run_e2fsck
--- /dev/null
+Pass 1: Checking inodes, blocks, and sizes
+e2fsck_pass1_run: increase inode 12 badness 0 to 1 for 1005c
+Inode 12 missing EXTENT_FL, but is in extents format
+Fix? yes
+
+e2fsck_pass1_run: increase inode 12 badness 1 to 2 for 10005
+Inode 12 is in use, but has dtime set. Fix? yes
+
+e2fsck_pass1_run: increase inode 12 badness 2 to 3 for 20044
+e2fsck_pass1_run: increase inode 12 badness 3 to 4 for 10084
+e2fsck_pass1_run: increase inode 12 badness 4 to 5 for 10084
+e2fsck_pass1_run: increase inode 12 badness 5 to 7 for 10084
+check_ext_attr: increase inode 12 badness 7 to 8 for 2000e
+scan_extent_node: increase inode 12 badness 8 to 9 for 10058
+Inode 12 has an invalid extent
+ (logical block 0, invalid physical block 1231231222, len 492)
+Clear? yes
+
+scan_extent_node: increase inode 12 badness 9 to 10 for 10058
+Inode 12 has an invalid extent
+ (logical block 556, invalid physical block 4294967295, len 45)
+Clear? yes
+
+scan_extent_node: increase inode 12 badness 10 to 11 for 10058
+Inode 12 has an invalid extent
+ (logical block 666, invalid physical block 4294967295, len 5)
+Clear? yes
+
+scan_extent_node: increase inode 12 badness 11 to 12 for 10058
+Inode 12 has an invalid extent
+ (logical block 700, invalid physical block 4294967295, len 45)
+Clear? yes
+
+check_blocks: increase inode 12 badness 12 to 13 for 1000d
+Inode 12, i_blocks is 984, should be 0. Fix? yes
+
+Inode 12 is badly corrupt (badness value = 13). Clear? yes
+
+Restarting e2fsck from the beginning...
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Entry 'testfile' 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
+Block bitmap differences: -(6145--6636)
+Fix? yes
+
+Free blocks count wrong for group #0 (6525, counted=7017).
+Fix? yes
+
+Free blocks count wrong (14584, counted=15076).
+Fix? yes
+
+Inode bitmap differences: -12
+Fix? yes
+
+Free inodes count wrong for group #0 (1012, counted=1013).
+Fix? yes
+
+Free inodes count wrong (2036, counted=2037).
+Fix? yes
+
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 11/2048 files (0.0% non-contiguous), 1308/16384 blocks
+Exit status is 1
--- /dev/null
+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: 11/2048 files (0.0% non-contiguous), 1308/16384 blocks
+Exit status is 0
--- /dev/null
+All in inode extents corrupt
--- /dev/null
+FSCK_OPT="-fyd"
+SECOND_FSCK_OPT=-yf
+
+. $cmd_dir/run_e2fsck
s/mmp_update_time: .*/mmp_update_time: test_time/
s/MMP last updated by '.*' on .*/MMP last updated by 'test_node' on test date/
s/MMP update by '.*' at .*/MMP last updated by 'test_node' on test date/
+s/:[0-9]*: \(increase inode [0-9]* badness\)/: \1/