aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_alloc_btree.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2008-10-30 01:56:22 -0400
committerLachlan McIlroy <lachlan@sgi.com>2008-10-30 01:56:22 -0400
commit38bb74237d2d94c1aced2ec626d7d0f317e360da (patch)
treee37dfdad942de0e98c36c0fdf781cc29cd2daf0c /fs/xfs/xfs_alloc_btree.c
parentfe033cc848489851f0c7de48f0b1bab5d744ad8a (diff)
[XFS] implement generic xfs_btree_updkey
From: Dave Chinner <dgc@sgi.com> Note that there are many > 80 char lines introduced due to the xfs_btree_key casts. But the places where this happens is throw-away code once the whole btree code gets merged into a common implementation. The same is true for the temporary xfs_alloc_log_keys define to the new name. All old users will be gone after a few patches. [hch: split out from bigger patch and minor adaptions] SGI-PV: 985583 SGI-Modid: xfs-linux-melb:xfs-kern:32193a 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_btree.c')
-rw-r--r--fs/xfs/xfs_alloc_btree.c50
1 files changed, 5 insertions, 45 deletions
diff --git a/fs/xfs/xfs_alloc_btree.c b/fs/xfs/xfs_alloc_btree.c
index b81fbf1216ed..28c6a698f562 100644
--- a/fs/xfs/xfs_alloc_btree.c
+++ b/fs/xfs/xfs_alloc_btree.c
@@ -52,7 +52,6 @@ STATIC int xfs_alloc_newroot(xfs_btree_cur_t *, int *);
52STATIC int xfs_alloc_rshift(xfs_btree_cur_t *, int, int *); 52STATIC int xfs_alloc_rshift(xfs_btree_cur_t *, int, int *);
53STATIC int xfs_alloc_split(xfs_btree_cur_t *, int, xfs_agblock_t *, 53STATIC int xfs_alloc_split(xfs_btree_cur_t *, int, xfs_agblock_t *,
54 xfs_alloc_key_t *, xfs_btree_cur_t **, int *); 54 xfs_alloc_key_t *, xfs_btree_cur_t **, int *);
55STATIC int xfs_alloc_updkey(xfs_btree_cur_t *, xfs_alloc_key_t *, int);
56 55
57/* 56/*
58 * Internal functions. 57 * Internal functions.
@@ -265,7 +264,7 @@ xfs_alloc_delrec(
265 * If we deleted the leftmost entry in the block, update the 264 * If we deleted the leftmost entry in the block, update the
266 * key values above us in the tree. 265 * key values above us in the tree.
267 */ 266 */
268 if (ptr == 1 && (error = xfs_alloc_updkey(cur, lkp, level + 1))) 267 if (ptr == 1 && (error = xfs_btree_updkey(cur, (union xfs_btree_key *)lkp, level + 1)))
269 return error; 268 return error;
270 /* 269 /*
271 * If the number of records remaining in the block is at least 270 * If the number of records remaining in the block is at least
@@ -798,7 +797,7 @@ xfs_alloc_insrec(
798 /* 797 /*
799 * If we inserted at the start of a block, update the parents' keys. 798 * If we inserted at the start of a block, update the parents' keys.
800 */ 799 */
801 if (optr == 1 && (error = xfs_alloc_updkey(cur, &key, level + 1))) 800 if (optr == 1 && (error = xfs_btree_updkey(cur, (union xfs_btree_key *)&key, level + 1)))
802 return error; 801 return error;
803 /* 802 /*
804 * Look to see if the longest extent in the allocation group 803 * Look to see if the longest extent in the allocation group
@@ -1068,7 +1067,7 @@ xfs_alloc_lshift(
1068 /* 1067 /*
1069 * Update the parent key values of right. 1068 * Update the parent key values of right.
1070 */ 1069 */
1071 if ((error = xfs_alloc_updkey(cur, rkp, level + 1))) 1070 if ((error = xfs_btree_updkey(cur, (union xfs_btree_key *)rkp, level + 1)))
1072 return error; 1071 return error;
1073 /* 1072 /*
1074 * Slide the cursor value left one. 1073 * Slide the cursor value left one.
@@ -1354,7 +1353,7 @@ xfs_alloc_rshift(
1354 i = xfs_btree_lastrec(tcur, level); 1353 i = xfs_btree_lastrec(tcur, level);
1355 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 1354 XFS_WANT_CORRUPTED_GOTO(i == 1, error0);
1356 if ((error = xfs_btree_increment(tcur, level, &i)) || 1355 if ((error = xfs_btree_increment(tcur, level, &i)) ||
1357 (error = xfs_alloc_updkey(tcur, rkp, level + 1))) 1356 (error = xfs_btree_updkey(tcur, (union xfs_btree_key *)rkp, level + 1)))
1358 goto error0; 1357 goto error0;
1359 xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR); 1358 xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR);
1360 *stat = 1; 1359 *stat = 1;
@@ -1520,45 +1519,6 @@ xfs_alloc_split(
1520} 1519}
1521 1520
1522/* 1521/*
1523 * Update keys at all levels from here to the root along the cursor's path.
1524 */
1525STATIC int /* error */
1526xfs_alloc_updkey(
1527 xfs_btree_cur_t *cur, /* btree cursor */
1528 xfs_alloc_key_t *keyp, /* new key value to update to */
1529 int level) /* starting level for update */
1530{
1531 int ptr; /* index of key in block */
1532
1533 /*
1534 * Go up the tree from this level toward the root.
1535 * At each level, update the key value to the value input.
1536 * Stop when we reach a level where the cursor isn't pointing
1537 * at the first entry in the block.
1538 */
1539 for (ptr = 1; ptr == 1 && level < cur->bc_nlevels; level++) {
1540 xfs_alloc_block_t *block; /* btree block */
1541 xfs_buf_t *bp; /* buffer for block */
1542#ifdef DEBUG
1543 int error; /* error return value */
1544#endif
1545 xfs_alloc_key_t *kp; /* ptr to btree block keys */
1546
1547 bp = cur->bc_bufs[level];
1548 block = XFS_BUF_TO_ALLOC_BLOCK(bp);
1549#ifdef DEBUG
1550 if ((error = xfs_btree_check_sblock(cur, block, level, bp)))
1551 return error;
1552#endif
1553 ptr = cur->bc_ptrs[level];
1554 kp = XFS_ALLOC_KEY_ADDR(block, ptr, cur);
1555 *kp = *keyp;
1556 xfs_alloc_log_keys(cur, bp, ptr, ptr);
1557 }
1558 return 0;
1559}
1560
1561/*
1562 * Externally visible routines. 1522 * Externally visible routines.
1563 */ 1523 */
1564 1524
@@ -1765,7 +1725,7 @@ xfs_alloc_update(
1765 1725
1766 key.ar_startblock = cpu_to_be32(bno); 1726 key.ar_startblock = cpu_to_be32(bno);
1767 key.ar_blockcount = cpu_to_be32(len); 1727 key.ar_blockcount = cpu_to_be32(len);
1768 if ((error = xfs_alloc_updkey(cur, &key, 1))) 1728 if ((error = xfs_btree_updkey(cur, (union xfs_btree_key *)&key, 1)))
1769 return error; 1729 return error;
1770 } 1730 }
1771 return 0; 1731 return 0;