diff options
author | Christoph Hellwig <hch@lst.de> | 2024-02-22 12:39:41 -0800 |
---|---|---|
committer | Darrick J. Wong <djwong@kernel.org> | 2024-02-22 12:39:41 -0800 |
commit | c49a4b2f0ef0ac5daee5c2a3cfd2b537345c34eb (patch) | |
tree | 39462d5719b2b165c8ec55a1e3b418a6dfb56777 /fs | |
parent | a5c2194406f322e91b90fb813128541a9b4fed6a (diff) | |
download | linux-stable-c49a4b2f0ef0ac5daee5c2a3cfd2b537345c34eb.tar.gz linux-stable-c49a4b2f0ef0ac5daee5c2a3cfd2b537345c34eb.tar.bz2 linux-stable-c49a4b2f0ef0ac5daee5c2a3cfd2b537345c34eb.zip |
xfs: fold xfs_rmapbt_init_common into xfs_rmapbt_init_cursor
Make the levels initialization in xfs_rmapbt_init_cursor conditional
and merge the two helpers.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/xfs/libxfs/xfs_rmap_btree.c | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/fs/xfs/libxfs/xfs_rmap_btree.c b/fs/xfs/libxfs/xfs_rmap_btree.c index 84eb767425cb..dda9f8844d84 100644 --- a/fs/xfs/libxfs/xfs_rmap_btree.c +++ b/fs/xfs/libxfs/xfs_rmap_btree.c @@ -502,21 +502,11 @@ const struct xfs_btree_ops xfs_rmapbt_ops = { .keys_contiguous = xfs_rmapbt_keys_contiguous, }; -static struct xfs_btree_cur * -xfs_rmapbt_init_common( - struct xfs_mount *mp, - struct xfs_trans *tp, - struct xfs_perag *pag) -{ - struct xfs_btree_cur *cur; - - cur = xfs_btree_alloc_cursor(mp, tp, XFS_BTNUM_RMAP, &xfs_rmapbt_ops, - mp->m_rmap_maxlevels, xfs_rmapbt_cur_cache); - cur->bc_ag.pag = xfs_perag_hold(pag); - return cur; -} - -/* Create a new reverse mapping btree cursor. */ +/* + * Create a new reverse mapping btree cursor. + * + * For staging cursors tp and agbp are NULL. + */ struct xfs_btree_cur * xfs_rmapbt_init_cursor( struct xfs_mount *mp, @@ -524,12 +514,17 @@ xfs_rmapbt_init_cursor( struct xfs_buf *agbp, struct xfs_perag *pag) { - struct xfs_agf *agf = agbp->b_addr; struct xfs_btree_cur *cur; - cur = xfs_rmapbt_init_common(mp, tp, pag); - cur->bc_nlevels = be32_to_cpu(agf->agf_levels[XFS_BTNUM_RMAP]); + cur = xfs_btree_alloc_cursor(mp, tp, XFS_BTNUM_RMAP, &xfs_rmapbt_ops, + mp->m_rmap_maxlevels, xfs_rmapbt_cur_cache); + cur->bc_ag.pag = xfs_perag_hold(pag); cur->bc_ag.agbp = agbp; + if (agbp) { + struct xfs_agf *agf = agbp->b_addr; + + cur->bc_nlevels = be32_to_cpu(agf->agf_levels[XFS_BTNUM_RMAP]); + } return cur; } @@ -542,7 +537,7 @@ xfs_rmapbt_stage_cursor( { struct xfs_btree_cur *cur; - cur = xfs_rmapbt_init_common(mp, NULL, pag); + cur = xfs_rmapbt_init_cursor(mp, NULL, NULL, pag); xfs_btree_stage_afakeroot(cur, afake); return cur; } |