summaryrefslogtreecommitdiff
path: root/e2fsck/unix.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2011-06-16 01:13:42 -0400
committerTheodore Ts'o <tytso@mit.edu>2011-06-16 01:22:02 -0400
commita3efe4842054175d01b465fbe0b29b9be8b800a1 (patch)
treee00375edf712715a27328af15306accf366efc2a /e2fsck/unix.c
parent96367ad3bc849220651b20f41340b48e07e82b04 (diff)
downloade2fsprogs-a3efe4842054175d01b465fbe0b29b9be8b800a1.tar.gz
e2fsck: fix mysterious "FILE SYSTEM WAS MODIFIED" with no changes
Commit 2a77a784a3 (firest released in e2fsprogs 1.33) compared superblock summary free blocks and inode counts with the allocation bitmap counts before starting the file system check proper, and if they differed, set the superblock and marked it as dirty. If no other file systme changes were required, this would cause a "*** FILE SYSTEM WAS MODIFIED ***" message without any explanation of what e2fsck had changed. We fix this by only setting the superblock summary free block/inodes counts if we are skipping a full check, and in non-preen mode, e2fsck will now print an explicit message stating how the superblock had been updated. In a full check, any updates to the superblock free blocks/inodes fields will be noted in pass5. This change requires changing a few test results (essentially reversing the changes made in commit 2a77a784a3). Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'e2fsck/unix.c')
-rw-r--r--e2fsck/unix.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index a43f0c9b..7e95ca88 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -287,6 +287,7 @@ static int is_on_batt(void)
static void check_if_skip(e2fsck_t ctx)
{
ext2_filsys fs = ctx->fs;
+ struct problem_context pctx;
const char *reason = NULL;
unsigned int reason_arg = 0;
long next_check;
@@ -349,6 +350,36 @@ static void check_if_skip(e2fsck_t ctx)
fputs(_(", check forced.\n"), stdout);
return;
}
+
+ /*
+ * Update the global counts from the block group counts. This
+ * is needed since modern kernels don't update the global
+ * counts so as to avoid locking the entire file system. So
+ * if the filesystem is not unmounted cleanly, the global
+ * counts may not be accurate. Update them here if we can,
+ * for the benefit of users who might examine the file system
+ * using dumpe2fs. (This is for cosmetic reasons only.)
+ */
+ clear_problem_context(&pctx);
+ pctx.ino = fs->super->s_free_inodes_count;
+ pctx.ino2 = ctx->free_inodes;
+ if ((pctx.ino != pctx.ino2) &&
+ !(ctx->options & E2F_OPT_READONLY) &&
+ fix_problem(ctx, PR_0_FREE_INODE_COUNT, &pctx)) {
+ fs->super->s_free_inodes_count = ctx->free_inodes;
+ ext2fs_mark_super_dirty(fs);
+ }
+ clear_problem_context(&pctx);
+ pctx.blk = ext2fs_free_blocks_count(fs->super);
+ pctx.blk2 = ctx->free_blocks;
+ if ((pctx.blk != pctx.blk2) &&
+ !(ctx->options & E2F_OPT_READONLY) &&
+ fix_problem(ctx, PR_0_FREE_BLOCK_COUNT, &pctx)) {
+ ext2fs_free_blocks_count_set(fs->super, ctx->free_blocks);
+ ext2fs_mark_super_dirty(fs);
+ }
+
+ /* Print the summary message when we're skipping a full check */
printf(_("%s: clean, %u/%u files, %llu/%llu blocks"), ctx->device_name,
fs->super->s_inodes_count - fs->super->s_free_inodes_count,
fs->super->s_inodes_count,