aboutsummaryrefslogtreecommitdiffstats
path: root/resize
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@redhat.com>2009-05-18 17:02:32 -0500
committerTheodore Ts'o <tytso@mit.edu>2009-05-25 22:40:35 -0400
commit69f7c80eaf25a642b0eb85f4557605c89acd80b6 (patch)
treef24a1437155dcb7ea06bd39d63321d997c52d91c /resize
parent53422e8a5644e22ea3f6e0efba82a765b72e4308 (diff)
downloade2fsprogs-69f7c80eaf25a642b0eb85f4557605c89acd80b6.tar.gz
resize2fs: fix minimum size calculations
The extra padding added to the minimum size calculations: /* * We need to reserve a few extra blocks if extents are * enabled, in case we need to grow the extent tree. The more * we shrink the file system, the more space we need. */ if (fs->super->s_feature_incompat & EXT3_FEATURE_INCOMPAT_EXTENTS) blks_needed += (fs->super->s_blocks_count - blks_needed)/500; can go quite wrong if we've already added up more "blks_needed" than our current size, and the above subtraction wraps. This can easily happen for a filesystem which is almost completely full. In this case, just return the current fs size as the minimum and be done with it. With this fix we could probably call calculate_minimum_resize_size() for each resize2fs invocation and refuse to resize smaller than that? Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'resize')
-rw-r--r--resize/resize2fs.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/resize/resize2fs.c b/resize/resize2fs.c
index f3e7fd0e0..0d5dc81a4 100644
--- a/resize/resize2fs.c
+++ b/resize/resize2fs.c
@@ -2003,6 +2003,12 @@ blk_t calculate_minimum_resize_size(ext2_filsys fs)
blks_needed += overhead;
/*
+ * If at this point we've already added up more "needed" than
+ * the current size, just return current size as minimum.
+ */
+ if (blks_needed >= fs->super->s_blocks_count)
+ return fs->super->s_blocks_count;
+ /*
* We need to reserve a few extra blocks if extents are
* enabled, in case we need to grow the extent tree. The more
* we shrink the file system, the more space we need.