Whamcloud - gitweb
resize2fs: If resize2fs fails, tell the user to run e2fsck
authorTheodore Ts'o <tytso@mit.edu>
Fri, 10 Jul 2009 17:14:00 +0000 (13:14 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 11 Jul 2009 18:16:39 +0000 (14:16 -0400)
If the resize operation fails in the middle of the operation, mark the
filesystem as needing to be checked, and tell the user that they
should run e2fsck -fy on the device.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
resize/main.c
resize/resize2fs.c

index 2dae161..c6cbb5e 100644 (file)
@@ -445,7 +445,8 @@ int main (int argc, char ** argv)
                                device_name);
                        exit(1);
                }
-       printf("Resizing the filesystem on %s to %u (%dk) blocks.\n",
+               printf(_("Resizing the filesystem on "
+                        "%s to %u (%dk) blocks.\n"),
                       device_name, new_size, fs->blocksize / 1024);
                retval = resize_fs(fs, &new_size, flags,
                                   ((flags & RESIZE_PERCENT_COMPLETE) ?
@@ -455,7 +456,11 @@ int main (int argc, char ** argv)
        if (retval) {
                com_err(program_name, retval, _("while trying to resize %s"),
                        device_name);
-               ext2fs_close (fs);
+               fprintf(stderr,
+                       _("Please run 'e2fsck -fy %s' to fix the filesystem\n"
+                         "after the aborted resize operation.\n"),
+                       device_name);
+               ext2fs_close(fs);
                exit(1);
        }
        printf(_("The filesystem on %s is now %u blocks long.\n\n"),
index d907c9c..c0b00b6 100644 (file)
@@ -84,6 +84,10 @@ errcode_t resize_fs(ext2_filsys fs, blk_t *new_size, int flags,
        if (retval)
                return retval;
 
+       fs->super->s_state |= EXT2_ERROR_FS;
+       ext2fs_mark_super_dirty(fs);
+       ext2fs_flush(fs);
+
        /*
         * Create the data structure
         */
@@ -153,6 +157,7 @@ errcode_t resize_fs(ext2_filsys fs, blk_t *new_size, int flags,
        if (retval)
                goto errout;
 
+       rfs->new_fs->super->s_state &= ~EXT2_ERROR_FS;
        rfs->new_fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
        retval = ext2fs_close(rfs->new_fs);
        if (retval)