Blame SOURCES/e2fsprogs-1.42.9-resize2fs-fs-with-errors.patch

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