diff mbox series

[7/9] xfs: caller perag always supplied to xfs_alloc_vextent_near_bno

Message ID 20231004001943.349265-8-david@fromorbit.com (mailing list archive)
State New, archived
Headers show
Series xfs: push perags further into allocation routines | expand

Commit Message

Dave Chinner Oct. 4, 2023, 12:19 a.m. UTC
From: Dave Chinner <dchinner@redhat.com>

So we don't need to conditionally grab the perag anymore.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 fs/xfs/libxfs/xfs_alloc.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

Comments

Christoph Hellwig Oct. 5, 2023, 12:02 p.m. UTC | #1
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Darrick J. Wong Oct. 6, 2023, 5:59 a.m. UTC | #2
On Wed, Oct 04, 2023 at 11:19:41AM +1100, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> So we don't need to conditionally grab the perag anymore.
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---
>  fs/xfs/libxfs/xfs_alloc.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
> index 289b54911b05..3190c8204903 100644
> --- a/fs/xfs/libxfs/xfs_alloc.c
> +++ b/fs/xfs/libxfs/xfs_alloc.c
> @@ -3686,7 +3686,7 @@ xfs_alloc_vextent_exact_bno(
>   * Allocate an extent as close to the target as possible. If there are not
>   * viable candidates in the AG, then fail the allocation.
>   *
> - * Caller may or may not have a per-ag reference in args->pag.
> + * Caller is expected to hold a per-ag reference in args->pag.

"Caller must hold..." ?

Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

>   */
>  int
>  xfs_alloc_vextent_near_bno(
> @@ -3695,14 +3695,12 @@ xfs_alloc_vextent_near_bno(
>  {
>  	struct xfs_mount	*mp = args->mp;
>  	xfs_agnumber_t		minimum_agno;
> -	bool			needs_perag = args->pag == NULL;
>  	uint32_t		alloc_flags = 0;
>  	int			error;
>  
> -	if (!needs_perag)
> -		ASSERT(args->pag->pag_agno == XFS_FSB_TO_AGNO(mp, target));
> +	ASSERT(args->pag->pag_agno == XFS_FSB_TO_AGNO(mp, target));
>  
> -	args->agno = XFS_FSB_TO_AGNO(mp, target);
> +	args->agno = args->pag->pag_agno;
>  	args->agbno = XFS_FSB_TO_AGBNO(mp, target);
>  
>  	trace_xfs_alloc_vextent_near_bno(args);
> @@ -3715,14 +3713,11 @@ xfs_alloc_vextent_near_bno(
>  		return error;
>  	}
>  
> -	if (needs_perag)
> -		args->pag = xfs_perag_grab(mp, args->agno);
> -
>  	error = xfs_alloc_vextent_prepare_ag(args, alloc_flags);
>  	if (!error && args->agbp)
>  		error = xfs_alloc_ag_vextent_near(args, alloc_flags);
>  
> -	return xfs_alloc_vextent_finish(args, minimum_agno, error, needs_perag);
> +	return xfs_alloc_vextent_finish(args, minimum_agno, error, false);
>  }
>  
>  /* Ensure that the freelist is at full capacity. */
> -- 
> 2.40.1
>
diff mbox series

Patch

diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index 289b54911b05..3190c8204903 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -3686,7 +3686,7 @@  xfs_alloc_vextent_exact_bno(
  * Allocate an extent as close to the target as possible. If there are not
  * viable candidates in the AG, then fail the allocation.
  *
- * Caller may or may not have a per-ag reference in args->pag.
+ * Caller is expected to hold a per-ag reference in args->pag.
  */
 int
 xfs_alloc_vextent_near_bno(
@@ -3695,14 +3695,12 @@  xfs_alloc_vextent_near_bno(
 {
 	struct xfs_mount	*mp = args->mp;
 	xfs_agnumber_t		minimum_agno;
-	bool			needs_perag = args->pag == NULL;
 	uint32_t		alloc_flags = 0;
 	int			error;
 
-	if (!needs_perag)
-		ASSERT(args->pag->pag_agno == XFS_FSB_TO_AGNO(mp, target));
+	ASSERT(args->pag->pag_agno == XFS_FSB_TO_AGNO(mp, target));
 
-	args->agno = XFS_FSB_TO_AGNO(mp, target);
+	args->agno = args->pag->pag_agno;
 	args->agbno = XFS_FSB_TO_AGBNO(mp, target);
 
 	trace_xfs_alloc_vextent_near_bno(args);
@@ -3715,14 +3713,11 @@  xfs_alloc_vextent_near_bno(
 		return error;
 	}
 
-	if (needs_perag)
-		args->pag = xfs_perag_grab(mp, args->agno);
-
 	error = xfs_alloc_vextent_prepare_ag(args, alloc_flags);
 	if (!error && args->agbp)
 		error = xfs_alloc_ag_vextent_near(args, alloc_flags);
 
-	return xfs_alloc_vextent_finish(args, minimum_agno, error, needs_perag);
+	return xfs_alloc_vextent_finish(args, minimum_agno, error, false);
 }
 
 /* Ensure that the freelist is at full capacity. */