lkml.org 
[lkml]   [2024]   [Apr]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 5/5] ext4: open coding repeated check in next_linear_group
On Tue 23-04-24 20:40:46, Kemeng Shi wrote:
> Open coding repeated check in next_linear_group.
>
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

Honza

> ---
> fs/ext4/mballoc.c | 31 +++++++++++++++----------------
> 1 file changed, 15 insertions(+), 16 deletions(-)
>
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index 71b2f9a18875..4afe5bb94bf4 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -1076,23 +1076,11 @@ static inline int should_optimize_scan(struct ext4_allocation_context *ac)
> }
>
> /*
> - * Return next linear group for allocation. If linear traversal should not be
> - * performed, this function just returns the same group
> + * Return next linear group for allocation.
> */
> static ext4_group_t
> -next_linear_group(struct ext4_allocation_context *ac, ext4_group_t group,
> - ext4_group_t ngroups)
> +next_linear_group(ext4_group_t group, ext4_group_t ngroups)
> {
> - if (!should_optimize_scan(ac))
> - goto inc_and_return;
> -
> - if (ac->ac_groups_linear_remaining) {
> - ac->ac_groups_linear_remaining--;
> - goto inc_and_return;
> - }
> -
> - return group;
> -inc_and_return:
> /*
> * Artificially restricted ngroups for non-extent
> * files makes group > ngroups possible on first loop.
> @@ -1118,8 +1106,19 @@ static void ext4_mb_choose_next_group(struct ext4_allocation_context *ac,
> {
> *new_cr = ac->ac_criteria;
>
> - if (!should_optimize_scan(ac) || ac->ac_groups_linear_remaining) {
> - *group = next_linear_group(ac, *group, ngroups);
> + if (!should_optimize_scan(ac)) {
> + *group = next_linear_group(*group, ngroups);
> + return;
> + }
> +
> + /*
> + * Optimized scanning can return non adjacent groups which can cause
> + * seek overhead for rotational disks. So try few linear groups before
> + * trying optimized scan.
> + */
> + if (ac->ac_groups_linear_remaining) {
> + *group = next_linear_group(*group, ngroups);
> + ac->ac_groups_linear_remaining--;
> return;
> }
>
> --
> 2.30.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR

\
 
 \ /
  Last update: 2024-04-23 23:53    [W:0.243 / U:0.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site