summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeng Tao <bergwolf@gmail.com>2009-09-04 17:15:40 +0800
committerTheodore Ts'o <tytso@mit.edu>2009-09-07 16:21:19 -0400
commit2884d208a37fe8813267198a247694bc90b00f96 (patch)
tree5eab188fdd617eab267c2c7b79f22db1f0dcf992
parent1d8af189bd3762c09175ff4d9b6cdd98fe8c8150 (diff)
downloade2fsprogs-2884d208a37fe8813267198a247694bc90b00f96.tar.gz
resize2fs: fix minimum resize size calculation with flex_bg
When flex_bg is on, calculate_minimum_resize_size() should add more meta blocks for newly added flex_bg. Addresses-RedHat-Bugzilla: #519131 Signed-off-by: Peng Tao <bergwolf@gmail.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r--resize/resize2fs.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/resize/resize2fs.c b/resize/resize2fs.c
index c0b00b67..648e1f93 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 */