One difficulty with checking the badness before doing the duplicate scanning is that the outcome depends on the order the inodes were processed in. The e2fsck block bitmap only stores if a block is used for pass1, assuming that no duplicate blocks exist in the filesystem. If e2fsck finds any duplicate blocks it has to re-scan the whole filesystem to find the inodes that are sharing blocks.
It is possible that we could avoid pass1 in some cases by clearing the bad inode rather than adding the blocks into the bitmap, assuming that the good inode is processed first and adds its blocks to the bitmap, and then the bad inode is found later and verified and does not add which would avoid pass1b sometimes.
The other proposal that Ted Ts'o had was to check all inodes in a block at the same time. That makes it easier to detect if a whole block is corrupted.
Andreas Dilger (adilger@whamcloud.com) merged in patch https://review.whamcloud.com/41450/
Subject:
LU-5949e2fsck: call delete_inode() properlyProject: tools/e2fsprogs
Branch: master-lustre
Current Patch Set:
Commit: 4aea203f2d490f53596eb21233bf0c186a5b3679