public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] ext4: avoid resizing to a partial cluster size
@ 2022-06-30  2:17 Kiselev, Oleg
  2022-07-14 13:52 ` Jan Kara
  0 siblings, 1 reply; 5+ messages in thread
From: Kiselev, Oleg @ 2022-06-30  2:17 UTC (permalink / raw)
  To: linux-ext4@vger.kernel.org; +Cc: Theodore Ts'o

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@amazon.com>
---
 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-07-15 11:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-30  2:17 [PATCH 2/2] ext4: avoid resizing to a partial cluster size Kiselev, Oleg
2022-07-14 13:52 ` Jan Kara
2022-07-15  1:00   ` Kiselev, Oleg
2022-07-15  9:35     ` Jan Kara
2022-07-15 11:48       ` Theodore Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox