|
|
ec15cf |
commit 7d7a8fe4ea4d9162977a1a6b32c4737d9ca9dd1f
|
|
|
ec15cf |
Author: Eric Sandeen <sandeen@redhat.com>
|
|
|
ec15cf |
Date: Mon Jun 9 09:52:19 2014 -0400
|
|
|
ec15cf |
|
|
|
ec15cf |
resize2fs: don't attempt to calculate minimum size on fs with errors
|
|
|
ec15cf |
|
|
|
ec15cf |
My old patch:
|
|
|
ec15cf |
|
|
|
ec15cf |
resize2fs: don't print minimum size if fs is not clean
|
|
|
ec15cf |
|
|
|
ec15cf |
almost did this, but it still calculated the size; it just didn't print
|
|
|
ec15cf |
it. Which is a bit silly.
|
|
|
ec15cf |
|
|
|
ec15cf |
Jes had a pretty badly corrupted image which made the minimum size
|
|
|
ec15cf |
calculation go off into the weeds. It was corrupted, and also marked
|
|
|
ec15cf |
as having an error.
|
|
|
ec15cf |
|
|
|
ec15cf |
We'll eventually bail out for an unmounted filesystem if it's marked
|
|
|
ec15cf |
as being in an error state anyway; just move that test & bail-out
|
|
|
ec15cf |
to a much earlier point, and remove the now-duplicate one under the
|
|
|
ec15cf |
print_min_size block.
|
|
|
ec15cf |
|
|
|
ec15cf |
This will catch & block all resize operations on an offline filesystem
|
|
|
ec15cf |
with errors, in one central place.
|
|
|
ec15cf |
|
|
|
ec15cf |
Reported-by: Jes Sorensen <Jes.Sorensen@redhat.com>
|
|
|
ec15cf |
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
|
|
|
ec15cf |
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
|
|
|
ec15cf |
|
|
|
ec15cf |
diff --git a/resize/main.c b/resize/main.c
|
|
|
ec15cf |
index 2b7abff..e65c8e4 100644
|
|
|
ec15cf |
--- a/resize/main.c
|
|
|
ec15cf |
+++ b/resize/main.c
|
|
|
ec15cf |
@@ -319,6 +319,17 @@ int main (int argc, char ** argv)
|
|
|
ec15cf |
exit (1);
|
|
|
ec15cf |
}
|
|
|
ec15cf |
|
|
|
ec15cf |
+ if (!(mount_flags & EXT2_MF_MOUNTED)) {
|
|
|
ec15cf |
+ if (!force && ((fs->super->s_lastcheck < fs->super->s_mtime) ||
|
|
|
ec15cf |
+ (fs->super->s_state & EXT2_ERROR_FS) ||
|
|
|
ec15cf |
+ ((fs->super->s_state & EXT2_VALID_FS) == 0))) {
|
|
|
ec15cf |
+ fprintf(stderr,
|
|
|
ec15cf |
+ _("Please run 'e2fsck -f %s' first.\n\n"),
|
|
|
ec15cf |
+ device_name);
|
|
|
ec15cf |
+ exit(1);
|
|
|
ec15cf |
+ }
|
|
|
ec15cf |
+ }
|
|
|
ec15cf |
+
|
|
|
ec15cf |
/*
|
|
|
ec15cf |
* Check for compatibility with the feature sets. We need to
|
|
|
ec15cf |
* be more stringent than ext2fs_open().
|
|
|
ec15cf |
@@ -332,13 +343,6 @@ int main (int argc, char ** argv)
|
|
|
ec15cf |
min_size = calculate_minimum_resize_size(fs, flags);
|
|
|
ec15cf |
|
|
|
ec15cf |
if (print_min_size) {
|
|
|
ec15cf |
- if (!force && ((fs->super->s_state & EXT2_ERROR_FS) ||
|
|
|
ec15cf |
- ((fs->super->s_state & EXT2_VALID_FS) == 0))) {
|
|
|
ec15cf |
- fprintf(stderr,
|
|
|
ec15cf |
- _("Please run 'e2fsck -f %s' first.\n\n"),
|
|
|
ec15cf |
- device_name);
|
|
|
ec15cf |
- exit(1);
|
|
|
ec15cf |
- }
|
|
|
ec15cf |
printf(_("Estimated minimum size of the filesystem: %llu\n"),
|
|
|
ec15cf |
min_size);
|
|
|
ec15cf |
exit(0);
|
|
|
ec15cf |
@@ -444,14 +448,6 @@ int main (int argc, char ** argv)
|
|
|
ec15cf |
bigalloc_check(fs, force);
|
|
|
ec15cf |
retval = online_resize_fs(fs, mtpt, &new_size, flags);
|
|
|
ec15cf |
} else {
|
|
|
ec15cf |
- if (!force && ((fs->super->s_lastcheck < fs->super->s_mtime) ||
|
|
|
ec15cf |
- (fs->super->s_state & EXT2_ERROR_FS) ||
|
|
|
ec15cf |
- ((fs->super->s_state & EXT2_VALID_FS) == 0))) {
|
|
|
ec15cf |
- fprintf(stderr,
|
|
|
ec15cf |
- _("Please run 'e2fsck -f %s' first.\n\n"),
|
|
|
ec15cf |
- device_name);
|
|
|
ec15cf |
- exit(1);
|
|
|
ec15cf |
- }
|
|
|
ec15cf |
bigalloc_check(fs, force);
|
|
|
ec15cf |
printf(_("Resizing the filesystem on "
|
|
|
ec15cf |
"%s to %llu (%dk) blocks.\n"),
|