From: Darrick J. Wong Date: Sun, 3 Aug 2014 02:32:12 +0000 (-0400) Subject: e2fsck: try to salvage corrupt directory entry blocks X-Git-Tag: v1.43-WIP-2015-05-18~260 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f43a46fad362435f8420f656c6157dc8be8dd4d;p=thirdparty%2Fe2fsprogs.git e2fsck: try to salvage corrupt directory entry blocks Remove the code that would prompt the user to zap directory entry blocks with bad checksums (i.e. strict_csums). Instead, we'll run the directory entries through the usual repair routines in an attempt to save whatever we can. At the same time, refactor the code that schedules the repair of missing dirblock checksum entries. Signed-off-by: Darrick J. Wong Signed-off-by: Theodore Ts'o --- diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c index 69ebab6fe..ae7768f9f 100644 --- a/e2fsck/pass2.c +++ b/e2fsck/pass2.c @@ -944,32 +944,16 @@ static int check_dir_block(ext2_filsys fs, out_htree: #endif /* ENABLE_HTREE */ - /* Verify checksum. */ - if (is_leaf && de_csum_size && !inline_data_size) { - /* No space for csum? Rebuild dirs in pass 3A. */ - if (!ext2fs_dirent_has_tail(fs, (struct ext2_dir_entry *)buf)) { - de_csum_size = 0; - if (e2fsck_dir_will_be_rehashed(ctx, ino)) - goto skip_checksum; - if (!fix_problem(cd->ctx, PR_2_LEAF_NODE_MISSING_CSUM, - &cd->pctx)) - goto skip_checksum; - e2fsck_rehash_dir_later(ctx, ino); + /* Leaf node with no space for csum? Rebuild dirs in pass 3A. */ + if (is_leaf && !inline_data_size && failed_csum && + !ext2fs_dirent_has_tail(fs, (struct ext2_dir_entry *)buf)) { + de_csum_size = 0; + if (e2fsck_dir_will_be_rehashed(ctx, ino) || + !fix_problem(cd->ctx, PR_2_LEAF_NODE_MISSING_CSUM, + &cd->pctx)) goto skip_checksum; - } - if (failed_csum) { - char *buf2; - if (!fix_problem(cd->ctx, PR_2_LEAF_NODE_CSUM_INVALID, - &cd->pctx)) - goto skip_checksum; - ext2fs_new_dir_block(fs, - db->blockcnt == 0 ? ino : 0, - EXT2_ROOT_INO, &buf2); - memcpy(buf, buf2, fs->blocksize); - ext2fs_free_mem(&buf2); - dir_modified++; - failed_csum = 0; - } + e2fsck_rehash_dir_later(ctx, ino); + goto skip_checksum; } /* htree nodes don't use fake dirents to store checksums */ if (!is_leaf) diff --git a/e2fsck/problem.c b/e2fsck/problem.c index 1b6bdb00e..80ca3a081 100644 --- a/e2fsck/problem.c +++ b/e2fsck/problem.c @@ -1477,11 +1477,6 @@ static struct e2fsck_problem problem_table[] = { N_("@p @h %d: internal node fails checksum.\n"), PROMPT_CLEAR_HTREE, PR_PREEN_OK }, - /* leaf node fails checksum */ - { PR_2_LEAF_NODE_CSUM_INVALID, - N_("@d @i %i, %B, offset %N: @d fails checksum.\n"), - PROMPT_SALVAGE, PR_PREEN_OK }, - /* leaf node has no checksum */ { PR_2_LEAF_NODE_MISSING_CSUM, N_("@d @i %i, %B, offset %N: @d has no checksum.\n"), diff --git a/e2fsck/problem.h b/e2fsck/problem.h index 89db5f309..4813fc604 100644 --- a/e2fsck/problem.h +++ b/e2fsck/problem.h @@ -879,9 +879,6 @@ struct problem_context { /* htree node fails checksum */ #define PR_2_HTREE_NODE_CSUM_INVALID 0x02004A -/* dir leaf node fails checksum */ -#define PR_2_LEAF_NODE_CSUM_INVALID 0x02004B - /* no space in leaf for checksum */ #define PR_2_LEAF_NODE_MISSING_CSUM 0x02004C