aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_alloc.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_alloc.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_alloc.c')
-rw-r--r--fs/xfs/xfs_alloc.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/fs/xfs/xfs_alloc.c b/fs/xfs/xfs_alloc.c
index 1956f83489f1..69833eb1de4f 100644
--- a/fs/xfs/xfs_alloc.c
+++ b/fs/xfs/xfs_alloc.c
@@ -640,8 +640,8 @@ xfs_alloc_ag_vextent_exact(
640 /* 640 /*
641 * Allocate/initialize a cursor for the by-number freespace btree. 641 * Allocate/initialize a cursor for the by-number freespace btree.
642 */ 642 */
643 bno_cur = xfs_btree_init_cursor(args->mp, args->tp, args->agbp, 643 bno_cur = xfs_allocbt_init_cursor(args->mp, args->tp, args->agbp,
644 args->agno, XFS_BTNUM_BNO, NULL, 0); 644 args->agno, XFS_BTNUM_BNO);
645 /* 645 /*
646 * Lookup bno and minlen in the btree (minlen is irrelevant, really). 646 * Lookup bno and minlen in the btree (minlen is irrelevant, really).
647 * Look for the closest free block <= bno, it must contain bno 647 * Look for the closest free block <= bno, it must contain bno
@@ -696,8 +696,8 @@ xfs_alloc_ag_vextent_exact(
696 * We are allocating agbno for rlen [agbno .. end] 696 * We are allocating agbno for rlen [agbno .. end]
697 * Allocate/initialize a cursor for the by-size btree. 697 * Allocate/initialize a cursor for the by-size btree.
698 */ 698 */
699 cnt_cur = xfs_btree_init_cursor(args->mp, args->tp, args->agbp, 699 cnt_cur = xfs_allocbt_init_cursor(args->mp, args->tp, args->agbp,
700 args->agno, XFS_BTNUM_CNT, NULL, 0); 700 args->agno, XFS_BTNUM_CNT);
701 ASSERT(args->agbno + args->len <= 701 ASSERT(args->agbno + args->len <=
702 be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length)); 702 be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length));
703 if ((error = xfs_alloc_fixup_trees(cnt_cur, bno_cur, fbno, flen, 703 if ((error = xfs_alloc_fixup_trees(cnt_cur, bno_cur, fbno, flen,
@@ -759,8 +759,8 @@ xfs_alloc_ag_vextent_near(
759 /* 759 /*
760 * Get a cursor for the by-size btree. 760 * Get a cursor for the by-size btree.
761 */ 761 */
762 cnt_cur = xfs_btree_init_cursor(args->mp, args->tp, args->agbp, 762 cnt_cur = xfs_allocbt_init_cursor(args->mp, args->tp, args->agbp,
763 args->agno, XFS_BTNUM_CNT, NULL, 0); 763 args->agno, XFS_BTNUM_CNT);
764 ltlen = 0; 764 ltlen = 0;
765 bno_cur_lt = bno_cur_gt = NULL; 765 bno_cur_lt = bno_cur_gt = NULL;
766 /* 766 /*
@@ -886,8 +886,8 @@ xfs_alloc_ag_vextent_near(
886 /* 886 /*
887 * Set up a cursor for the by-bno tree. 887 * Set up a cursor for the by-bno tree.
888 */ 888 */
889 bno_cur_lt = xfs_btree_init_cursor(args->mp, args->tp, 889 bno_cur_lt = xfs_allocbt_init_cursor(args->mp, args->tp,
890 args->agbp, args->agno, XFS_BTNUM_BNO, NULL, 0); 890 args->agbp, args->agno, XFS_BTNUM_BNO);
891 /* 891 /*
892 * Fix up the btree entries. 892 * Fix up the btree entries.
893 */ 893 */
@@ -914,8 +914,8 @@ xfs_alloc_ag_vextent_near(
914 /* 914 /*
915 * Allocate and initialize the cursor for the leftward search. 915 * Allocate and initialize the cursor for the leftward search.
916 */ 916 */
917 bno_cur_lt = xfs_btree_init_cursor(args->mp, args->tp, args->agbp, 917 bno_cur_lt = xfs_allocbt_init_cursor(args->mp, args->tp, args->agbp,
918 args->agno, XFS_BTNUM_BNO, NULL, 0); 918 args->agno, XFS_BTNUM_BNO);
919 /* 919 /*
920 * Lookup <= bno to find the leftward search's starting point. 920 * Lookup <= bno to find the leftward search's starting point.
921 */ 921 */
@@ -1267,8 +1267,8 @@ xfs_alloc_ag_vextent_size(
1267 /* 1267 /*
1268 * Allocate and initialize a cursor for the by-size btree. 1268 * Allocate and initialize a cursor for the by-size btree.
1269 */ 1269 */
1270 cnt_cur = xfs_btree_init_cursor(args->mp, args->tp, args->agbp, 1270 cnt_cur = xfs_allocbt_init_cursor(args->mp, args->tp, args->agbp,
1271 args->agno, XFS_BTNUM_CNT, NULL, 0); 1271 args->agno, XFS_BTNUM_CNT);
1272 bno_cur = NULL; 1272 bno_cur = NULL;
1273 /* 1273 /*
1274 * Look for an entry >= maxlen+alignment-1 blocks. 1274 * Look for an entry >= maxlen+alignment-1 blocks.
@@ -1372,8 +1372,8 @@ xfs_alloc_ag_vextent_size(
1372 /* 1372 /*
1373 * Allocate and initialize a cursor for the by-block tree. 1373 * Allocate and initialize a cursor for the by-block tree.
1374 */ 1374 */
1375 bno_cur = xfs_btree_init_cursor(args->mp, args->tp, args->agbp, 1375 bno_cur = xfs_allocbt_init_cursor(args->mp, args->tp, args->agbp,
1376 args->agno, XFS_BTNUM_BNO, NULL, 0); 1376 args->agno, XFS_BTNUM_BNO);
1377 if ((error = xfs_alloc_fixup_trees(cnt_cur, bno_cur, fbno, flen, 1377 if ((error = xfs_alloc_fixup_trees(cnt_cur, bno_cur, fbno, flen,
1378 rbno, rlen, XFSA_FIXUP_CNT_OK))) 1378 rbno, rlen, XFSA_FIXUP_CNT_OK)))
1379 goto error0; 1379 goto error0;
@@ -1515,8 +1515,7 @@ xfs_free_ag_extent(
1515 /* 1515 /*
1516 * Allocate and initialize a cursor for the by-block btree. 1516 * Allocate and initialize a cursor for the by-block btree.
1517 */ 1517 */
1518 bno_cur = xfs_btree_init_cursor(mp, tp, agbp, agno, XFS_BTNUM_BNO, NULL, 1518 bno_cur = xfs_allocbt_init_cursor(mp, tp, agbp, agno, XFS_BTNUM_BNO);
1519 0);
1520 cnt_cur = NULL; 1519 cnt_cur = NULL;
1521 /* 1520 /*
1522 * Look for a neighboring block on the left (lower block numbers) 1521 * Look for a neighboring block on the left (lower block numbers)
@@ -1575,8 +1574,7 @@ xfs_free_ag_extent(
1575 /* 1574 /*
1576 * Now allocate and initialize a cursor for the by-size tree. 1575 * Now allocate and initialize a cursor for the by-size tree.
1577 */ 1576 */
1578 cnt_cur = xfs_btree_init_cursor(mp, tp, agbp, agno, XFS_BTNUM_CNT, NULL, 1577 cnt_cur = xfs_allocbt_init_cursor(mp, tp, agbp, agno, XFS_BTNUM_CNT);
1579 0);
1580 /* 1578 /*
1581 * Have both left and right contiguous neighbors. 1579 * Have both left and right contiguous neighbors.
1582 * Merge all three into a single free block. 1580 * Merge all three into a single free block.