Whamcloud - gitweb
e2fsck: track errors/badness found for each inode
authorAndreas Dilger <andreas.dilger@intel.com>
Fri, 13 Apr 2012 07:13:58 +0000 (01:13 -0600)
committerAndreas Dilger <adilger@whamcloud.com>
Tue, 19 Apr 2022 00:16:07 +0000 (18:16 -0600)
commit7799a7651741f0468415bfa6f8edab3851677115
tree6163b82206f7788554fdb286c7265bdc5b5ad604
parent4f6226ce76cedaff55517692bdcda9cdd27f2be0
e2fsck: track errors/badness found for each inode

The present e2fsck code checks the inode, per field basis.  It
doesn't take into consideration to total sanity of the inode.
This may cause e2fsck turning a garbage inode into an apparently
sane inode ("It is a vessel of fertilizer, and none may abide
its strength").

Add heuristics into fix_problem() so that e2efsck tracks the degree
of badness of an inode, without needing to be added in many places
in code and explicitly set. An icount is used to keep track the
badness of every inode.  Take advantage of pctx->ino almost always
pointing at the bad inode and increment badness when fix_problem()
is called on an inode.  This also handles future problem addition.

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.

Badness above a certain threshold value results in clearing the
inode.  The default badness threshold value is 7, it can be tuned
for e2fsck using "-E inode_badness_threshold=<value>" if needed.

This can avoid lengthy pass1b shared block processing, where a
corrupt chunk of the inode table has resulted in a bunch of
garbage inodes suddenly having shared blocks with a lot of good
inodes (or each other).

Change-Id: I9f5f48d979afebb9c953d9fb2777ebf570f30c15
Signed-off-by: Girish Shilamkar <girish@clusterfs.com>
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
27 files changed:
e2fsck/e2fsck.8.in
e2fsck/e2fsck.c
e2fsck/e2fsck.h
e2fsck/pass1.c
e2fsck/pass1b.c
e2fsck/pass2.c
e2fsck/pass3.c
e2fsck/problem.c
e2fsck/problem.h
e2fsck/super.c
e2fsck/unix.c
lib/ext2fs/ext2fs.h
lib/ext2fs/icount.c
tests/f_ibadness/expect.1 [new file with mode: 0644]
tests/f_ibadness/expect.2 [new file with mode: 0644]
tests/f_ibadness/image.gz [new file with mode: 0644]
tests/f_ibadness/name [new file with mode: 0644]
tests/f_ibadness/script [new file with mode: 0644]
tests/f_ibadness_bad_extents/expect.1 [new file with mode: 0644]
tests/f_ibadness_bad_extents/expect.2 [new file with mode: 0644]
tests/f_ibadness_bad_extents/image.gz [new file with mode: 0644]
tests/f_ibadness_bad_extents/name [new file with mode: 0644]
tests/f_ibadness_bad_extents/script [new file with mode: 0644]
tests/f_messy_inode/expect.1
tests/f_messy_inode/expect.2
tests/f_messy_inode/script [new file with mode: 0644]
tests/filter.sed