]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
e2fsck: try to salvage corrupt directory entry blocks
authorDarrick J. Wong <darrick.wong@oracle.com>
Sun, 3 Aug 2014 02:32:12 +0000 (22:32 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 3 Aug 2014 02:32:12 +0000 (22:32 -0400)
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 <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/pass2.c
e2fsck/problem.c
e2fsck/problem.h

index 69ebab6fef3f52546ad94c2d5d417bc87ac30fbf..ae7768f9f78bd6c8829f5f28383ddcb041bcac3d 100644 (file)
@@ -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)
index 1b6bdb00eda5e62364618a4770c59f6de333f4a6..80ca3a081d974dff8a0b96e22b0d0963f9b1014a 100644 (file)
@@ -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"),
index 89db5f3090c46e02f18c3d02a65efaf485607ed3..4813fc604d4623c4c6b205be4fb22e17e6b6bf26 100644 (file)
@@ -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