Whamcloud - gitweb
e2fsck: Move check to add an index to a directory after fixing i_size
authorTheodore Ts'o <tytso@mit.edu>
Sat, 28 Nov 2009 14:44:08 +0000 (09:44 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 29 Nov 2009 06:03:04 +0000 (01:03 -0500)
The check that determines whether an directory needs to be have an
index added to it depends on i_size.  So move it after we have fixed
up i_size so that we reliable will rehash a directory that needs it,
even if its i_size field was originally incorrect.  Otherwise, a
second run of e2fsck would be needed before the directory gets an
index added.

Thanks to Mikulas Patocka for providing a sample file system which
demonstrated this problem.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
e2fsck/pass1.c

index b534841..d2021dd 100644 (file)
@@ -1896,10 +1896,6 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
 #endif
                }
        }
-       if (ctx->dirs_to_hash && pb.is_dir &&
-           !(inode->i_flags & EXT2_INDEX_FL) &&
-           ((inode->i_size / fs->blocksize) >= 3))
-               ext2fs_u32_list_add(ctx->dirs_to_hash, ino);
 
        if (!pb.num_blocks && pb.is_dir) {
                if (fix_problem(ctx, PR_1_ZERO_LENGTH_DIR, pctx)) {
@@ -1977,6 +1973,12 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
                }
                pctx->num = 0;
        }
+
+       if (ctx->dirs_to_hash && pb.is_dir &&
+           !(inode->i_flags & EXT2_INDEX_FL) &&
+           ((inode->i_size / fs->blocksize) >= 3))
+               ext2fs_u32_list_add(ctx->dirs_to_hash, ino);
+
 out:
        if (dirty_inode)
                e2fsck_write_inode(ctx, ino, inode, "check_blocks");