Skip to content

Commit 772c9f6

Browse files
riteshharjanitytso
authored andcommitted
ext4: don't use CR_BEST_AVAIL_LEN for non-regular files
Using CR_BEST_AVAIL_LEN only make sense for regular files, as for non-regular files we never normalize the allocation request length i.e. goal len is same as original length (ac_g_ex.fe_len == ac_o_ex.fe_len). Hence there is no scope of trimming the goal length to make it satisfy original request len. Thus this patch avoids using CR_BEST_AVAIL_LEN criteria for non-regular files request. Cc: [email protected] Fixes: 33122aa ("ext4: Add allocation criteria 1.5 (CR1_5)") Reported-by: Eric Whitney <[email protected]> Signed-off-by: Ritesh Harjani (IBM) <[email protected]> Tested-by: Eric Whitney <[email protected]> Link: https://lore.kernel.org/r/2a694c748ff8b8c4b416995a24f06f07b55047a8.1689516047.git.ritesh.list@gmail.com Signed-off-by: Theodore Ts'o <[email protected]>
1 parent e15e117 commit 772c9f6

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

fs/ext4/mballoc.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,18 @@ static void ext4_mb_choose_next_group_goal_fast(struct ext4_allocation_context *
966966
}
967967
}
968968

969-
*new_cr = CR_BEST_AVAIL_LEN;
969+
/*
970+
* CR_BEST_AVAIL_LEN works based on the concept that we have
971+
* a larger normalized goal len request which can be trimmed to
972+
* a smaller goal len such that it can still satisfy original
973+
* request len. However, allocation request for non-regular
974+
* files never gets normalized.
975+
* See function ext4_mb_normalize_request() (EXT4_MB_HINT_DATA).
976+
*/
977+
if (ac->ac_flags & EXT4_MB_HINT_DATA)
978+
*new_cr = CR_BEST_AVAIL_LEN;
979+
else
980+
*new_cr = CR_GOAL_LEN_SLOW;
970981
}
971982

972983
/*

0 commit comments

Comments
 (0)