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_bmap_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_bmap_btree.c')
-rw-r--r-- | fs/xfs/xfs_bmap_btree.c | 49 |
1 files changed, 5 insertions, 44 deletions
diff --git a/fs/xfs/xfs_bmap_btree.c b/fs/xfs/xfs_bmap_btree.c index 8403d154ae09..0a56257b7fd5 100644 --- a/fs/xfs/xfs_bmap_btree.c +++ b/fs/xfs/xfs_bmap_btree.c | |||
@@ -56,7 +56,6 @@ STATIC int xfs_bmbt_lshift(xfs_btree_cur_t *, int, int *); | |||
56 | STATIC int xfs_bmbt_rshift(xfs_btree_cur_t *, int, int *); | 56 | STATIC int xfs_bmbt_rshift(xfs_btree_cur_t *, int, int *); |
57 | STATIC int xfs_bmbt_split(xfs_btree_cur_t *, int, xfs_fsblock_t *, | 57 | STATIC int xfs_bmbt_split(xfs_btree_cur_t *, int, xfs_fsblock_t *, |
58 | __uint64_t *, xfs_btree_cur_t **, int *); | 58 | __uint64_t *, xfs_btree_cur_t **, int *); |
59 | STATIC int xfs_bmbt_updkey(xfs_btree_cur_t *, xfs_bmbt_key_t *, int); | ||
60 | 59 | ||
61 | #undef EXIT | 60 | #undef EXIT |
62 | 61 | ||
@@ -211,7 +210,7 @@ xfs_bmbt_delrec( | |||
211 | *stat = 1; | 210 | *stat = 1; |
212 | return 0; | 211 | return 0; |
213 | } | 212 | } |
214 | if (ptr == 1 && (error = xfs_bmbt_updkey(cur, kp, level + 1))) { | 213 | if (ptr == 1 && (error = xfs_btree_updkey(cur, (union xfs_btree_key *)kp, level + 1))) { |
215 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 214 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
216 | goto error0; | 215 | goto error0; |
217 | } | 216 | } |
@@ -635,7 +634,7 @@ xfs_bmbt_insrec( | |||
635 | kp + ptr); | 634 | kp + ptr); |
636 | } | 635 | } |
637 | #endif | 636 | #endif |
638 | if (optr == 1 && (error = xfs_bmbt_updkey(cur, &key, level + 1))) { | 637 | if (optr == 1 && (error = xfs_btree_updkey(cur, (union xfs_btree_key *)&key, level + 1))) { |
639 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 638 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
640 | return error; | 639 | return error; |
641 | } | 640 | } |
@@ -935,7 +934,7 @@ xfs_bmbt_lshift( | |||
935 | key.br_startoff = cpu_to_be64(xfs_bmbt_disk_get_startoff(rrp)); | 934 | key.br_startoff = cpu_to_be64(xfs_bmbt_disk_get_startoff(rrp)); |
936 | rkp = &key; | 935 | rkp = &key; |
937 | } | 936 | } |
938 | if ((error = xfs_bmbt_updkey(cur, rkp, level + 1))) { | 937 | if ((error = xfs_btree_updkey(cur, (union xfs_btree_key *)rkp, level + 1))) { |
939 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 938 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
940 | return error; | 939 | return error; |
941 | } | 940 | } |
@@ -1067,7 +1066,7 @@ xfs_bmbt_rshift( | |||
1067 | goto error1; | 1066 | goto error1; |
1068 | } | 1067 | } |
1069 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); | 1068 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); |
1070 | if ((error = xfs_bmbt_updkey(tcur, rkp, level + 1))) { | 1069 | if ((error = xfs_btree_updkey(tcur, (union xfs_btree_key *)rkp, level + 1))) { |
1071 | XFS_BMBT_TRACE_CURSOR(tcur, ERROR); | 1070 | XFS_BMBT_TRACE_CURSOR(tcur, ERROR); |
1072 | goto error1; | 1071 | goto error1; |
1073 | } | 1072 | } |
@@ -1276,44 +1275,6 @@ xfs_bmbt_split( | |||
1276 | return 0; | 1275 | return 0; |
1277 | } | 1276 | } |
1278 | 1277 | ||
1279 | |||
1280 | /* | ||
1281 | * Update keys for the record. | ||
1282 | */ | ||
1283 | STATIC int | ||
1284 | xfs_bmbt_updkey( | ||
1285 | xfs_btree_cur_t *cur, | ||
1286 | xfs_bmbt_key_t *keyp, /* on-disk format */ | ||
1287 | int level) | ||
1288 | { | ||
1289 | xfs_bmbt_block_t *block; | ||
1290 | xfs_buf_t *bp; | ||
1291 | #ifdef DEBUG | ||
1292 | int error; | ||
1293 | #endif | ||
1294 | xfs_bmbt_key_t *kp; | ||
1295 | int ptr; | ||
1296 | |||
1297 | ASSERT(level >= 1); | ||
1298 | XFS_BMBT_TRACE_CURSOR(cur, ENTRY); | ||
1299 | XFS_BMBT_TRACE_ARGIK(cur, level, keyp); | ||
1300 | for (ptr = 1; ptr == 1 && level < cur->bc_nlevels; level++) { | ||
1301 | block = xfs_bmbt_get_block(cur, level, &bp); | ||
1302 | #ifdef DEBUG | ||
1303 | if ((error = xfs_btree_check_lblock(cur, block, level, bp))) { | ||
1304 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | ||
1305 | return error; | ||
1306 | } | ||
1307 | #endif | ||
1308 | ptr = cur->bc_ptrs[level]; | ||
1309 | kp = XFS_BMAP_KEY_IADDR(block, ptr, cur); | ||
1310 | *kp = *keyp; | ||
1311 | xfs_bmbt_log_keys(cur, bp, ptr, ptr); | ||
1312 | } | ||
1313 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | ||
1314 | return 0; | ||
1315 | } | ||
1316 | |||
1317 | /* | 1278 | /* |
1318 | * Convert on-disk form of btree root to in-memory form. | 1279 | * Convert on-disk form of btree root to in-memory form. |
1319 | */ | 1280 | */ |
@@ -2039,7 +2000,7 @@ xfs_bmbt_update( | |||
2039 | return 0; | 2000 | return 0; |
2040 | } | 2001 | } |
2041 | key.br_startoff = cpu_to_be64(off); | 2002 | key.br_startoff = cpu_to_be64(off); |
2042 | if ((error = xfs_bmbt_updkey(cur, &key, 1))) { | 2003 | if ((error = xfs_btree_updkey(cur, (union xfs_btree_key *)&key, 1))) { |
2043 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 2004 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
2044 | return error; | 2005 | return error; |
2045 | } | 2006 | } |