This patch avoids an attempt to resize the filesystem to an unaligned cluster boundary. An online resize to a size that is not integral to cluster size results in the last iteration attempting to grow the fs by a negative amount, which trips a BUG_ON and leaves the fs with a corrupted in-memory superblock. Signed-off-by: Oleg Kiselev <okiselev@xxxxxxxxxx> --- fs/ext4/resize.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c index 2acc9fca99ea..8803905907de 100644 --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c @@ -1624,7 +1624,8 @@ static int ext4_setup_next_flex_gd(struct super_block *sb, o_blocks_count = ext4_blocks_count(es); - if (o_blocks_count == n_blocks_count) + if ((o_blocks_count == n_blocks_count) || + ((n_blocks_count - o_blocks_count) < sbi->s_cluster_ratio)) return 0; ext4_get_group_no_and_offset(sb, o_blocks_count, &group, &last); -- 2.32.0