linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peng Tao <bergwolf@gmail.com>
To: linux-ext4@vger.kernel.org
Cc: Theodore Tso <tytso@mit.edu>, Eric Sandeen <sandeen@redhat.com>
Subject: [PATCH] resize2fs: fix minimum resize size calculation with flex_bg
Date: Fri,  4 Sep 2009 17:15:40 +0800	[thread overview]
Message-ID: <1252055740-9993-1-git-send-email-bergwolf@gmail.com> (raw)

When flex_bg is on, calculate_minimum_resize_size() should add more meta
blocks for newly added flex_bg.

Addresses-Red-Hat-Bug: #519131
Signed-off-by: Peng Tao <bergwolf@gmail.com>
---
 resize/resize2fs.c |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/resize/resize2fs.c b/resize/resize2fs.c
index c0b00b6..648e1f9 100644
--- a/resize/resize2fs.c
+++ b/resize/resize2fs.c
@@ -1900,6 +1900,8 @@ blk_t calculate_minimum_resize_size(ext2_filsys fs)
 	blk_t inode_count, blks_needed, groups, data_blocks;
 	blk_t grp, data_needed, last_start;
 	int overhead = 0, num_of_superblocks = 0;
+	int extra_groups = 0;
+	int flexbg_size = 1 << fs->super->s_log_groups_per_flex;
 
 	/*
 	 * first figure out how many group descriptors we need to
@@ -1934,11 +1936,9 @@ blk_t calculate_minimum_resize_size(ext2_filsys fs)
 		 * of inode tables of slack space so the resize
 		 * operation can be guaranteed to finish.
 		 */
-		int flexbg_size = 1 << fs->super->s_log_groups_per_flex;
-		int extra_groups;
-
 		extra_groups = flexbg_size - (groups & (flexbg_size - 1));
 		data_needed += META_OVERHEAD(fs) * extra_groups;
+		extra_groups = groups % flexbg_size;
 	}
 
 	/*
@@ -2002,6 +2002,20 @@ blk_t calculate_minimum_resize_size(ext2_filsys fs)
 		}
 
 		groups += extra_grps;
+		extra_groups += extra_grps;
+		if (fs->super->s_feature_incompat
+			& EXT4_FEATURE_INCOMPAT_FLEX_BG
+		    && extra_groups > flexbg_size) {
+			/*
+			 * For ext4 we need to allow for up to a flex_bg worth
+			 * of inode tables of slack space so the resize
+			 * operation can be guaranteed to finish.
+			 */
+			extra_groups = flexbg_size -
+						(groups & (flexbg_size - 1));
+			data_needed += META_OVERHEAD(fs) * extra_groups;
+			extra_groups = groups % flexbg_size;
+		}
 	}
 
 	/* now for the fun voodoo */
-- 
1.6.4.2.446.gbd046


             reply	other threads:[~2009-09-04  9:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-04  9:15 Peng Tao [this message]
2009-09-07 18:21 ` [PATCH] resize2fs: fix minimum resize size calculation with flex_bg Theodore Tso

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=1252055740-9993-1-git-send-email-bergwolf@gmail.com \
    --to=bergwolf@gmail.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=sandeen@redhat.com \
    --cc=tytso@mit.edu \
    /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).