Skip to content

Commit 10b01ee

Browse files
committed
ext4: fix overhead calculation to account for the reserved gdt blocks
The kernel calculation was underestimating the overhead by not taking into account the reserved gdt blocks. With this change, the overhead calculated by the kernel matches the overhead calculation in mke2fs. Signed-off-by: Theodore Ts'o <[email protected]> Cc: [email protected]
1 parent 7102ffe commit 10b01ee

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/ext4/super.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4177,9 +4177,11 @@ static int count_overhead(struct super_block *sb, ext4_group_t grp,
41774177
ext4_fsblk_t first_block, last_block, b;
41784178
ext4_group_t i, ngroups = ext4_get_groups_count(sb);
41794179
int s, j, count = 0;
4180+
int has_super = ext4_bg_has_super(sb, grp);
41804181

41814182
if (!ext4_has_feature_bigalloc(sb))
4182-
return (ext4_bg_has_super(sb, grp) + ext4_bg_num_gdb(sb, grp) +
4183+
return (has_super + ext4_bg_num_gdb(sb, grp) +
4184+
(has_super ? le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks) : 0) +
41834185
sbi->s_itb_per_group + 2);
41844186

41854187
first_block = le32_to_cpu(sbi->s_es->s_first_data_block) +

0 commit comments

Comments
 (0)