]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
tune2fs: if turning off csum_seed and the UUID has changed, require fsck
authorTheodore Ts'o <tytso@mit.edu>
Sun, 25 Feb 2018 01:23:24 +0000 (20:23 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 25 Feb 2018 01:23:24 +0000 (20:23 -0500)
In the case where the UUID has changed and the user wants to turn off
the csum_seed feature, it's important that file system be freshly
checked.  That's also the only case when it's necessary to recalculate
all of the metadata file systems.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
misc/tune2fs.c

index 9c8b6e43df938ae13c46106c82294d54238792e1..b11b2e3f30c8ec3b0470a0f61e75f16061594876 100644 (file)
@@ -1366,16 +1366,18 @@ mmp_error:
 
                uuid_seed = ext2fs_crc32c_le(~0, fs->super->s_uuid,
                                        sizeof(fs->super->s_uuid));
-               if (fs->super->s_checksum_seed != uuid_seed &&
-                   (mount_flags & EXT2_MF_MOUNTED)) {
-                       fputs(_("UUID has changed since enabling "
-                               "metadata_csum.  Filesystem must be unmounted "
-                               "\nto safely rewrite all metadata to "
-                               "match the new UUID.\n"), stderr);
-                       return 1;
+               if (fs->super->s_checksum_seed != uuid_seed) {
+                       if (mount_flags & (EXT2_MF_BUSY|EXT2_MF_MOUNTED)) {
+                               fputs(_("UUID has changed since enabling "
+               "metadata_csum.  Filesystem must be unmounted "
+               "\nto safely rewrite all metadata to match the new UUID.\n"),
+                                     stderr);
+                               return 1;
+                       }
+                       check_fsck_needed(fs, _("Recalculating checksums "
+                                               "could take some time."));
+                       rewrite_checksums = 1;
                }
-
-               rewrite_checksums = 1;
        }
 
        if (sb->s_rev_level == EXT2_GOOD_OLD_REV &&