]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
tune2fs: warn if the filesystem journal is dirty
authorJim Garlick <garlick@llnl.gov>
Mon, 30 Nov 2015 17:13:39 +0000 (12:13 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 30 Nov 2015 17:13:39 +0000 (12:13 -0500)
Running tune2fs on a filesystem with an unrecovered journal can
cause the tune2fs settings changes in the superblock to be reverted
when the journal is replayed if it contains an uncommitted copy of
the superblock.  Print a warning if this is detected so that the
user isn't surprised if it happens.

Signed-off-by: Jim Garlick <garlick@llnl.gov>
Updated message printed to include steps to replay journal.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
misc/tune2fs.c

index cd1d17f509f9d5eadebe4a1ce4baa1ebe73a5d0e..aed0a35a03addd4153063339e6361006bb1dec02 100644 (file)
@@ -2406,6 +2406,18 @@ retry_open:
                       ext_mount_opts);
                free(ext_mount_opts);
        }
+
+       /* Warn if file system needs recovery and it is opened for writing. */
+       if ((open_flag & EXT2_FLAG_RW) && !(mount_flags & EXT2_MF_MOUNTED) &&
+           (sb->s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL) &&
+           (sb->s_feature_incompat & EXT3_FEATURE_INCOMPAT_RECOVER)) {
+               fprintf(stderr,
+_("Warning: The journal is dirty. You may wish to replay the journal like:\n\n"
+  "\te2fsck -E journal_only %s\n\n"
+  "then rerun this command.  Otherwise, any changes made may be overwritten\n"
+  "by journal recovery.\n"), device_name);
+       }
+
        free(device_name);
        remove_error_table(&et_ext2_error_table);