]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ext4: keep "prefetch_grp" and "nr" consistent
authorKemeng Shi <shikemeng@huaweicloud.com>
Wed, 24 Apr 2024 06:19:00 +0000 (14:19 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 3 May 2024 04:12:32 +0000 (00:12 -0400)
Keep "prefetch_grp" and "nr" consistent to avoid to call
ext4_mb_prefetch_fini with non-prefetched groups.
When we step into next criteria, "prefetch_grp" is set to prefetch start
of new criteria while "nr" is number of the prefetched group in previous
criteria. If previous criteria and next criteria are both inexpensive
(< CR_GOAL_LEN_SLOW) and prefetch_ios reachs sbi->s_mb_prefetch_limit
in previous criteria, "prefetch_grp" and "nr" will be inconsistent and
may introduce unexpected cost to do ext4_mb_init_group for non-prefetched
groups.
Reset "nr" to 0 when we reset "prefetch_grp" to goal group to keep them
consistent.

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

index c65fac9b8c72f698dece7b563a34a455b487ec1d..33e6a3ebdb55fa1b9968adbfeca99c6f7ef1d860 100644 (file)
@@ -2860,6 +2860,7 @@ repeat:
                group = ac->ac_g_ex.fe_group;
                ac->ac_groups_linear_remaining = sbi->s_mb_max_linear_groups;
                prefetch_grp = group;
+               nr = 0;
 
                for (i = 0, new_cr = cr; i < ngroups; i++,
                     ext4_mb_choose_next_group(ac, &new_cr, &group, ngroups)) {