aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_ialloc_btree.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2008-10-30 01:53:59 -0400
committerLachlan McIlroy <lachlan@sgi.com>2008-10-30 01:53:59 -0400
commit561f7d17390d00444e6cd0b02b7516c91528082e (patch)
tree59359b995320bf79a55c2f23305960b5ffe74d8f /fs/xfs/xfs_ialloc_btree.c
parentf2277f06e626d694e61bb356524ff536ced24acf (diff)
[XFS] split up xfs_btree_init_cursor
xfs_btree_init_cursor contains close to little shared code for the different btrees and will get even more non-common code in the future. Split it up into one routine per btree type. Because xfs_btree_dup_cursor needs to call the init routine for a generic btree cursor add a new btree operation vector that contains a dup_cursor method that initializes a new cursor based on an existing one. The btree operations vector is based on an idea and code from Dave Chinner and will grow more entries later during this series. SGI-PV: 985583 SGI-Modid: xfs-linux-melb:xfs-kern:32176a Signed-off-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Lachlan McIlroy <lachlan@sgi.com> Signed-off-by: Bill O'Donnell <billodo@sgi.com> Signed-off-by: David Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs/xfs_ialloc_btree.c')
-rw-r--r--fs/xfs/xfs_ialloc_btree.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/fs/xfs/xfs_ialloc_btree.c b/fs/xfs/xfs_ialloc_btree.c
index 83502f3edef0..8c0c4748a8df 100644
--- a/fs/xfs/xfs_ialloc_btree.c
+++ b/fs/xfs/xfs_ialloc_btree.c
@@ -2076,3 +2076,44 @@ xfs_inobt_update(
2076 } 2076 }
2077 return 0; 2077 return 0;
2078} 2078}
2079
2080STATIC struct xfs_btree_cur *
2081xfs_inobt_dup_cursor(
2082 struct xfs_btree_cur *cur)
2083{
2084 return xfs_inobt_init_cursor(cur->bc_mp, cur->bc_tp,
2085 cur->bc_private.a.agbp, cur->bc_private.a.agno);
2086}
2087
2088static const struct xfs_btree_ops xfs_inobt_ops = {
2089 .dup_cursor = xfs_inobt_dup_cursor,
2090};
2091
2092/*
2093 * Allocate a new inode btree cursor.
2094 */
2095struct xfs_btree_cur * /* new inode btree cursor */
2096xfs_inobt_init_cursor(
2097 struct xfs_mount *mp, /* file system mount point */
2098 struct xfs_trans *tp, /* transaction pointer */
2099 struct xfs_buf *agbp, /* buffer for agi structure */
2100 xfs_agnumber_t agno) /* allocation group number */
2101{
2102 struct xfs_agi *agi = XFS_BUF_TO_AGI(agbp);
2103 struct xfs_btree_cur *cur;
2104
2105 cur = kmem_zone_zalloc(xfs_btree_cur_zone, KM_SLEEP);
2106
2107 cur->bc_tp = tp;
2108 cur->bc_mp = mp;
2109 cur->bc_nlevels = be32_to_cpu(agi->agi_level);
2110 cur->bc_btnum = XFS_BTNUM_INO;
2111 cur->bc_blocklog = mp->m_sb.sb_blocklog;
2112
2113 cur->bc_ops = &xfs_inobt_ops;
2114
2115 cur->bc_private.a.agbp = agbp;
2116 cur->bc_private.a.agno = agno;
2117
2118 return cur;
2119}