All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] resize2fs: fix minimum resize size calculation with flex_bg
@ 2009-09-04  9:15 Peng Tao
  2009-09-07 18:21 ` Theodore Tso
  0 siblings, 1 reply; 2+ messages in thread
From: Peng Tao @ 2009-09-04  9:15 UTC (permalink / raw)
  To: linux-ext4; +Cc: Theodore Tso, Eric Sandeen

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] resize2fs: fix minimum resize size calculation with flex_bg
  2009-09-04  9:15 [PATCH] resize2fs: fix minimum resize size calculation with flex_bg Peng Tao
@ 2009-09-07 18:21 ` Theodore Tso
  0 siblings, 0 replies; 2+ messages in thread
From: Theodore Tso @ 2009-09-07 18:21 UTC (permalink / raw)
  To: Peng Tao; +Cc: linux-ext4, Eric Sandeen

On Fri, Sep 04, 2009 at 05:15:40PM +0800, Peng Tao wrote:
> 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>

Applied to the maint branch, thanks.

					- Ted

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-09-07 18:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-04  9:15 [PATCH] resize2fs: fix minimum resize size calculation with flex_bg Peng Tao
2009-09-07 18:21 ` Theodore Tso

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.