From: Zheng Liu <wenqing.lz@xxxxxxxxxx> in __ext4_get_inode_loc, when all other inodes are free, we will skip I/O. Thus, all of inodes in this block are set to 0. Then when we scan these inodes in pass1, we will get a metadata checksum error. However, we don't need to scan these inodes because they have been freed. This bug can be reproduced by xfstests #013. Reported-by: Tao Ma <boyu.tm@xxxxxxxxxx> Cc: Darrick J. Wong <djwong@xxxxxxxxxx> Cc: "Theodore Ts'o" <tytso@xxxxxxx> Signed-off-by: Zheng Liu <wenqing.lz@xxxxxxxxxx> --- e2fsck/pass1.c | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-) diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index 48a1af0..72f8e82 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -583,6 +583,7 @@ void e2fsck_pass1(e2fsck_t ctx) ext2_ino_t ino = 0; struct ext2_inode *inode; ext2_inode_scan scan; + errcode_t csum_errcode; char *block_buf; #ifdef RESOURCE_TRACK struct resource_track rtrack; @@ -788,12 +789,7 @@ void e2fsck_pass1(e2fsck_t ctx) pctx.inode = inode; ctx->stashed_ino = ino; - /* Clear corrupt inode? */ - if (pctx.errcode == EXT2_ET_INODE_CSUM_INVALID) { - if (fix_problem(ctx, PR_1_INODE_CSUM_INVALID, &pctx)) - goto clear_inode; - failed_csum = 1; - } + csum_errcode = pctx.errcode; if (inode->i_links_count) { pctx.errcode = ext2fs_icount_store(ctx->inode_link_info, @@ -1063,6 +1059,14 @@ void e2fsck_pass1(e2fsck_t ctx) } continue; } + + /* Clear corrupt inode? */ + if (csum_errcode == EXT2_ET_INODE_CSUM_INVALID) { + if (fix_problem(ctx, PR_1_INODE_CSUM_INVALID, &pctx)) + goto clear_inode; + failed_csum = 1; + } + /* * n.b. 0.3c ext2fs code didn't clear i_links_count for * deleted files. Oops. -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html