summaryrefslogtreecommitdiff
path: root/fs/xfs/libxfs/xfs_btree.h
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2021-09-16 22:27:24 +0300
committerDarrick J. Wong <djwong@kernel.org>2021-10-19 21:45:15 +0300
commitc940a0c54a2e9333478f1d87ed40006a04fcec7e (patch)
treef02e9ba660f9fe2b33b0a6b7080e437c5a2c6b87 /fs/xfs/libxfs/xfs_btree.h
parentc0643f6fdd6d3c448142ed1492a9a6b6505f9afb (diff)
downloadlinux-c940a0c54a2e9333478f1d87ed40006a04fcec7e.tar.xz
xfs: dynamically allocate cursors based on maxlevels
To support future btree code, we need to be able to size btree cursors dynamically for very large btrees. Switch the maxlevels computation to use the precomputed values in the superblock, and create cursors that can handle a certain height. For now, we retain the btree cursor cache that can handle up to 9-level btrees, though a subsequent patch introduces separate caches for each btree type, where each cache's objects will be exactly tall enough to handle the specific btree type. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Dave Chinner <dchinner@redhat.com>
Diffstat (limited to 'fs/xfs/libxfs/xfs_btree.h')
-rw-r--r--fs/xfs/libxfs/xfs_btree.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/fs/xfs/libxfs/xfs_btree.h b/fs/xfs/libxfs/xfs_btree.h
index ed0b7d5ab3a3..b46cd98309fa 100644
--- a/fs/xfs/libxfs/xfs_btree.h
+++ b/fs/xfs/libxfs/xfs_btree.h
@@ -94,6 +94,12 @@ uint32_t xfs_btree_magic(int crc, xfs_btnum_t btnum);
#define XFS_BTREE_MAXLEVELS 9 /* max of all btrees */
+/*
+ * The btree cursor zone hands out cursors that can handle up to this many
+ * levels. This is the known maximum for all btree types.
+ */
+#define XFS_BTREE_CUR_CACHE_MAXLEVELS (9)
+
struct xfs_btree_ops {
/* size of the key and record structures */
size_t key_len;
@@ -583,15 +589,18 @@ static inline struct xfs_btree_cur *
xfs_btree_alloc_cursor(
struct xfs_mount *mp,
struct xfs_trans *tp,
- xfs_btnum_t btnum)
+ xfs_btnum_t btnum,
+ uint8_t maxlevels)
{
struct xfs_btree_cur *cur;
+ ASSERT(maxlevels <= XFS_BTREE_CUR_CACHE_MAXLEVELS);
+
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->bc_maxlevels = XFS_BTREE_MAXLEVELS;
+ cur->bc_maxlevels = maxlevels;
return cur;
}