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

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