Skip to content

Commit 2054cf0

Browse files
author
Darrick J. Wong
committed
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>
1 parent 07b7f2e commit 2054cf0

1 file changed

Lines changed: 11 additions & 14 deletions

File tree

fs/xfs/libxfs/xfs_btree.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,27 +1222,24 @@ xfs_btree_init_buf(
12221222
bp->b_ops = ops->buf_ops;
12231223
}
12241224

1225+
static inline __u64
1226+
xfs_btree_owner(
1227+
struct xfs_btree_cur *cur)
1228+
{
1229+
if (cur->bc_ops->geom_flags & XFS_BTGEO_ROOT_IN_INODE)
1230+
return cur->bc_ino.ip->i_ino;
1231+
return cur->bc_ag.pag->pag_agno;
1232+
}
1233+
12251234
void
12261235
xfs_btree_init_block_cur(
12271236
struct xfs_btree_cur *cur,
12281237
struct xfs_buf *bp,
12291238
int level,
12301239
int numrecs)
12311240
{
1232-
__u64 owner;
1233-
1234-
/*
1235-
* we can pull the owner from the cursor right now as the different
1236-
* owners align directly with the pointer size of the btree. This may
1237-
* change in future, but is safe for current users of the generic btree
1238-
* code.
1239-
*/
1240-
if (cur->bc_ops->geom_flags & XFS_BTGEO_LONG_PTRS)
1241-
owner = cur->bc_ino.ip->i_ino;
1242-
else
1243-
owner = cur->bc_ag.pag->pag_agno;
1244-
1245-
xfs_btree_init_buf(cur->bc_mp, bp, cur->bc_ops, level, numrecs, owner);
1241+
xfs_btree_init_buf(cur->bc_mp, bp, cur->bc_ops, level, numrecs,
1242+
xfs_btree_owner(cur));
12461243
}
12471244

12481245
/*

0 commit comments

Comments
 (0)