]> Git Repo - linux.git/commitdiff
ext4: fix overhead calculation to account for the reserved gdt blocks
authorTheodore Ts'o <[email protected]>
Fri, 15 Apr 2022 01:31:27 +0000 (21:31 -0400)
committerTheodore Ts'o <[email protected]>
Fri, 15 Apr 2022 01:31:27 +0000 (21:31 -0400)
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]
fs/ext4/super.c

index f2a5e78f93a9809caea5a047782cd5d8518962dd..23a9b2c086ed3fa9bf97d6914458a773e63946bc 100644 (file)
@@ -4177,9 +4177,11 @@ static int count_overhead(struct super_block *sb, ext4_group_t grp,
        ext4_fsblk_t            first_block, last_block, b;
        ext4_group_t            i, ngroups = ext4_get_groups_count(sb);
        int                     s, j, count = 0;
+       int                     has_super = ext4_bg_has_super(sb, grp);
 
        if (!ext4_has_feature_bigalloc(sb))
-               return (ext4_bg_has_super(sb, grp) + ext4_bg_num_gdb(sb, grp) +
+               return (has_super + ext4_bg_num_gdb(sb, grp) +
+                       (has_super ? le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks) : 0) +
                        sbi->s_itb_per_group + 2);
 
        first_block = le32_to_cpu(sbi->s_es->s_first_data_block) +
This page took 0.064415 seconds and 4 git commands to generate.