diff mbox series

resize2fs: account for META_BG in group descriptor check

Message ID 20231029003505.656956-1-anssi.hannula@iki.fi
State New
Headers show
Series resize2fs: account for META_BG in group descriptor check | expand

Commit Message

Anssi Hannula Oct. 29, 2023, 12:34 a.m. UTC
The block group descriptor count sanity check added in 21bad2b6797f
("resize2fs: prevent block group descriptors from overflowing the first
bg") prevents enlarging the filesystem when the block group descriptors
would not fit in the first block group.

However, this does not take into account the META_BG feature in which
case not all the descriptors need to be stored in the first block group.

This prevents, for example, enlarging filesystems with 4KiB block size
past 256TiB.

Relax the check to allow resizing META_BG filesystems past the limit.

Also, always allow on-line resizing as the kernel takes care of
converting the filesystem to use META_BG when needed.

Link: https://github.com/tytso/e2fsprogs/issues/117
Fixes: 21bad2b6797f ("resize2fs: prevent block group descriptors from overflowing the first bg")
Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
---
 resize/main.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/resize/main.c b/resize/main.c
index f914c050..8c626202 100644
--- a/resize/main.c
+++ b/resize/main.c
@@ -556,11 +556,13 @@  int main (int argc, char ** argv)
 						 EXT2_BLOCKS_PER_GROUP(fs->super));
 	new_desc_blocks = ext2fs_div_ceil(new_group_desc_count,
 					  EXT2_DESC_PER_BLOCK(fs->super));
-	if ((new_desc_blocks + fs->super->s_first_data_block) >
+	if (!ext2fs_has_feature_meta_bg(fs->super) &&
+	    !(mount_flags & EXT2_MF_MOUNTED) &&
+	    (new_desc_blocks + fs->super->s_first_data_block) >
 	    EXT2_BLOCKS_PER_GROUP(fs->super)) {
 		com_err(program_name, 0,
-			_("New size results in too many block group "
-			  "descriptors.\n"));
+			_("New size requires on-line resizing for meta_bg "
+			  "conversion, please mount the filesystem first\n"));
 		goto errout;
 	}