Whamcloud - gitweb
resize2fs: Reserve some extra space for -P/-M for ext4 filesystems
authorTheodore Ts'o <tytso@mit.edu>
Tue, 20 Jan 2009 05:46:06 +0000 (00:46 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 20 Jan 2009 05:46:06 +0000 (00:46 -0500)
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>
resize/resize2fs.c

index df4dac7..b7c42ce 100644 (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;
 }