]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: kill xfs_alloc_pagf_init()
authorDave Chinner <dchinner@redhat.com>
Mon, 22 Aug 2022 10:51:00 +0000 (12:51 +0200)
committerCarlos Maiolino <cem@kernel.org>
Tue, 30 Aug 2022 07:49:43 +0000 (09:49 +0200)
Source kernel commit: 76b47e528e3a27a3bf3b3f9153aad9435e03be8c

Trivial wrapper around xfs_alloc_read_agf(), can be easily replaced
by passing a NULL agfbp to xfs_alloc_read_agf().

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
libxfs/xfs_ag.c
libxfs/xfs_ag_resv.c
libxfs/xfs_alloc.c
libxfs/xfs_alloc.h
libxfs/xfs_bmap.c
libxfs/xfs_ialloc.c

index 904e82703d1039d98ba30099738e3b8fabd9ec8b..fb6d058307451444b6dfaed48146959dfbcfbc93 100644 (file)
@@ -122,7 +122,7 @@ xfs_initialize_perag_data(
                 * all the information we need and populates the
                 * per-ag structures for us.
                 */
-               error = xfs_alloc_pagf_init(mp, NULL, index, 0);
+               error = xfs_alloc_read_agf(mp, NULL, index, 0, NULL);
                if (error)
                        return error;
 
index 546f34e8b837431eb60d5991a2f2be59c8bd2243..95fe8d70d4595d0e3ddfaae3798854a14d428d5c 100644 (file)
@@ -321,7 +321,7 @@ out:
         * address.
         */
        if (has_resv) {
-               error2 = xfs_alloc_pagf_init(mp, tp, pag->pag_agno, 0);
+               error2 = xfs_alloc_read_agf(mp, tp, pag->pag_agno, 0, NULL);
                if (error2)
                        return error2;
 
index 6f292609ed663033d1f460ad993b10edef0a4fa3..5b285c2fe4c8657b52eedcf3b9cb0b792b78640c 100644 (file)
@@ -2863,25 +2863,6 @@ xfs_alloc_log_agf(
        xfs_trans_log_buf(tp, bp, (uint)first, (uint)last);
 }
 
-/*
- * Interface for inode allocation to force the pag data to be initialized.
- */
-int                                    /* error */
-xfs_alloc_pagf_init(
-       xfs_mount_t             *mp,    /* file system mount structure */
-       xfs_trans_t             *tp,    /* transaction pointer */
-       xfs_agnumber_t          agno,   /* allocation group number */
-       int                     flags)  /* XFS_ALLOC_FLAGS_... */
-{
-       struct xfs_buf          *bp;
-       int                     error;
-
-       error = xfs_alloc_read_agf(mp, tp, agno, flags, &bp);
-       if (!error)
-               xfs_trans_brelse(tp, bp);
-       return error;
-}
-
 /*
  * Put the block on the freelist for the allocation group.
  */
@@ -3091,7 +3072,9 @@ xfs_read_agf(
 }
 
 /*
- * Read in the allocation group header (free/alloc section).
+ * Read in the allocation group header (free/alloc section) and initialise the
+ * perag structure if necessary. If the caller provides @agfbpp, then return the
+ * locked buffer to the caller, otherwise free it.
  */
 int                                    /* error */
 xfs_alloc_read_agf(
@@ -3099,8 +3082,9 @@ xfs_alloc_read_agf(
        struct xfs_trans        *tp,    /* transaction pointer */
        xfs_agnumber_t          agno,   /* allocation group number */
        int                     flags,  /* XFS_ALLOC_FLAG_... */
-       struct xfs_buf          **bpp)  /* buffer for the ag freelist header */
+       struct xfs_buf          **agfbpp)
 {
+       struct xfs_buf          *agfbp;
        struct xfs_agf          *agf;           /* ag freelist header */
        struct xfs_perag        *pag;           /* per allocation group data */
        int                     error;
@@ -3114,13 +3098,12 @@ xfs_alloc_read_agf(
        ASSERT(agno != NULLAGNUMBER);
        error = xfs_read_agf(mp, tp, agno,
                        (flags & XFS_ALLOC_FLAG_TRYLOCK) ? XBF_TRYLOCK : 0,
-                       bpp);
+                       &agfbp);
        if (error)
                return error;
-       ASSERT(!(*bpp)->b_error);
 
-       agf = (*bpp)->b_addr;
-       pag = (*bpp)->b_pag;
+       agf = agfbp->b_addr;
+       pag = agfbp->b_pag;
        if (!pag->pagf_init) {
                pag->pagf_freeblks = be32_to_cpu(agf->agf_freeblks);
                pag->pagf_btreeblks = be32_to_cpu(agf->agf_btreeblks);
@@ -3161,6 +3144,10 @@ xfs_alloc_read_agf(
                       be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNTi]));
        }
 #endif
+       if (agfbpp)
+               *agfbpp = agfbp;
+       else
+               xfs_trans_brelse(tp, agfbp);
        return 0;
 }
 
index 84ca09b2223fdf46b31d30fb19b19d0fd0c9c850..96d5301a5c8becb6090f15e1cfe9fb3a4c56eb96 100644 (file)
@@ -123,16 +123,6 @@ xfs_alloc_log_agf(
        struct xfs_buf  *bp,    /* buffer for a.g. freelist header */
        uint32_t        fields);/* mask of fields to be logged (XFS_AGF_...) */
 
-/*
- * Interface for inode allocation to force the pag data to be initialized.
- */
-int                            /* error */
-xfs_alloc_pagf_init(
-       struct xfs_mount *mp,   /* file system mount structure */
-       struct xfs_trans *tp,   /* transaction pointer */
-       xfs_agnumber_t  agno,   /* allocation group number */
-       int             flags); /* XFS_ALLOC_FLAGS_... */
-
 /*
  * Put the block on the freelist for the allocation group.
  */
index 56e39e651a1652e1c718a23972d129b19159d3ce..743590cbf5367999b342675bb37b8cff6aef26fe 100644 (file)
@@ -3178,7 +3178,8 @@ xfs_bmap_longest_free_extent(
 
        pag = xfs_perag_get(mp, ag);
        if (!pag->pagf_init) {
-               error = xfs_alloc_pagf_init(mp, tp, ag, XFS_ALLOC_FLAG_TRYLOCK);
+               error = xfs_alloc_read_agf(mp, tp, ag, XFS_ALLOC_FLAG_TRYLOCK,
+                               NULL);
                if (error) {
                        /* Couldn't lock the AGF, so skip this AG. */
                        if (error == -EAGAIN) {
index 4ccc6b5977dfbecf7f769ef87b62fa975181b22a..40d2e03bf9d82fef0dbadfc7ea8550c6651d0cb6 100644 (file)
@@ -1616,7 +1616,7 @@ xfs_dialloc_good_ag(
                return false;
 
        if (!pag->pagf_init) {
-               error = xfs_alloc_pagf_init(mp, tp, pag->pag_agno, flags);
+               error = xfs_alloc_read_agf(mp, tp, pag->pag_agno, flags, NULL);
                if (error)
                        return false;
        }