All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: djwong@kernel.org, david@fromorbit.com
Cc: Chandan Babu R <chandan.babu@oracle.com>,
	Christoph Hellwig <hch@lst.de>,
	Dave Chinner <dchinner@redhat.com>,
	linux-xfs@vger.kernel.org, chandan.babu@oracle.com, hch@lst.de
Subject: [PATCH 08/17] xfs: refactor btree cursor allocation function
Date: Thu, 14 Oct 2021 13:17:39 -0700	[thread overview]
Message-ID: <163424265899.756780.18387240829988701889.stgit@magnolia> (raw)
In-Reply-To: <163424261462.756780.16294781570977242370.stgit@magnolia>

From: Darrick J. Wong <djwong@kernel.org>

Refactor btree allocation to a common helper.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandan.babu@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
---
 fs/xfs/libxfs/xfs_alloc_btree.c    |    6 +-----
 fs/xfs/libxfs/xfs_bmap_btree.c     |    6 +-----
 fs/xfs/libxfs/xfs_btree.h          |   16 ++++++++++++++++
 fs/xfs/libxfs/xfs_ialloc_btree.c   |    5 +----
 fs/xfs/libxfs/xfs_refcount_btree.c |    5 +----
 fs/xfs/libxfs/xfs_rmap_btree.c     |    5 +----
 6 files changed, 21 insertions(+), 22 deletions(-)


diff --git a/fs/xfs/libxfs/xfs_alloc_btree.c b/fs/xfs/libxfs/xfs_alloc_btree.c
index 152ed2a202f4..c644b11132f6 100644
--- a/fs/xfs/libxfs/xfs_alloc_btree.c
+++ b/fs/xfs/libxfs/xfs_alloc_btree.c
@@ -477,11 +477,7 @@ xfs_allocbt_init_common(
 
 	ASSERT(btnum == XFS_BTNUM_BNO || btnum == XFS_BTNUM_CNT);
 
-	cur = kmem_cache_zalloc(xfs_btree_cur_zone, GFP_NOFS | __GFP_NOFAIL);
-
-	cur->bc_tp = tp;
-	cur->bc_mp = mp;
-	cur->bc_btnum = btnum;
+	cur = xfs_btree_alloc_cursor(mp, tp, btnum);
 	cur->bc_ag.abt.active = false;
 
 	if (btnum == XFS_BTNUM_CNT) {
diff --git a/fs/xfs/libxfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c
index a43dea8d6a65..a06987e36db5 100644
--- a/fs/xfs/libxfs/xfs_bmap_btree.c
+++ b/fs/xfs/libxfs/xfs_bmap_btree.c
@@ -552,12 +552,8 @@ xfs_bmbt_init_cursor(
 	struct xfs_btree_cur	*cur;
 	ASSERT(whichfork != XFS_COW_FORK);
 
-	cur = kmem_cache_zalloc(xfs_btree_cur_zone, GFP_NOFS | __GFP_NOFAIL);
-
-	cur->bc_tp = tp;
-	cur->bc_mp = mp;
+	cur = xfs_btree_alloc_cursor(mp, tp, XFS_BTNUM_BMAP);
 	cur->bc_nlevels = be16_to_cpu(ifp->if_broot->bb_level) + 1;
-	cur->bc_btnum = XFS_BTNUM_BMAP;
 	cur->bc_statoff = XFS_STATS_CALC_INDEX(xs_bmbt_2);
 
 	cur->bc_ops = &xfs_bmbt_ops;
diff --git a/fs/xfs/libxfs/xfs_btree.h b/fs/xfs/libxfs/xfs_btree.h
index eaffd8223ce6..8e78ede87b16 100644
--- a/fs/xfs/libxfs/xfs_btree.h
+++ b/fs/xfs/libxfs/xfs_btree.h
@@ -578,4 +578,20 @@ void xfs_btree_copy_keys(struct xfs_btree_cur *cur,
 		union xfs_btree_key *dst_key,
 		const union xfs_btree_key *src_key, int numkeys);
 
+static inline struct xfs_btree_cur *
+xfs_btree_alloc_cursor(
+	struct xfs_mount	*mp,
+	struct xfs_trans	*tp,
+	xfs_btnum_t		btnum)
+{
+	struct xfs_btree_cur	*cur;
+
+	cur = kmem_cache_zalloc(xfs_btree_cur_zone, GFP_NOFS | __GFP_NOFAIL);
+	cur->bc_tp = tp;
+	cur->bc_mp = mp;
+	cur->bc_btnum = btnum;
+
+	return cur;
+}
+
 #endif	/* __XFS_BTREE_H__ */
diff --git a/fs/xfs/libxfs/xfs_ialloc_btree.c b/fs/xfs/libxfs/xfs_ialloc_btree.c
index 10736b89b679..c8fea6a464d5 100644
--- a/fs/xfs/libxfs/xfs_ialloc_btree.c
+++ b/fs/xfs/libxfs/xfs_ialloc_btree.c
@@ -432,10 +432,7 @@ xfs_inobt_init_common(
 {
 	struct xfs_btree_cur	*cur;
 
-	cur = kmem_cache_zalloc(xfs_btree_cur_zone, GFP_NOFS | __GFP_NOFAIL);
-	cur->bc_tp = tp;
-	cur->bc_mp = mp;
-	cur->bc_btnum = btnum;
+	cur = xfs_btree_alloc_cursor(mp, tp, btnum);
 	if (btnum == XFS_BTNUM_INO) {
 		cur->bc_statoff = XFS_STATS_CALC_INDEX(xs_ibt_2);
 		cur->bc_ops = &xfs_inobt_ops;
diff --git a/fs/xfs/libxfs/xfs_refcount_btree.c b/fs/xfs/libxfs/xfs_refcount_btree.c
index 3ea589f15b14..48c45e31d897 100644
--- a/fs/xfs/libxfs/xfs_refcount_btree.c
+++ b/fs/xfs/libxfs/xfs_refcount_btree.c
@@ -322,10 +322,7 @@ xfs_refcountbt_init_common(
 
 	ASSERT(pag->pag_agno < mp->m_sb.sb_agcount);
 
-	cur = kmem_cache_zalloc(xfs_btree_cur_zone, GFP_NOFS | __GFP_NOFAIL);
-	cur->bc_tp = tp;
-	cur->bc_mp = mp;
-	cur->bc_btnum = XFS_BTNUM_REFC;
+	cur = xfs_btree_alloc_cursor(mp, tp, XFS_BTNUM_REFC);
 	cur->bc_statoff = XFS_STATS_CALC_INDEX(xs_refcbt_2);
 
 	cur->bc_flags |= XFS_BTREE_CRC_BLOCKS;
diff --git a/fs/xfs/libxfs/xfs_rmap_btree.c b/fs/xfs/libxfs/xfs_rmap_btree.c
index d65bf3c6f25e..f3c4d0965cc9 100644
--- a/fs/xfs/libxfs/xfs_rmap_btree.c
+++ b/fs/xfs/libxfs/xfs_rmap_btree.c
@@ -451,11 +451,8 @@ xfs_rmapbt_init_common(
 {
 	struct xfs_btree_cur	*cur;
 
-	cur = kmem_cache_zalloc(xfs_btree_cur_zone, GFP_NOFS | __GFP_NOFAIL);
-	cur->bc_tp = tp;
-	cur->bc_mp = mp;
 	/* Overlapping btree; 2 keys per pointer. */
-	cur->bc_btnum = XFS_BTNUM_RMAP;
+	cur = xfs_btree_alloc_cursor(mp, tp, XFS_BTNUM_RMAP);
 	cur->bc_flags = XFS_BTREE_CRC_BLOCKS | XFS_BTREE_OVERLAPPING;
 	cur->bc_statoff = XFS_STATS_CALC_INDEX(xs_rmap_2);
 	cur->bc_ops = &xfs_rmapbt_ops;


  parent reply	other threads:[~2021-10-14 20:17 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-14 20:16 [PATCHSET v4 00/17] xfs: support dynamic btree cursor height Darrick J. Wong
2021-10-14 20:17 ` [PATCH 01/17] xfs: fix incorrect decoding in xchk_btree_cur_fsbno Darrick J. Wong
2021-10-14 22:48   ` Dave Chinner
2021-10-14 23:05     ` Darrick J. Wong
2021-10-14 23:17       ` Dave Chinner
2021-10-15  0:37         ` Darrick J. Wong
2021-10-15  0:42   ` [PATCH v4.1 " Darrick J. Wong
2021-10-18 22:26     ` Dave Chinner
2021-10-14 20:17 ` [PATCH 02/17] xfs: remove xfs_btree_cur.bc_blocklog Darrick J. Wong
2021-10-14 20:17 ` [PATCH 03/17] xfs: reduce the size of nr_ops for refcount btree cursors Darrick J. Wong
2021-10-14 20:17 ` [PATCH 04/17] xfs: don't track firstrec/firstkey separately in xchk_btree Darrick J. Wong
2021-10-14 20:17 ` [PATCH 05/17] xfs: dynamically allocate btree scrub context structure Darrick J. Wong
2021-10-14 22:48   ` Dave Chinner
2021-10-14 20:17 ` [PATCH 06/17] xfs: prepare xfs_btree_cur for dynamic cursor heights Darrick J. Wong
2021-10-14 22:49   ` Dave Chinner
2021-10-14 20:17 ` [PATCH 07/17] xfs: rearrange xfs_btree_cur fields for better packing Darrick J. Wong
2021-10-14 20:17 ` Darrick J. Wong [this message]
2021-10-14 20:17 ` [PATCH 09/17] xfs: encode the max btree height in the cursor Darrick J. Wong
2021-10-14 20:17 ` [PATCH 10/17] xfs: dynamically allocate cursors based on maxlevels Darrick J. Wong
2021-10-14 20:17 ` [PATCH 11/17] xfs: rename m_ag_maxlevels to m_allocbt_maxlevels Darrick J. Wong
2021-10-14 22:52   ` Dave Chinner
2021-10-15  0:44     ` Darrick J. Wong
2021-10-14 20:18 ` [PATCH 12/17] xfs: compute maximum AG btree height for critical reservation calculation Darrick J. Wong
2021-10-14 22:54   ` Dave Chinner
2021-10-15  0:44     ` Darrick J. Wong
2021-10-14 20:18 ` [PATCH 13/17] xfs: clean up xfs_btree_{calc_size,compute_maxlevels} Darrick J. Wong
2021-10-14 22:58   ` Dave Chinner
2021-10-14 20:18 ` [PATCH 14/17] xfs: compute the maximum height of the rmap btree when reflink enabled Darrick J. Wong
2021-10-14 23:03   ` Dave Chinner
2021-10-15  0:48     ` Darrick J. Wong
2021-10-14 20:18 ` [PATCH 15/17] xfs: kill XFS_BTREE_MAXLEVELS Darrick J. Wong
2021-10-14 20:18 ` [PATCH 16/17] xfs: compute absolute maximum nlevels for each btree type Darrick J. Wong
2021-10-14 23:08   ` Dave Chinner
2021-10-14 20:18 ` [PATCH 17/17] xfs: use separate btree cursor cache " Darrick J. Wong
2021-10-14 23:11   ` Dave Chinner

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=163424265899.756780.18387240829988701889.stgit@magnolia \
    --to=djwong@kernel.org \
    --cc=chandan.babu@oracle.com \
    --cc=david@fromorbit.com \
    --cc=dchinner@redhat.com \
    --cc=hch@lst.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.