linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@redhat.com>
To: ext4 development <linux-ext4@vger.kernel.org>
Subject: [PATCH] resize2fs: don't try to resize below calculated minimum
Date: Mon, 18 May 2009 17:11:28 -0500	[thread overview]
Message-ID: <4A11DD10.2060404@redhat.com> (raw)

Without a force flag, don't allow resize2fs to even start resizing
below what it thinks the minimum safe value is.

This may stop resizes which could otherwise proceed with a bit
of space still left, but seems like a reasonably safe thing to do.

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

(sorry, this should have been [PATCH 3/3] I guess, I did this
too iteratively)

Index: e2fsprogs/resize/main.c
===================================================================
--- e2fsprogs.orig/resize/main.c
+++ e2fsprogs/resize/main.c
@@ -160,6 +160,7 @@ int main (int argc, char ** argv)
 	int		fd, ret;
 	blk_t		new_size = 0;
 	blk_t		max_size = 0;
+	blk_t		min_size = 0;
 	io_manager	io_ptr;
 	char		*new_size_str = 0;
 	int		use_stride = -1;
@@ -341,9 +342,11 @@ int main (int argc, char ** argv)
 		exit(1);
 	}
 
+	min_size = calculate_minimum_resize_size(fs);
+
 	if (print_min_size) {
 		printf(_("Estimated minimum size of the filesystem: %u\n"),
-		       calculate_minimum_resize_size(fs));
+		       min_size);
 		exit(0);
 	}
 
@@ -388,6 +391,11 @@ int main (int argc, char ** argv)
 			new_size &= ~((sys_page_size / fs->blocksize)-1);
 	}
 
+	if (!force && new_size < min_size) {
+		com_err(program_name, 0,
+			_("New size smaller than minimum (%u)\n"), min_size);
+		exit(1);
+	}
 	if (use_stride >= 0) {
 		if (use_stride >= (int) fs->super->s_blocks_per_group) {
 			com_err(program_name, 0,


                 reply	other threads:[~2009-05-18 22:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=4A11DD10.2060404@redhat.com \
    --to=sandeen@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).