xfs: kill xfs_alloc_pagf_init()
authorDave Chinner <dchinner@redhat.com>
Thu, 7 Jul 2022 09:07:32 +0000 (19:07 +1000)
committerDave Chinner <david@fromorbit.com>
Thu, 7 Jul 2022 09:07:32 +0000 (19:07 +1000)
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>
fs/xfs/libxfs/xfs_ag.c
fs/xfs/libxfs/xfs_ag_resv.c
fs/xfs/libxfs/xfs_alloc.c
fs/xfs/libxfs/xfs_alloc.h
fs/xfs/libxfs/xfs_bmap.c
fs/xfs/libxfs/xfs_ialloc.c
fs/xfs/xfs_filestream.c

index a16c985940d35efd1f15b7ff4bbd2e378c0c3d50..2ed15839fb3e20e5e0241cda26f6694f8d0acd0d 100644 (file)
@@ -124,7 +124,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 fe94058d4e9eb8ed8109d95a96b10c17e6bbbae9..ce28bf8f72dcc74cabe102128af1b668e7baa907 100644 (file)
@@ -322,7 +322,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 d3f2886fdc0817d8384034bc88b673a1750e904d..f7853ab7b962a46d143060defe21a84a22c03a54 100644 (file)
@@ -2867,25 +2867,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.
  */
@@ -3095,7 +3076,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(
@@ -3103,8 +3086,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;
@@ -3118,13 +3102,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);
@@ -3165,6 +3148,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 6833110d1bd40567200a0b54ef288729b0dd9528..a76d5894641bcb2827aa278bf305ebd78f246562 100644 (file)
@@ -3185,7 +3185,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 a7259404377dee866cf289f1a412df5a272e3f7e..8e252207b131b3940ab5dd02e5937793de1f760a 100644 (file)
@@ -1621,7 +1621,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;
        }
index be9bcf8a1f991632348d26f7cdd5d47abd06a6df..6b09a30f8d06636dd2b2bf0bbe40bcf847ccc6e3 100644 (file)
@@ -126,7 +126,7 @@ xfs_filestream_pick_ag(
                pag = xfs_perag_get(mp, ag);
 
                if (!pag->pagf_init) {
-                       err = xfs_alloc_pagf_init(mp, NULL, ag, trylock);
+                       err = xfs_alloc_read_agf(mp, NULL, ag, trylock, NULL);
                        if (err) {
                                if (err != -EAGAIN) {
                                        xfs_perag_put(pag);
@@ -181,7 +181,7 @@ next_ag:
                if (ag != startag)
                        continue;
 
-               /* Allow sleeping in xfs_alloc_pagf_init() on the 2nd pass. */
+               /* Allow sleeping in xfs_alloc_read_agf() on the 2nd pass. */
                if (trylock != 0) {
                        trylock = 0;
                        continue;