aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKiselev, Oleg <okiselev@amazon.com>2022-05-14 04:17:09 +0000
committerTheodore Ts'o <tytso@mit.edu>2022-08-11 10:06:10 -0400
commitb609d01e6d200638aad42adee922f91d91e3e642 (patch)
tree40cb6d865ffb79ca3928b230f4ad4e3f3d5742c0
parentaa5732531f76e405a17415a4217f86cf8270d589 (diff)
downloade2fsprogs-b609d01e6d200638aad42adee922f91d91e3e642.tar.gz
resize2fs: trim resize to cluster boundary
This patch rounds down the size provided to resize2fs to the nearest cluster boundary for bigalloc filesystems. This is similar to the trimming already done for page boundary alignment. Aligning the size in the user space provides the right value feedback from the resize2fs command, which is a better user experience than trimming the size in the kernel. Signed-off-by: Oleg Kiselev <okiselev@amazon.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r--resize/main.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/resize/main.c b/resize/main.c
index c1338fbe1..d2ba34481 100644
--- a/resize/main.c
+++ b/resize/main.c
@@ -537,6 +537,12 @@ int main (int argc, char ** argv)
goto errout;
}
}
+
+ /* If using cluster allocations, trim down to a cluster boundary */
+ if (ext2fs_has_feature_bigalloc(fs->super)) {
+ new_size &= ~((blk64_t)(1 << fs->cluster_ratio_bits) - 1);
+ }
+
new_group_desc_count = ext2fs_div64_ceil(new_size -
fs->super->s_first_data_block,
EXT2_BLOCKS_PER_GROUP(fs->super));