Skip to content

Commit

Permalink
resize2fs: check number of group descriptors only if meta_bg is disabled
Browse files Browse the repository at this point in the history
When meta_bg feature is enabled, the total number of group descriptors
is not really limiting the filesystem size. So there's no reason to
check it in that case. This allows resize2fs to resize filesystems past
256TB boundary similarly as the kernel can do it.

Signed-off-by: Jan Kara <[email protected]>
Reviewed-by: Ojaswin Mujoo <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Theodore Ts'o <[email protected]>
  • Loading branch information
jankara authored and tytso committed Oct 25, 2024
1 parent 2c1e554 commit ad56cca
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions resize/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,6 @@ int main (int argc, char ** argv)
long sysval;
int len, mount_flags;
char *mtpt, *undo_file = NULL;
dgrp_t new_group_desc_count;
unsigned long new_desc_blocks;

#ifdef ENABLE_NLS
setlocale(LC_MESSAGES, "");
Expand Down Expand Up @@ -551,17 +549,22 @@ int main (int argc, char ** argv)
new_size &= ~((blk64_t)(1ULL << 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));
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) >
EXT2_BLOCKS_PER_GROUP(fs->super)) {
com_err(program_name, 0,
_("New size results in too many block group "
"descriptors.\n"));
goto errout;
if (!ext2fs_has_feature_meta_bg(fs->super)) {
dgrp_t new_group_desc_count;
unsigned long new_desc_blocks;

new_group_desc_count = ext2fs_div64_ceil(new_size -
fs->super->s_first_data_block,
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) >
EXT2_BLOCKS_PER_GROUP(fs->super)) {
com_err(program_name, 0,
_("New size results in too many block group "
"descriptors.\n"));
goto errout;
}
}

if (!force && new_size < min_size) {
Expand Down

0 comments on commit ad56cca

Please sign in to comment.