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" <tytso@mit.edu>
bitmap-optimize
Theodore Ts'o 2009-01-20 00:46:06 -05:00
parent 79a9ab1454
commit 793a04a071
1 changed files with 8 additions and 0 deletions

View File

@ -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;
}