summaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2024-02-22 12:39:38 -0800
committerDarrick J. Wong <djwong@kernel.org>2024-02-22 12:39:38 -0800
commitf6c98d921a9e5b753ac1a35d540a6487ee111a33 (patch)
tree6097f3e5abb16d540114419f73f2cd74a1e3542d /fs/xfs
parent91796b2eef8bd725873bec326a7be830a68a11ff (diff)
downloadlinux-f6c98d921a9e5b753ac1a35d540a6487ee111a33.tar.gz
linux-f6c98d921a9e5b753ac1a35d540a6487ee111a33.tar.bz2
linux-f6c98d921a9e5b753ac1a35d540a6487ee111a33.zip
xfs: fold xfs_inobt_init_common into xfs_inobt_init_cursor
Make the levels initialization in xfs_inobt_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/xfs')
-rw-r--r--fs/xfs/libxfs/xfs_ialloc_btree.c39
1 files changed, 15 insertions, 24 deletions
diff --git a/fs/xfs/libxfs/xfs_ialloc_btree.c b/fs/xfs/libxfs/xfs_ialloc_btree.c
index 0d04ac32367d..48bfea0e2a20 100644
--- a/fs/xfs/libxfs/xfs_ialloc_btree.c
+++ b/fs/xfs/libxfs/xfs_ialloc_btree.c
@@ -455,12 +455,15 @@ const struct xfs_btree_ops xfs_finobt_ops = {
};
/*
- * Initialize a new inode btree cursor.
+ * Create an inode btree cursor.
+ *
+ * For staging cursors tp and agbp are NULL.
*/
-static struct xfs_btree_cur *
-xfs_inobt_init_common(
+struct xfs_btree_cur *
+xfs_inobt_init_cursor(
struct xfs_perag *pag,
- struct xfs_trans *tp, /* transaction pointer */
+ struct xfs_trans *tp,
+ struct xfs_buf *agbp,
xfs_btnum_t btnum) /* ialloc or free ino btree */
{
struct xfs_mount *mp = pag->pag_mount;
@@ -475,26 +478,14 @@ xfs_inobt_init_common(
cur = xfs_btree_alloc_cursor(mp, tp, btnum, ops,
M_IGEO(mp)->inobt_maxlevels, xfs_inobt_cur_cache);
cur->bc_ag.pag = xfs_perag_hold(pag);
- return cur;
-}
-
-/* Create an inode btree cursor. */
-struct xfs_btree_cur *
-xfs_inobt_init_cursor(
- struct xfs_perag *pag,
- struct xfs_trans *tp,
- struct xfs_buf *agbp,
- xfs_btnum_t btnum)
-{
- struct xfs_btree_cur *cur;
- struct xfs_agi *agi = agbp->b_addr;
-
- cur = xfs_inobt_init_common(pag, tp, btnum);
- if (btnum == XFS_BTNUM_INO)
- cur->bc_nlevels = be32_to_cpu(agi->agi_level);
- else
- cur->bc_nlevels = be32_to_cpu(agi->agi_free_level);
cur->bc_ag.agbp = agbp;
+ if (agbp) {
+ struct xfs_agi *agi = agbp->b_addr;
+
+ cur->bc_nlevels = (btnum == XFS_BTNUM_INO) ?
+ be32_to_cpu(agi->agi_level) :
+ be32_to_cpu(agi->agi_free_level);
+ }
return cur;
}
@@ -507,7 +498,7 @@ xfs_inobt_stage_cursor(
{
struct xfs_btree_cur *cur;
- cur = xfs_inobt_init_common(pag, NULL, btnum);
+ cur = xfs_inobt_init_cursor(pag, NULL, NULL, btnum);
xfs_btree_stage_afakeroot(cur, afake);
return cur;
}