All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@redhat.com>
To: ext4 development <linux-ext4@vger.kernel.org>,
	Jes Sorensen <Jes.Sorensen@redhat.com>
Subject: [PATCH] resize2fs: Don't attempt to calculate minimum size on fs with errors
Date: Wed, 04 Jun 2014 16:12:47 -0500	[thread overview]
Message-ID: <538F8BCF.7090405@redhat.com> (raw)

My old patch:

	resize2fs: don't print minimum size if fs is not clean

almost did this, but it still calculated the size; it just didn't print
it.  Which is a bit silly.

Jes had a pretty badly corrupted image which made the minimum size
calculation go off into the weeds.  It was corrupted, and also marked
as having an error.

We'll eventually bail out for an unmounted filesystem if it's marked
as being in an error state anyway; just move that test & bail-out
to a much earlier point, and remove the now-duplicate one under the
print_min_size block.

This will catch & block all resize operations on an offline filesystem
with errors, in one central place.

Reported-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

diff --git a/resize/main.c b/resize/main.c
index 2b7abff..e65c8e4 100644
--- a/resize/main.c
+++ b/resize/main.c
@@ -319,6 +319,17 @@ int main (int argc, char ** argv)
 		exit (1);
 	}
 
+	if (!(mount_flags & EXT2_MF_MOUNTED)) {
+		if (!force && ((fs->super->s_lastcheck < fs->super->s_mtime) ||
+			       (fs->super->s_state & EXT2_ERROR_FS) ||
+			       ((fs->super->s_state & EXT2_VALID_FS) == 0))) {
+			fprintf(stderr,
+				_("Please run 'e2fsck -f %s' first.\n\n"),
+				device_name);
+			exit(1);
+		}
+	}
+
 	/*
 	 * Check for compatibility with the feature sets.  We need to
 	 * be more stringent than ext2fs_open().
@@ -332,13 +343,6 @@ int main (int argc, char ** argv)
 	min_size = calculate_minimum_resize_size(fs, flags);
 
 	if (print_min_size) {
-		if (!force && ((fs->super->s_state & EXT2_ERROR_FS) ||
-			       ((fs->super->s_state & EXT2_VALID_FS) == 0))) {
-			fprintf(stderr,
-				_("Please run 'e2fsck -f %s' first.\n\n"),
-				device_name);
-			exit(1);
-		}
 		printf(_("Estimated minimum size of the filesystem: %llu\n"),
 		       min_size);
 		exit(0);
@@ -444,14 +448,6 @@ int main (int argc, char ** argv)
 		bigalloc_check(fs, force);
 		retval = online_resize_fs(fs, mtpt, &new_size, flags);
 	} else {
-		if (!force && ((fs->super->s_lastcheck < fs->super->s_mtime) ||
-			       (fs->super->s_state & EXT2_ERROR_FS) ||
-			       ((fs->super->s_state & EXT2_VALID_FS) == 0))) {
-			fprintf(stderr,
-				_("Please run 'e2fsck -f %s' first.\n\n"),
-				device_name);
-			exit(1);
-		}
 		bigalloc_check(fs, force);
 		printf(_("Resizing the filesystem on "
 			 "%s to %llu (%dk) blocks.\n"),


             reply	other threads:[~2014-06-04 21:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-04 21:12 Eric Sandeen [this message]
2014-06-09 13:52 ` [PATCH] resize2fs: Don't attempt to calculate minimum size on fs with errors Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=538F8BCF.7090405@redhat.com \
    --to=sandeen@redhat.com \
    --cc=Jes.Sorensen@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.