ext4: fix wrong unit use in ext4_mb_find_by_goal
authorKemeng Shi <shikemeng@huaweicloud.com>
Sat, 3 Jun 2023 15:03:11 +0000 (23:03 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 15 Jun 2023 04:02:10 +0000 (00:02 -0400)
We need start in block unit while fe_start is in cluster unit. Use
ext4_grp_offs_to_block helper to convert fe_start to get start in
block unit.

Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
Reviewed-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Link: https://lore.kernel.org/r/20230603150327.3596033-4-shikemeng@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/mballoc.c

index d8caef7cd9d0bb3d8635dd4dc04399b75ed64564..f6dc4f276ca479867f41607c3c8839145b6a175d 100644 (file)
@@ -2210,8 +2210,7 @@ int ext4_mb_find_by_goal(struct ext4_allocation_context *ac,
        if (max >= ac->ac_g_ex.fe_len && ac->ac_g_ex.fe_len == sbi->s_stripe) {
                ext4_fsblk_t start;
 
-               start = ext4_group_first_block_no(ac->ac_sb, e4b->bd_group) +
-                       ex.fe_start;
+               start = ext4_grp_offs_to_block(ac->ac_sb, &ex);
                /* use do_div to get remainder (would be 64-bit modulo) */
                if (do_div(start, sbi->s_stripe) == 0) {
                        ac->ac_found++;