[v4,07/11] xfs: refactor allocation tree fixup code
diff mbox series

Message ID 20190916121635.43148-8-bfoster@redhat.com
State New
Headers show
Series
  • xfs: rework near mode extent allocation
Related show

Commit Message

Brian Foster Sept. 16, 2019, 12:16 p.m. UTC
Both algorithms duplicate the same btree allocation code. Eliminate
the duplication and reuse the fallback algorithm codepath.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/libxfs/xfs_alloc.c | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)

Comments

Darrick J. Wong Sept. 18, 2019, 8:44 p.m. UTC | #1
On Mon, Sep 16, 2019 at 08:16:31AM -0400, Brian Foster wrote:
> Both algorithms duplicate the same btree allocation code. Eliminate
> the duplication and reuse the fallback algorithm codepath.
> 
> Signed-off-by: Brian Foster <bfoster@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_alloc.c | 18 ++----------------
>  1 file changed, 2 insertions(+), 16 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
> index edcec975c306..3eacc799c4cb 100644
> --- a/fs/xfs/libxfs/xfs_alloc.c
> +++ b/fs/xfs/libxfs/xfs_alloc.c
> @@ -1333,23 +1333,8 @@ xfs_alloc_ag_vextent_near(
>  		if (acur.len == 0)
>  			break;
>  
> -		/*
> -		 * Allocate at the bno/len tracked in the cursor.
> -		 */
> -		args->agbno = acur.bno;
> -		args->len = acur.len;
> -		ASSERT(acur.bno >= acur.rec_bno);
> -		ASSERT(acur.bno + acur.len <= acur.rec_bno + acur.rec_len);
> -		ASSERT(acur.rec_bno + acur.rec_len <=
> -		       be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length));
> -
> -		error = xfs_alloc_fixup_trees(acur.cnt, acur.bnolt,
> -				acur.rec_bno, acur.rec_len, acur.bno, acur.len,
> -				0);
> -		if (error)
> -			goto out;
>  		trace_xfs_alloc_near_first(args);
> -		goto out;
> +		goto alloc;
>  	}
>  
>  	/*
> @@ -1434,6 +1419,7 @@ xfs_alloc_ag_vextent_near(
>  		goto out;
>  	}
>  
> +alloc:
>  	args->agbno = acur.bno;
>  	args->len = acur.len;
>  	ASSERT(acur.bno >= acur.rec_bno);
> -- 
> 2.20.1
>

Patch
diff mbox series

diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index edcec975c306..3eacc799c4cb 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -1333,23 +1333,8 @@  xfs_alloc_ag_vextent_near(
 		if (acur.len == 0)
 			break;
 
-		/*
-		 * Allocate at the bno/len tracked in the cursor.
-		 */
-		args->agbno = acur.bno;
-		args->len = acur.len;
-		ASSERT(acur.bno >= acur.rec_bno);
-		ASSERT(acur.bno + acur.len <= acur.rec_bno + acur.rec_len);
-		ASSERT(acur.rec_bno + acur.rec_len <=
-		       be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length));
-
-		error = xfs_alloc_fixup_trees(acur.cnt, acur.bnolt,
-				acur.rec_bno, acur.rec_len, acur.bno, acur.len,
-				0);
-		if (error)
-			goto out;
 		trace_xfs_alloc_near_first(args);
-		goto out;
+		goto alloc;
 	}
 
 	/*
@@ -1434,6 +1419,7 @@  xfs_alloc_ag_vextent_near(
 		goto out;
 	}
 
+alloc:
 	args->agbno = acur.bno;
 	args->len = acur.len;
 	ASSERT(acur.bno >= acur.rec_bno);