From: Dave Chinner <david@fromorbit.com>
To: linux-xfs@vger.kernel.org
Subject: [PATCH 04/14] xfs: kill xfs_alloc_pagf_init()
Date: Mon, 27 Jun 2022 10:18:22 +1000 [thread overview]
Message-ID: <20220627001832.215779-5-david@fromorbit.com> (raw)
In-Reply-To: <20220627001832.215779-1-david@fromorbit.com>
From: Dave Chinner <dchinner@redhat.com>
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>
---
fs/xfs/libxfs/xfs_ag.c | 2 +-
fs/xfs/libxfs/xfs_ag_resv.c | 2 +-
fs/xfs/libxfs/xfs_alloc.c | 37 ++++++++++++-------------------------
fs/xfs/libxfs/xfs_alloc.h | 10 ----------
fs/xfs/libxfs/xfs_bmap.c | 3 ++-
fs/xfs/libxfs/xfs_ialloc.c | 2 +-
fs/xfs/xfs_filestream.c | 4 ++--
7 files changed, 19 insertions(+), 41 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_ag.c b/fs/xfs/libxfs/xfs_ag.c
index a16c985940d3..2ed15839fb3e 100644
--- a/fs/xfs/libxfs/xfs_ag.c
+++ b/fs/xfs/libxfs/xfs_ag.c
@@ -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;
diff --git a/fs/xfs/libxfs/xfs_ag_resv.c b/fs/xfs/libxfs/xfs_ag_resv.c
index fe94058d4e9e..ce28bf8f72dc 100644
--- a/fs/xfs/libxfs/xfs_ag_resv.c
+++ b/fs/xfs/libxfs/xfs_ag_resv.c
@@ -322,7 +322,7 @@ xfs_ag_resv_init(
* 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;
diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index d3f2886fdc08..f7853ab7b962 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -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;
}
diff --git a/fs/xfs/libxfs/xfs_alloc.h b/fs/xfs/libxfs/xfs_alloc.h
index 84ca09b2223f..96d5301a5c8b 100644
--- a/fs/xfs/libxfs/xfs_alloc.h
+++ b/fs/xfs/libxfs/xfs_alloc.h
@@ -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.
*/
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 6833110d1bd4..a76d5894641b 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -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) {
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index a7259404377d..8e252207b131 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -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;
}
diff --git a/fs/xfs/xfs_filestream.c b/fs/xfs/xfs_filestream.c
index be9bcf8a1f99..6b09a30f8d06 100644
--- a/fs/xfs/xfs_filestream.c
+++ b/fs/xfs/xfs_filestream.c
@@ -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 @@ xfs_filestream_pick_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;
--
2.36.1
next prev parent reply other threads:[~2022-06-27 0:18 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-27 0:18 [PATCH 00/14] xfs: perag conversions for 5.20 Dave Chinner
2022-06-27 0:18 ` [PATCH 01/14] xfs: make last AG grow/shrink perag centric Dave Chinner
2022-06-27 0:18 ` [PATCH 02/14] xfs: kill xfs_ialloc_pagi_init() Dave Chinner
2022-06-27 0:18 ` [PATCH 03/14] xfs: pass perag to xfs_ialloc_read_agi() Dave Chinner
2022-06-27 0:18 ` Dave Chinner [this message]
2022-06-27 0:18 ` [PATCH 05/14] xfs: pass perag to xfs_alloc_read_agf() Dave Chinner
2022-06-29 6:58 ` Christoph Hellwig
2022-06-27 0:18 ` [PATCH 06/14] xfs: pass perag to xfs_read_agi Dave Chinner
2022-06-27 0:18 ` [PATCH 07/14] xfs: pass perag to xfs_read_agf Dave Chinner
2022-06-27 0:18 ` [PATCH 08/14] xfs: pass perag to xfs_alloc_get_freelist Dave Chinner
2022-06-27 0:18 ` [PATCH 09/14] xfs: pass perag to xfs_alloc_put_freelist Dave Chinner
2022-06-27 0:18 ` [PATCH 10/14] xfs: pass perag to xfs_alloc_read_agfl Dave Chinner
2022-06-27 0:18 ` [PATCH 11/14] xfs: Pre-calculate per-AG agbno geometry Dave Chinner
2022-06-29 7:00 ` Christoph Hellwig
2022-06-27 0:18 ` [PATCH 12/14] xfs: Pre-calculate per-AG agino geometry Dave Chinner
2022-06-29 7:02 ` Christoph Hellwig
2022-06-27 0:18 ` [PATCH 13/14] xfs: replace xfs_ag_block_count() with perag accesses Dave Chinner
2022-06-29 7:02 ` Christoph Hellwig
2022-06-27 0:18 ` [PATCH 14/14] xfs: make is_log_ag() a first class helper Dave Chinner
2022-06-29 7:03 ` Christoph Hellwig
2022-06-29 20:26 ` [PATCH 00/14] xfs: perag conversions for 5.20 Darrick J. Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220627001832.215779-5-david@fromorbit.com \
--to=david@fromorbit.com \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox