diff mbox series

[20/22] xfs: inode allocation can use a single perag instance

Message ID 20210506072054.271157-21-david@fromorbit.com (mailing list archive)
State Superseded
Headers show
Series xfs: initial agnumber -> perag conversions for shrink | expand

Commit Message

Dave Chinner May 6, 2021, 7:20 a.m. UTC
From: Dave Chinner <dchinner@redhat.com>

Now that we've internalised the two-phase inode allocation, we can
now easily make the AG selection and allocation atomic from the
perspective of a single perag context. This will ensure AGs going
offline/away cannot occur between the selection and allocation
steps.

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

Comments

Brian Foster May 12, 2021, 12:52 p.m. UTC | #1
On Thu, May 06, 2021 at 05:20:52PM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> Now that we've internalised the two-phase inode allocation, we can
> now easily make the AG selection and allocation atomic from the
> perspective of a single perag context. This will ensure AGs going
> offline/away cannot occur between the selection and allocation
> steps.
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/libxfs/xfs_ialloc.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
> index 2c0ef2dd46d9..d749bb7c7a69 100644
> --- a/fs/xfs/libxfs/xfs_ialloc.c
> +++ b/fs/xfs/libxfs/xfs_ialloc.c
> @@ -1432,6 +1432,7 @@ int
>  xfs_dialloc_ag(
>  	struct xfs_trans	*tp,
>  	struct xfs_buf		*agbp,
> +	struct xfs_perag	*pag,
>  	xfs_ino_t		parent,
>  	xfs_ino_t		*inop)
>  {
> @@ -1446,7 +1447,6 @@ xfs_dialloc_ag(
>  	int				error;
>  	int				offset;
>  	int				i;
> -	struct xfs_perag		*pag = agbp->b_pag;
>  
>  	if (!xfs_sb_version_hasfinobt(&mp->m_sb))
>  		return xfs_dialloc_ag_inobt(tp, agbp, pag, parent, inop);
> @@ -1761,9 +1761,9 @@ xfs_dialloc(
>  	xfs_perag_put(pag);
>  	return error ? error : -ENOSPC;
>  found_ag:
> -	xfs_perag_put(pag);
>  	/* Allocate an inode in the found AG */
> -	error = xfs_dialloc_ag(*tpp, agbp, parent, &ino);
> +	error = xfs_dialloc_ag(*tpp, agbp, pag, parent, &ino);
> +	xfs_perag_put(pag);
>  	if (error)
>  		return error;
>  	*new_ino = ino;
> -- 
> 2.31.1
>
Darrick J. Wong May 12, 2021, 11:19 p.m. UTC | #2
On Thu, May 06, 2021 at 05:20:52PM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> Now that we've internalised the two-phase inode allocation, we can
> now easily make the AG selection and allocation atomic from the
> perspective of a single perag context. This will ensure AGs going
> offline/away cannot occur between the selection and allocation
> steps.
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>

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

--D

> ---
>  fs/xfs/libxfs/xfs_ialloc.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
> index 2c0ef2dd46d9..d749bb7c7a69 100644
> --- a/fs/xfs/libxfs/xfs_ialloc.c
> +++ b/fs/xfs/libxfs/xfs_ialloc.c
> @@ -1432,6 +1432,7 @@ int
>  xfs_dialloc_ag(
>  	struct xfs_trans	*tp,
>  	struct xfs_buf		*agbp,
> +	struct xfs_perag	*pag,
>  	xfs_ino_t		parent,
>  	xfs_ino_t		*inop)
>  {
> @@ -1446,7 +1447,6 @@ xfs_dialloc_ag(
>  	int				error;
>  	int				offset;
>  	int				i;
> -	struct xfs_perag		*pag = agbp->b_pag;
>  
>  	if (!xfs_sb_version_hasfinobt(&mp->m_sb))
>  		return xfs_dialloc_ag_inobt(tp, agbp, pag, parent, inop);
> @@ -1761,9 +1761,9 @@ xfs_dialloc(
>  	xfs_perag_put(pag);
>  	return error ? error : -ENOSPC;
>  found_ag:
> -	xfs_perag_put(pag);
>  	/* Allocate an inode in the found AG */
> -	error = xfs_dialloc_ag(*tpp, agbp, parent, &ino);
> +	error = xfs_dialloc_ag(*tpp, agbp, pag, parent, &ino);
> +	xfs_perag_put(pag);
>  	if (error)
>  		return error;
>  	*new_ino = ino;
> -- 
> 2.31.1
>
diff mbox series

Patch

diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index 2c0ef2dd46d9..d749bb7c7a69 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -1432,6 +1432,7 @@  int
 xfs_dialloc_ag(
 	struct xfs_trans	*tp,
 	struct xfs_buf		*agbp,
+	struct xfs_perag	*pag,
 	xfs_ino_t		parent,
 	xfs_ino_t		*inop)
 {
@@ -1446,7 +1447,6 @@  xfs_dialloc_ag(
 	int				error;
 	int				offset;
 	int				i;
-	struct xfs_perag		*pag = agbp->b_pag;
 
 	if (!xfs_sb_version_hasfinobt(&mp->m_sb))
 		return xfs_dialloc_ag_inobt(tp, agbp, pag, parent, inop);
@@ -1761,9 +1761,9 @@  xfs_dialloc(
 	xfs_perag_put(pag);
 	return error ? error : -ENOSPC;
 found_ag:
-	xfs_perag_put(pag);
 	/* Allocate an inode in the found AG */
-	error = xfs_dialloc_ag(*tpp, agbp, parent, &ino);
+	error = xfs_dialloc_ag(*tpp, agbp, pag, parent, &ino);
+	xfs_perag_put(pag);
 	if (error)
 		return error;
 	*new_ino = ino;