[02/21] ext4: allow to find by goal if EXT4_MB_HINT_GOAL_ONLY is set

Message ID 20230209194825.511043-3-shikemeng@huaweicloud.com
State New
Headers
Series Some bugfix and cleanup to mballoc |

Commit Message

Kemeng Shi Feb. 9, 2023, 7:48 p.m. UTC
  If EXT4_MB_HINT_GOAL_ONLY is set, ext4_mb_regular_allocator will only
allocate blocks from ext4_mb_find_by_goal. Allow to find by goal in
ext4_mb_find_by_goal if EXT4_MB_HINT_GOAL_ONLY is set or allocation
with EXT4_MB_HINT_GOAL_ONLY set will always fail.

EXT4_MB_HINT_GOAL_ONLY is not used at all, so the problem is not
found for now.

Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
---
 fs/ext4/mballoc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Ojaswin Mujoo Feb. 13, 2023, 6:57 a.m. UTC | #1
On Fri, Feb 10, 2023 at 03:48:06AM +0800, Kemeng Shi wrote:
> If EXT4_MB_HINT_GOAL_ONLY is set, ext4_mb_regular_allocator will only
> allocate blocks from ext4_mb_find_by_goal. Allow to find by goal in
> ext4_mb_find_by_goal if EXT4_MB_HINT_GOAL_ONLY is set or allocation
> with EXT4_MB_HINT_GOAL_ONLY set will always fail.
> 
> EXT4_MB_HINT_GOAL_ONLY is not used at all, so the problem is not
> found for now.
> 
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
> ---
>  fs/ext4/mballoc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index 0650a1dc870e..375d9655b525 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -2162,7 +2162,7 @@ int ext4_mb_find_by_goal(struct ext4_allocation_context *ac,
>  	struct ext4_group_info *grp = ext4_get_group_info(ac->ac_sb, group);
>  	struct ext4_free_extent ex;
>  
> -	if (!(ac->ac_flags & EXT4_MB_HINT_TRY_GOAL))
> +	if (!(ac->ac_flags & (EXT4_MB_HINT_TRY_GOAL | EXT4_MB_HINT_GOAL_ONLY)))
>  		return 0;
>  	if (grp->bb_free == 0)
>  		return 0;
Looks good to me, feel free to add:

Reviewed-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
  

Patch

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 0650a1dc870e..375d9655b525 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2162,7 +2162,7 @@  int ext4_mb_find_by_goal(struct ext4_allocation_context *ac,
 	struct ext4_group_info *grp = ext4_get_group_info(ac->ac_sb, group);
 	struct ext4_free_extent ex;
 
-	if (!(ac->ac_flags & EXT4_MB_HINT_TRY_GOAL))
+	if (!(ac->ac_flags & (EXT4_MB_HINT_TRY_GOAL | EXT4_MB_HINT_GOAL_ONLY)))
 		return 0;
 	if (grp->bb_free == 0)
 		return 0;