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

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