From: Theodore Ts'o Date: Tue, 20 Jan 2009 05:46:06 +0000 (-0500) Subject: resize2fs: Reserve some extra space for -P/-M for ext4 filesystems X-Git-Tag: v1.41.4~19 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=793a04a0719d5688a0033e4bda3cf267f57ea760;p=tools%2Fe2fsprogs.git resize2fs: Reserve some extra space for -P/-M for ext4 filesystems Some extra blocks may be needed to expand some extent allocation trees while we are shrinking the filesystem. We don't know exactly how much, so we use a hueristic. Signed-off-by: "Theodore Ts'o" --- diff --git a/resize/resize2fs.c b/resize/resize2fs.c index df4dac7..b7c42ce 100644 --- a/resize/resize2fs.c +++ b/resize/resize2fs.c @@ -1954,5 +1954,13 @@ blk_t calculate_minimum_resize_size(ext2_filsys fs) blks_needed = (groups-1) * EXT2_BLOCKS_PER_GROUP(fs->super); blks_needed += overhead; + /* + * 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; + return blks_needed; }