[PATCH 08/10] ext4: return found group directly in ext4_mb_choose_next_group_goal_fast

Kemeng Shi posted 10 patches 2 years, 6 months ago
There is a newer version of this series
[PATCH 08/10] ext4: return found group directly in ext4_mb_choose_next_group_goal_fast
Posted by Kemeng Shi 2 years, 6 months ago
Return good group when it's found in loop to remove futher check if good
group is found after loop.

Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
---
 fs/ext4/mballoc.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 412d335583fe..6f8e804905d5 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -960,16 +960,14 @@ static void ext4_mb_choose_next_group_goal_fast(struct ext4_allocation_context *
 	for (i = mb_avg_fragment_size_order(ac->ac_sb, ac->ac_g_ex.fe_len);
 	     i < MB_NUM_ORDERS(ac->ac_sb); i++) {
 		grp = ext4_mb_find_good_group_avg_frag_lists(ac, i);
-		if (grp)
-			break;
+		if (grp) {
+			*group = grp->bb_group;
+			ac->ac_flags |= EXT4_MB_CR_GOAL_LEN_FAST_OPTIMIZED;
+			return;
+		}
 	}
 
-	if (grp) {
-		*group = grp->bb_group;
-		ac->ac_flags |= EXT4_MB_CR_GOAL_LEN_FAST_OPTIMIZED;
-	} else {
-		*new_cr = CR_BEST_AVAIL_LEN;
-	}
+	*new_cr = CR_BEST_AVAIL_LEN;
 }
 
 /*
-- 
2.30.0
Re: [PATCH 08/10] ext4: return found group directly in ext4_mb_choose_next_group_goal_fast
Posted by Ritesh Harjani (IBM) 2 years, 6 months ago
Kemeng Shi <shikemeng@huaweicloud.com> writes:

> Return good group when it's found in loop to remove futher check if good
> group is found after loop.
>
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
> ---
>  fs/ext4/mballoc.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)


Looks good to me, feel free to add: 
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>

-ritesh

>
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index 412d335583fe..6f8e804905d5 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -960,16 +960,14 @@ static void ext4_mb_choose_next_group_goal_fast(struct ext4_allocation_context *
>  	for (i = mb_avg_fragment_size_order(ac->ac_sb, ac->ac_g_ex.fe_len);
>  	     i < MB_NUM_ORDERS(ac->ac_sb); i++) {
>  		grp = ext4_mb_find_good_group_avg_frag_lists(ac, i);
> -		if (grp)
> -			break;
> +		if (grp) {
> +			*group = grp->bb_group;
> +			ac->ac_flags |= EXT4_MB_CR_GOAL_LEN_FAST_OPTIMIZED;
> +			return;
> +		}
>  	}
>  
> -	if (grp) {
> -		*group = grp->bb_group;
> -		ac->ac_flags |= EXT4_MB_CR_GOAL_LEN_FAST_OPTIMIZED;
> -	} else {
> -		*new_cr = CR_BEST_AVAIL_LEN;
> -	}
> +	*new_cr = CR_BEST_AVAIL_LEN;
>  }
>  
>  /*
> -- 
> 2.30.0