diff options
author | Christoph Hellwig <hch@infradead.org> | 2008-10-30 01:56:22 -0400 |
---|---|---|
committer | Lachlan McIlroy <lachlan@sgi.com> | 2008-10-30 01:56:22 -0400 |
commit | 38bb74237d2d94c1aced2ec626d7d0f317e360da (patch) | |
tree | e37dfdad942de0e98c36c0fdf781cc29cd2daf0c /fs/xfs/xfs_ialloc_btree.c | |
parent | fe033cc848489851f0c7de48f0b1bab5d744ad8a (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_ialloc_btree.c')
-rw-r--r-- | fs/xfs/xfs_ialloc_btree.c | 50 |
1 files changed, 5 insertions, 45 deletions
diff --git a/fs/xfs/xfs_ialloc_btree.c b/fs/xfs/xfs_ialloc_btree.c index 161c3b2e245f..cd8bb519cb5f 100644 --- a/fs/xfs/xfs_ialloc_btree.c +++ b/fs/xfs/xfs_ialloc_btree.c | |||
@@ -48,7 +48,6 @@ STATIC int xfs_inobt_newroot(xfs_btree_cur_t *, int *); | |||
48 | STATIC int xfs_inobt_rshift(xfs_btree_cur_t *, int, int *); | 48 | STATIC int xfs_inobt_rshift(xfs_btree_cur_t *, int, int *); |
49 | STATIC int xfs_inobt_split(xfs_btree_cur_t *, int, xfs_agblock_t *, | 49 | STATIC int xfs_inobt_split(xfs_btree_cur_t *, int, xfs_agblock_t *, |
50 | xfs_inobt_key_t *, xfs_btree_cur_t **, int *); | 50 | xfs_inobt_key_t *, xfs_btree_cur_t **, int *); |
51 | STATIC int xfs_inobt_updkey(xfs_btree_cur_t *, xfs_inobt_key_t *, int); | ||
52 | 51 | ||
53 | /* | 52 | /* |
54 | * Single level of the xfs_inobt_delete record deletion routine. | 53 | * Single level of the xfs_inobt_delete record deletion routine. |
@@ -214,7 +213,7 @@ xfs_inobt_delrec( | |||
214 | * If we deleted the leftmost entry in the block, update the | 213 | * If we deleted the leftmost entry in the block, update the |
215 | * key values above us in the tree. | 214 | * key values above us in the tree. |
216 | */ | 215 | */ |
217 | if (ptr == 1 && (error = xfs_inobt_updkey(cur, kp, level + 1))) | 216 | if (ptr == 1 && (error = xfs_btree_updkey(cur, (union xfs_btree_key *)kp, level + 1))) |
218 | return error; | 217 | return error; |
219 | /* | 218 | /* |
220 | * If the number of records remaining in the block is at least | 219 | * If the number of records remaining in the block is at least |
@@ -723,7 +722,7 @@ xfs_inobt_insrec( | |||
723 | /* | 722 | /* |
724 | * If we inserted at the start of a block, update the parents' keys. | 723 | * If we inserted at the start of a block, update the parents' keys. |
725 | */ | 724 | */ |
726 | if (optr == 1 && (error = xfs_inobt_updkey(cur, &key, level + 1))) | 725 | if (optr == 1 && (error = xfs_btree_updkey(cur, (union xfs_btree_key *)&key, level + 1))) |
727 | return error; | 726 | return error; |
728 | /* | 727 | /* |
729 | * Return the new block number, if any. | 728 | * Return the new block number, if any. |
@@ -960,7 +959,7 @@ xfs_inobt_lshift( | |||
960 | /* | 959 | /* |
961 | * Update the parent key values of right. | 960 | * Update the parent key values of right. |
962 | */ | 961 | */ |
963 | if ((error = xfs_inobt_updkey(cur, rkp, level + 1))) | 962 | if ((error = xfs_btree_updkey(cur, (union xfs_btree_key *)rkp, level + 1))) |
964 | return error; | 963 | return error; |
965 | /* | 964 | /* |
966 | * Slide the cursor value left one. | 965 | * Slide the cursor value left one. |
@@ -1238,7 +1237,7 @@ xfs_inobt_rshift( | |||
1238 | return error; | 1237 | return error; |
1239 | xfs_btree_lastrec(tcur, level); | 1238 | xfs_btree_lastrec(tcur, level); |
1240 | if ((error = xfs_btree_increment(tcur, level, &i)) || | 1239 | if ((error = xfs_btree_increment(tcur, level, &i)) || |
1241 | (error = xfs_inobt_updkey(tcur, rkp, level + 1))) { | 1240 | (error = xfs_btree_updkey(tcur, (union xfs_btree_key *)rkp, level + 1))) { |
1242 | xfs_btree_del_cursor(tcur, XFS_BTREE_ERROR); | 1241 | xfs_btree_del_cursor(tcur, XFS_BTREE_ERROR); |
1243 | return error; | 1242 | return error; |
1244 | } | 1243 | } |
@@ -1407,45 +1406,6 @@ xfs_inobt_split( | |||
1407 | } | 1406 | } |
1408 | 1407 | ||
1409 | /* | 1408 | /* |
1410 | * Update keys at all levels from here to the root along the cursor's path. | ||
1411 | */ | ||
1412 | STATIC int /* error */ | ||
1413 | xfs_inobt_updkey( | ||
1414 | xfs_btree_cur_t *cur, /* btree cursor */ | ||
1415 | xfs_inobt_key_t *keyp, /* new key value to update to */ | ||
1416 | int level) /* starting level for update */ | ||
1417 | { | ||
1418 | int ptr; /* index of key in block */ | ||
1419 | |||
1420 | /* | ||
1421 | * Go up the tree from this level toward the root. | ||
1422 | * At each level, update the key value to the value input. | ||
1423 | * Stop when we reach a level where the cursor isn't pointing | ||
1424 | * at the first entry in the block. | ||
1425 | */ | ||
1426 | for (ptr = 1; ptr == 1 && level < cur->bc_nlevels; level++) { | ||
1427 | xfs_buf_t *bp; /* buffer for block */ | ||
1428 | xfs_inobt_block_t *block; /* btree block */ | ||
1429 | #ifdef DEBUG | ||
1430 | int error; /* error return value */ | ||
1431 | #endif | ||
1432 | xfs_inobt_key_t *kp; /* ptr to btree block keys */ | ||
1433 | |||
1434 | bp = cur->bc_bufs[level]; | ||
1435 | block = XFS_BUF_TO_INOBT_BLOCK(bp); | ||
1436 | #ifdef DEBUG | ||
1437 | if ((error = xfs_btree_check_sblock(cur, block, level, bp))) | ||
1438 | return error; | ||
1439 | #endif | ||
1440 | ptr = cur->bc_ptrs[level]; | ||
1441 | kp = XFS_INOBT_KEY_ADDR(block, ptr, cur); | ||
1442 | *kp = *keyp; | ||
1443 | xfs_inobt_log_keys(cur, bp, ptr, ptr); | ||
1444 | } | ||
1445 | return 0; | ||
1446 | } | ||
1447 | |||
1448 | /* | ||
1449 | * Externally visible routines. | 1409 | * Externally visible routines. |
1450 | */ | 1410 | */ |
1451 | 1411 | ||
@@ -1637,7 +1597,7 @@ xfs_inobt_update( | |||
1637 | xfs_inobt_key_t key; /* key containing [ino] */ | 1597 | xfs_inobt_key_t key; /* key containing [ino] */ |
1638 | 1598 | ||
1639 | key.ir_startino = cpu_to_be32(ino); | 1599 | key.ir_startino = cpu_to_be32(ino); |
1640 | if ((error = xfs_inobt_updkey(cur, &key, 1))) | 1600 | if ((error = xfs_btree_updkey(cur, (union xfs_btree_key *)&key, 1))) |
1641 | return error; | 1601 | return error; |
1642 | } | 1602 | } |
1643 | return 0; | 1603 | return 0; |