Skip to content

Commit 9c97c34

Browse files
Kemeng Shitytso
authored andcommitted
ext4: keep "prefetch_grp" and "nr" consistent
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 <[email protected]> Reviewed-by: Ojaswin Mujoo <[email protected]> Reviewed-by: Jan Kara <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent a11adf7 commit 9c97c34

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

fs/ext4/mballoc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2860,6 +2860,7 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac)
28602860
group = ac->ac_g_ex.fe_group;
28612861
ac->ac_groups_linear_remaining = sbi->s_mb_max_linear_groups;
28622862
prefetch_grp = group;
2863+
nr = 0;
28632864

28642865
for (i = 0, new_cr = cr; i < ngroups; i++,
28652866
ext4_mb_choose_next_group(ac, &new_cr, &group, ngroups)) {

0 commit comments

Comments
 (0)