aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_alloc_btree.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_alloc_btree.c')
-rw-r--r--fs/xfs/xfs_alloc_btree.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/fs/xfs/xfs_alloc_btree.c b/fs/xfs/xfs_alloc_btree.c
index 3ce2645508ae..60c121f1e81b 100644
--- a/fs/xfs/xfs_alloc_btree.c
+++ b/fs/xfs/xfs_alloc_btree.c
@@ -2209,3 +2209,48 @@ xfs_alloc_update(
2209 } 2209 }
2210 return 0; 2210 return 0;
2211} 2211}
2212
2213STATIC struct xfs_btree_cur *
2214xfs_allocbt_dup_cursor(
2215 struct xfs_btree_cur *cur)
2216{
2217 return xfs_allocbt_init_cursor(cur->bc_mp, cur->bc_tp,
2218 cur->bc_private.a.agbp, cur->bc_private.a.agno,
2219 cur->bc_btnum);
2220}
2221
2222static const struct xfs_btree_ops xfs_allocbt_ops = {
2223 .dup_cursor = xfs_allocbt_dup_cursor,
2224};
2225
2226/*
2227 * Allocate a new allocation btree cursor.
2228 */
2229struct xfs_btree_cur * /* new alloc btree cursor */
2230xfs_allocbt_init_cursor(
2231 struct xfs_mount *mp, /* file system mount point */
2232 struct xfs_trans *tp, /* transaction pointer */
2233 struct xfs_buf *agbp, /* buffer for agf structure */
2234 xfs_agnumber_t agno, /* allocation group number */
2235 xfs_btnum_t btnum) /* btree identifier */
2236{
2237 struct xfs_agf *agf = XFS_BUF_TO_AGF(agbp);
2238 struct xfs_btree_cur *cur;
2239
2240 ASSERT(btnum == XFS_BTNUM_BNO || btnum == XFS_BTNUM_CNT);
2241
2242 cur = kmem_zone_zalloc(xfs_btree_cur_zone, KM_SLEEP);
2243
2244 cur->bc_tp = tp;
2245 cur->bc_mp = mp;
2246 cur->bc_nlevels = be32_to_cpu(agf->agf_levels[btnum]);
2247 cur->bc_btnum = btnum;
2248 cur->bc_blocklog = mp->m_sb.sb_blocklog;
2249
2250 cur->bc_ops = &xfs_allocbt_ops;
2251
2252 cur->bc_private.a.agbp = agbp;
2253 cur->bc_private.a.agno = agno;
2254
2255 return cur;
2256}