aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2024-02-22 12:35:22 -0800
committerDarrick J. Wong <djwong@kernel.org>2024-02-22 12:35:22 -0800
commit2054cf051698d30cc9479678c2b807a364248f38 (patch)
treecdd74392897fc38fd2afb1916aabdbe787c69f62 /fs/xfs
parent07b7f2e3172b97da2a7ac273ecbaf173cc09a9f4 (diff)
downloadlinux-2054cf051698d30cc9479678c2b807a364248f38.tar.gz
xfs: factor out a xfs_btree_owner helper
Split out a helper to calculate the owner for a given btree instead of duplicating the logic in two places. While we're at it, make the bc_ag/bc_ino switch logic depend on the correct geometry flag. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <djwong@kernel.org> [djwong: break this up into two patches for the owner check] Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/libxfs/xfs_btree.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
index e1e96f4f4052f..b869d6eb6a0b7 100644
--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -1222,6 +1222,15 @@ xfs_btree_init_buf(
bp->b_ops = ops->buf_ops;
}
+static inline __u64
+xfs_btree_owner(
+ struct xfs_btree_cur *cur)
+{
+ if (cur->bc_ops->geom_flags & XFS_BTGEO_ROOT_IN_INODE)
+ return cur->bc_ino.ip->i_ino;
+ return cur->bc_ag.pag->pag_agno;
+}
+
void
xfs_btree_init_block_cur(
struct xfs_btree_cur *cur,
@@ -1229,20 +1238,8 @@ xfs_btree_init_block_cur(
int level,
int numrecs)
{
- __u64 owner;
-
- /*
- * we can pull the owner from the cursor right now as the different
- * owners align directly with the pointer size of the btree. This may
- * change in future, but is safe for current users of the generic btree
- * code.
- */
- if (cur->bc_ops->geom_flags & XFS_BTGEO_LONG_PTRS)
- owner = cur->bc_ino.ip->i_ino;
- else
- owner = cur->bc_ag.pag->pag_agno;
-
- xfs_btree_init_buf(cur->bc_mp, bp, cur->bc_ops, level, numrecs, owner);
+ xfs_btree_init_buf(cur->bc_mp, bp, cur->bc_ops, level, numrecs,
+ xfs_btree_owner(cur));
}
/*