diff options
author | Christoph Hellwig <hch@infradead.org> | 2008-10-30 02:11:40 -0400 |
---|---|---|
committer | Lachlan McIlroy <lachlan@sgi.com> | 2008-10-30 02:11:40 -0400 |
commit | 136341b41ad4883bd668120f727a52c42331fe8a (patch) | |
tree | 0cb1b220073948f2632911354a828606a9e276bb /fs | |
parent | 6c7699c047c50403149ad91331dd39de47dea070 (diff) |
[XFS] cleanup btree record / key / ptr addressing macros.
Replace the generic record / key / ptr addressing macros that use cpp
token pasting with simpler macros that do the job for just one given btree
type. The new macros lose the cur argument and thus can be used outside
the core btree code, but also gain an xfs_mount * argument to allow for
checking the CRC flag in the near future. Note that many of these macros
aren't actually used in the kernel code, but only in userspace (mostly in
xfs_repair).
SGI-PV: 988146
SGI-Modid: xfs-linux-melb:xfs-kern:32295a
Signed-off-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Donald Douwsma <donaldd@sgi.com>
Signed-off-by: David Chinner <david@fromorbit.com>
Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/xfs/xfs_alloc_btree.c | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_alloc_btree.h | 25 | ||||
-rw-r--r-- | fs/xfs/xfs_bmap.c | 54 | ||||
-rw-r--r-- | fs/xfs/xfs_bmap_btree.c | 13 | ||||
-rw-r--r-- | fs/xfs/xfs_bmap_btree.h | 62 | ||||
-rw-r--r-- | fs/xfs/xfs_btree.h | 15 | ||||
-rw-r--r-- | fs/xfs/xfs_fsops.c | 4 | ||||
-rw-r--r-- | fs/xfs/xfs_ialloc_btree.h | 29 | ||||
-rw-r--r-- | fs/xfs/xfs_inode.c | 6 |
9 files changed, 113 insertions, 97 deletions
diff --git a/fs/xfs/xfs_alloc_btree.c b/fs/xfs/xfs_alloc_btree.c index 6ff27b75b93f..72c083f62a94 100644 --- a/fs/xfs/xfs_alloc_btree.c +++ b/fs/xfs/xfs_alloc_btree.c | |||
@@ -179,7 +179,7 @@ xfs_allocbt_update_lastrec( | |||
179 | if (numrecs) { | 179 | if (numrecs) { |
180 | xfs_alloc_rec_t *rrp; | 180 | xfs_alloc_rec_t *rrp; |
181 | 181 | ||
182 | rrp = XFS_ALLOC_REC_ADDR(block, numrecs, cur); | 182 | rrp = XFS_ALLOC_REC_ADDR(cur->bc_mp, block, numrecs); |
183 | len = rrp->ar_blockcount; | 183 | len = rrp->ar_blockcount; |
184 | } else { | 184 | } else { |
185 | len = 0; | 185 | len = 0; |
diff --git a/fs/xfs/xfs_alloc_btree.h b/fs/xfs/xfs_alloc_btree.h index ff1f71d069c4..579f9c7e0872 100644 --- a/fs/xfs/xfs_alloc_btree.h +++ b/fs/xfs/xfs_alloc_btree.h | |||
@@ -78,16 +78,27 @@ typedef struct xfs_btree_sblock xfs_alloc_block_t; | |||
78 | 78 | ||
79 | /* | 79 | /* |
80 | * Record, key, and pointer address macros for btree blocks. | 80 | * Record, key, and pointer address macros for btree blocks. |
81 | * | ||
82 | * (note that some of these may appear unused, but they are used in userspace) | ||
81 | */ | 83 | */ |
82 | #define XFS_ALLOC_REC_ADDR(bb,i,cur) \ | 84 | #define XFS_ALLOC_REC_ADDR(mp, block, index) \ |
83 | XFS_BTREE_REC_ADDR(xfs_alloc, bb, i) | 85 | ((xfs_alloc_rec_t *) \ |
84 | 86 | ((char *)(block) + \ | |
85 | #define XFS_ALLOC_KEY_ADDR(bb,i,cur) \ | 87 | sizeof(struct xfs_btree_sblock) + \ |
86 | XFS_BTREE_KEY_ADDR(xfs_alloc, bb, i) | 88 | (((index) - 1) * sizeof(xfs_alloc_rec_t)))) |
87 | 89 | ||
88 | #define XFS_ALLOC_PTR_ADDR(bb,i,cur) \ | 90 | #define XFS_ALLOC_KEY_ADDR(mp, block, index) \ |
89 | XFS_BTREE_PTR_ADDR(xfs_alloc, bb, i, XFS_ALLOC_BLOCK_MAXRECS(1, cur)) | 91 | ((xfs_alloc_key_t *) \ |
92 | ((char *)(block) + \ | ||
93 | sizeof(struct xfs_btree_sblock) + \ | ||
94 | ((index) - 1) * sizeof(xfs_alloc_key_t))) | ||
90 | 95 | ||
96 | #define XFS_ALLOC_PTR_ADDR(mp, block, index, maxrecs) \ | ||
97 | ((xfs_alloc_ptr_t *) \ | ||
98 | ((char *)(block) + \ | ||
99 | sizeof(struct xfs_btree_sblock) + \ | ||
100 | (maxrecs) * sizeof(xfs_alloc_key_t) + \ | ||
101 | ((index) - 1) * sizeof(xfs_alloc_ptr_t))) | ||
91 | 102 | ||
92 | extern struct xfs_btree_cur *xfs_allocbt_init_cursor(struct xfs_mount *, | 103 | extern struct xfs_btree_cur *xfs_allocbt_init_cursor(struct xfs_mount *, |
93 | struct xfs_trans *, struct xfs_buf *, | 104 | struct xfs_trans *, struct xfs_buf *, |
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c index 09e4de4ed507..3dab937d4b85 100644 --- a/fs/xfs/xfs_bmap.c +++ b/fs/xfs/xfs_bmap.c | |||
@@ -393,7 +393,7 @@ xfs_bmap_count_leaves( | |||
393 | 393 | ||
394 | STATIC void | 394 | STATIC void |
395 | xfs_bmap_disk_count_leaves( | 395 | xfs_bmap_disk_count_leaves( |
396 | xfs_extnum_t idx, | 396 | struct xfs_mount *mp, |
397 | xfs_bmbt_block_t *block, | 397 | xfs_bmbt_block_t *block, |
398 | int numrecs, | 398 | int numrecs, |
399 | int *count); | 399 | int *count); |
@@ -3539,7 +3539,7 @@ xfs_bmap_extents_to_btree( | |||
3539 | ablock->bb_level = 0; | 3539 | ablock->bb_level = 0; |
3540 | ablock->bb_leftsib = cpu_to_be64(NULLDFSBNO); | 3540 | ablock->bb_leftsib = cpu_to_be64(NULLDFSBNO); |
3541 | ablock->bb_rightsib = cpu_to_be64(NULLDFSBNO); | 3541 | ablock->bb_rightsib = cpu_to_be64(NULLDFSBNO); |
3542 | arp = XFS_BMAP_REC_IADDR(ablock, 1, cur); | 3542 | arp = XFS_BMBT_REC_ADDR(mp, ablock, 1); |
3543 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); | 3543 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); |
3544 | for (cnt = i = 0; i < nextents; i++) { | 3544 | for (cnt = i = 0; i < nextents; i++) { |
3545 | ep = xfs_iext_get_ext(ifp, i); | 3545 | ep = xfs_iext_get_ext(ifp, i); |
@@ -3554,11 +3554,13 @@ xfs_bmap_extents_to_btree( | |||
3554 | /* | 3554 | /* |
3555 | * Fill in the root key and pointer. | 3555 | * Fill in the root key and pointer. |
3556 | */ | 3556 | */ |
3557 | kp = XFS_BMAP_KEY_IADDR(block, 1, cur); | 3557 | kp = XFS_BMBT_KEY_ADDR(mp, block, 1); |
3558 | arp = XFS_BMAP_REC_IADDR(ablock, 1, cur); | 3558 | arp = XFS_BMBT_REC_ADDR(mp, ablock, 1); |
3559 | kp->br_startoff = cpu_to_be64(xfs_bmbt_disk_get_startoff(arp)); | 3559 | kp->br_startoff = cpu_to_be64(xfs_bmbt_disk_get_startoff(arp)); |
3560 | pp = XFS_BMAP_PTR_IADDR(block, 1, cur); | 3560 | pp = XFS_BMBT_PTR_ADDR(mp, block, 1, xfs_bmbt_get_maxrecs(cur, |
3561 | be16_to_cpu(block->bb_level))); | ||
3561 | *pp = cpu_to_be64(args.fsbno); | 3562 | *pp = cpu_to_be64(args.fsbno); |
3563 | |||
3562 | /* | 3564 | /* |
3563 | * Do all this logging at the end so that | 3565 | * Do all this logging at the end so that |
3564 | * the root is at the right level. | 3566 | * the root is at the right level. |
@@ -4574,7 +4576,7 @@ xfs_bmap_read_extents( | |||
4574 | error0); | 4576 | error0); |
4575 | if (level == 0) | 4577 | if (level == 0) |
4576 | break; | 4578 | break; |
4577 | pp = XFS_BTREE_PTR_ADDR(xfs_bmbt, block, 1, mp->m_bmap_dmxr[1]); | 4579 | pp = XFS_BMBT_PTR_ADDR(mp, block, 1, mp->m_bmap_dmxr[1]); |
4578 | bno = be64_to_cpu(*pp); | 4580 | bno = be64_to_cpu(*pp); |
4579 | XFS_WANT_CORRUPTED_GOTO(XFS_FSB_SANITY_CHECK(mp, bno), error0); | 4581 | XFS_WANT_CORRUPTED_GOTO(XFS_FSB_SANITY_CHECK(mp, bno), error0); |
4580 | xfs_trans_brelse(tp, bp); | 4582 | xfs_trans_brelse(tp, bp); |
@@ -4617,7 +4619,7 @@ xfs_bmap_read_extents( | |||
4617 | /* | 4619 | /* |
4618 | * Copy records into the extent records. | 4620 | * Copy records into the extent records. |
4619 | */ | 4621 | */ |
4620 | frp = XFS_BTREE_REC_ADDR(xfs_bmbt, block, 1); | 4622 | frp = XFS_BMBT_REC_ADDR(mp, block, 1); |
4621 | start = i; | 4623 | start = i; |
4622 | for (j = 0; j < num_recs; j++, i++, frp++) { | 4624 | for (j = 0; j < num_recs; j++, i++, frp++) { |
4623 | xfs_bmbt_rec_host_t *trp = xfs_iext_get_ext(ifp, i); | 4625 | xfs_bmbt_rec_host_t *trp = xfs_iext_get_ext(ifp, i); |
@@ -6187,12 +6189,7 @@ xfs_check_block( | |||
6187 | prevp = NULL; | 6189 | prevp = NULL; |
6188 | for( i = 1; i <= be16_to_cpu(block->bb_numrecs); i++) { | 6190 | for( i = 1; i <= be16_to_cpu(block->bb_numrecs); i++) { |
6189 | dmxr = mp->m_bmap_dmxr[0]; | 6191 | dmxr = mp->m_bmap_dmxr[0]; |
6190 | 6192 | keyp = XFS_BMBT_KEY_ADDR(mp, block, i); | |
6191 | if (root) { | ||
6192 | keyp = XFS_BMAP_BROOT_KEY_ADDR(block, i, sz); | ||
6193 | } else { | ||
6194 | keyp = XFS_BTREE_KEY_ADDR(xfs_bmbt, block, i); | ||
6195 | } | ||
6196 | 6193 | ||
6197 | if (prevp) { | 6194 | if (prevp) { |
6198 | ASSERT(be64_to_cpu(prevp->br_startoff) < | 6195 | ASSERT(be64_to_cpu(prevp->br_startoff) < |
@@ -6203,19 +6200,16 @@ xfs_check_block( | |||
6203 | /* | 6200 | /* |
6204 | * Compare the block numbers to see if there are dups. | 6201 | * Compare the block numbers to see if there are dups. |
6205 | */ | 6202 | */ |
6206 | 6203 | if (root) | |
6207 | if (root) { | ||
6208 | pp = XFS_BMAP_BROOT_PTR_ADDR(mp, block, i, sz); | 6204 | pp = XFS_BMAP_BROOT_PTR_ADDR(mp, block, i, sz); |
6209 | } else { | 6205 | else |
6210 | pp = XFS_BTREE_PTR_ADDR(xfs_bmbt, block, i, dmxr); | 6206 | pp = XFS_BMBT_PTR_ADDR(mp, block, i, dmxr); |
6211 | } | 6207 | |
6212 | for (j = i+1; j <= be16_to_cpu(block->bb_numrecs); j++) { | 6208 | for (j = i+1; j <= be16_to_cpu(block->bb_numrecs); j++) { |
6213 | if (root) { | 6209 | if (root) |
6214 | thispa = XFS_BMAP_BROOT_PTR_ADDR(mp, block, j, sz); | 6210 | thispa = XFS_BMAP_BROOT_PTR_ADDR(mp, block, j, sz); |
6215 | } else { | 6211 | else |
6216 | thispa = XFS_BTREE_PTR_ADDR(xfs_bmbt, block, j, | 6212 | thispa = XFS_BMBT_PTR_ADDR(mp, block, j, dmxr); |
6217 | dmxr); | ||
6218 | } | ||
6219 | if (*thispa == *pp) { | 6213 | if (*thispa == *pp) { |
6220 | cmn_err(CE_WARN, "%s: thispa(%d) == pp(%d) %Ld", | 6214 | cmn_err(CE_WARN, "%s: thispa(%d) == pp(%d) %Ld", |
6221 | __func__, j, i, | 6215 | __func__, j, i, |
@@ -6301,7 +6295,7 @@ xfs_bmap_check_leaf_extents( | |||
6301 | */ | 6295 | */ |
6302 | 6296 | ||
6303 | xfs_check_block(block, mp, 0, 0); | 6297 | xfs_check_block(block, mp, 0, 0); |
6304 | pp = XFS_BTREE_PTR_ADDR(xfs_bmbt, block, 1, mp->m_bmap_dmxr[1]); | 6298 | pp = XFS_BMBT_PTR_ADDR(mp, block, 1, mp->m_bmap_dmxr[1]); |
6305 | bno = be64_to_cpu(*pp); | 6299 | bno = be64_to_cpu(*pp); |
6306 | XFS_WANT_CORRUPTED_GOTO(XFS_FSB_SANITY_CHECK(mp, bno), error0); | 6300 | XFS_WANT_CORRUPTED_GOTO(XFS_FSB_SANITY_CHECK(mp, bno), error0); |
6307 | if (bp_release) { | 6301 | if (bp_release) { |
@@ -6337,14 +6331,14 @@ xfs_bmap_check_leaf_extents( | |||
6337 | * conform with the first entry in this one. | 6331 | * conform with the first entry in this one. |
6338 | */ | 6332 | */ |
6339 | 6333 | ||
6340 | ep = XFS_BTREE_REC_ADDR(xfs_bmbt, block, 1); | 6334 | ep = XFS_BMBT_REC_ADDR(mp, block, 1); |
6341 | if (i) { | 6335 | if (i) { |
6342 | ASSERT(xfs_bmbt_disk_get_startoff(&last) + | 6336 | ASSERT(xfs_bmbt_disk_get_startoff(&last) + |
6343 | xfs_bmbt_disk_get_blockcount(&last) <= | 6337 | xfs_bmbt_disk_get_blockcount(&last) <= |
6344 | xfs_bmbt_disk_get_startoff(ep)); | 6338 | xfs_bmbt_disk_get_startoff(ep)); |
6345 | } | 6339 | } |
6346 | for (j = 1; j < num_recs; j++) { | 6340 | for (j = 1; j < num_recs; j++) { |
6347 | nextp = XFS_BTREE_REC_ADDR(xfs_bmbt, block, j + 1); | 6341 | nextp = XFS_BMBT_REC_ADDR(mp, block, j + 1); |
6348 | ASSERT(xfs_bmbt_disk_get_startoff(ep) + | 6342 | ASSERT(xfs_bmbt_disk_get_startoff(ep) + |
6349 | xfs_bmbt_disk_get_blockcount(ep) <= | 6343 | xfs_bmbt_disk_get_blockcount(ep) <= |
6350 | xfs_bmbt_disk_get_startoff(nextp)); | 6344 | xfs_bmbt_disk_get_startoff(nextp)); |
@@ -6482,7 +6476,7 @@ xfs_bmap_count_tree( | |||
6482 | } | 6476 | } |
6483 | 6477 | ||
6484 | /* Dive to the next level */ | 6478 | /* Dive to the next level */ |
6485 | pp = XFS_BTREE_PTR_ADDR(xfs_bmbt, block, 1, mp->m_bmap_dmxr[1]); | 6479 | pp = XFS_BMBT_PTR_ADDR(mp, block, 1, mp->m_bmap_dmxr[1]); |
6486 | bno = be64_to_cpu(*pp); | 6480 | bno = be64_to_cpu(*pp); |
6487 | if (unlikely((error = | 6481 | if (unlikely((error = |
6488 | xfs_bmap_count_tree(mp, tp, ifp, bno, level, count)) < 0)) { | 6482 | xfs_bmap_count_tree(mp, tp, ifp, bno, level, count)) < 0)) { |
@@ -6497,7 +6491,7 @@ xfs_bmap_count_tree( | |||
6497 | for (;;) { | 6491 | for (;;) { |
6498 | nextbno = be64_to_cpu(block->bb_rightsib); | 6492 | nextbno = be64_to_cpu(block->bb_rightsib); |
6499 | numrecs = be16_to_cpu(block->bb_numrecs); | 6493 | numrecs = be16_to_cpu(block->bb_numrecs); |
6500 | xfs_bmap_disk_count_leaves(0, block, numrecs, count); | 6494 | xfs_bmap_disk_count_leaves(mp, block, numrecs, count); |
6501 | xfs_trans_brelse(tp, bp); | 6495 | xfs_trans_brelse(tp, bp); |
6502 | if (nextbno == NULLFSBLOCK) | 6496 | if (nextbno == NULLFSBLOCK) |
6503 | break; | 6497 | break; |
@@ -6536,7 +6530,7 @@ xfs_bmap_count_leaves( | |||
6536 | */ | 6530 | */ |
6537 | STATIC void | 6531 | STATIC void |
6538 | xfs_bmap_disk_count_leaves( | 6532 | xfs_bmap_disk_count_leaves( |
6539 | xfs_extnum_t idx, | 6533 | struct xfs_mount *mp, |
6540 | xfs_bmbt_block_t *block, | 6534 | xfs_bmbt_block_t *block, |
6541 | int numrecs, | 6535 | int numrecs, |
6542 | int *count) | 6536 | int *count) |
@@ -6545,7 +6539,7 @@ xfs_bmap_disk_count_leaves( | |||
6545 | xfs_bmbt_rec_t *frp; | 6539 | xfs_bmbt_rec_t *frp; |
6546 | 6540 | ||
6547 | for (b = 1; b <= numrecs; b++) { | 6541 | for (b = 1; b <= numrecs; b++) { |
6548 | frp = XFS_BTREE_REC_ADDR(xfs_bmbt, block, idx + b); | 6542 | frp = XFS_BMBT_REC_ADDR(mp, block, b); |
6549 | *count += xfs_bmbt_disk_get_blockcount(frp); | 6543 | *count += xfs_bmbt_disk_get_blockcount(frp); |
6550 | } | 6544 | } |
6551 | } | 6545 | } |
diff --git a/fs/xfs/xfs_bmap_btree.c b/fs/xfs/xfs_bmap_btree.c index 853828c6b45e..11137c042c94 100644 --- a/fs/xfs/xfs_bmap_btree.c +++ b/fs/xfs/xfs_bmap_btree.c | |||
@@ -44,7 +44,6 @@ | |||
44 | #include "xfs_error.h" | 44 | #include "xfs_error.h" |
45 | #include "xfs_quota.h" | 45 | #include "xfs_quota.h" |
46 | 46 | ||
47 | |||
48 | /* | 47 | /* |
49 | * Determine the extent state. | 48 | * Determine the extent state. |
50 | */ | 49 | */ |
@@ -85,9 +84,9 @@ xfs_bmdr_to_bmbt( | |||
85 | rblock->bb_leftsib = cpu_to_be64(NULLDFSBNO); | 84 | rblock->bb_leftsib = cpu_to_be64(NULLDFSBNO); |
86 | rblock->bb_rightsib = cpu_to_be64(NULLDFSBNO); | 85 | rblock->bb_rightsib = cpu_to_be64(NULLDFSBNO); |
87 | dmxr = xfs_bmdr_maxrecs(mp, dblocklen, 0); | 86 | dmxr = xfs_bmdr_maxrecs(mp, dblocklen, 0); |
88 | fkp = XFS_BTREE_KEY_ADDR(xfs_bmdr, dblock, 1); | 87 | fkp = XFS_BMDR_KEY_ADDR(dblock, 1); |
89 | tkp = XFS_BMAP_BROOT_KEY_ADDR(rblock, 1, rblocklen); | 88 | tkp = XFS_BMBT_KEY_ADDR(mp, rblock, 1); |
90 | fpp = XFS_BTREE_PTR_ADDR(xfs_bmdr, dblock, 1, dmxr); | 89 | fpp = XFS_BMDR_PTR_ADDR(dblock, 1, dmxr); |
91 | tpp = XFS_BMAP_BROOT_PTR_ADDR(mp, rblock, 1, rblocklen); | 90 | tpp = XFS_BMAP_BROOT_PTR_ADDR(mp, rblock, 1, rblocklen); |
92 | dmxr = be16_to_cpu(dblock->bb_numrecs); | 91 | dmxr = be16_to_cpu(dblock->bb_numrecs); |
93 | memcpy(tkp, fkp, sizeof(*fkp) * dmxr); | 92 | memcpy(tkp, fkp, sizeof(*fkp) * dmxr); |
@@ -448,10 +447,10 @@ xfs_bmbt_to_bmdr( | |||
448 | dblock->bb_level = rblock->bb_level; | 447 | dblock->bb_level = rblock->bb_level; |
449 | dblock->bb_numrecs = rblock->bb_numrecs; | 448 | dblock->bb_numrecs = rblock->bb_numrecs; |
450 | dmxr = xfs_bmdr_maxrecs(mp, dblocklen, 0); | 449 | dmxr = xfs_bmdr_maxrecs(mp, dblocklen, 0); |
451 | fkp = XFS_BMAP_BROOT_KEY_ADDR(rblock, 1, rblocklen); | 450 | fkp = XFS_BMBT_KEY_ADDR(mp, rblock, 1); |
452 | tkp = XFS_BTREE_KEY_ADDR(xfs_bmdr, dblock, 1); | 451 | tkp = XFS_BMDR_KEY_ADDR(dblock, 1); |
453 | fpp = XFS_BMAP_BROOT_PTR_ADDR(mp, rblock, 1, rblocklen); | 452 | fpp = XFS_BMAP_BROOT_PTR_ADDR(mp, rblock, 1, rblocklen); |
454 | tpp = XFS_BTREE_PTR_ADDR(xfs_bmdr, dblock, 1, dmxr); | 453 | tpp = XFS_BMDR_PTR_ADDR(dblock, 1, dmxr); |
455 | dmxr = be16_to_cpu(dblock->bb_numrecs); | 454 | dmxr = be16_to_cpu(dblock->bb_numrecs); |
456 | memcpy(tkp, fkp, sizeof(*fkp) * dmxr); | 455 | memcpy(tkp, fkp, sizeof(*fkp) * dmxr); |
457 | memcpy(tpp, fpp, sizeof(*fpp) * dmxr); | 456 | memcpy(tpp, fpp, sizeof(*fpp) * dmxr); |
diff --git a/fs/xfs/xfs_bmap_btree.h b/fs/xfs/xfs_bmap_btree.h index 835be2a84ca1..7f001072db47 100644 --- a/fs/xfs/xfs_bmap_btree.h +++ b/fs/xfs/xfs_bmap_btree.h | |||
@@ -21,6 +21,7 @@ | |||
21 | #define XFS_BMAP_MAGIC 0x424d4150 /* 'BMAP' */ | 21 | #define XFS_BMAP_MAGIC 0x424d4150 /* 'BMAP' */ |
22 | 22 | ||
23 | struct xfs_btree_cur; | 23 | struct xfs_btree_cur; |
24 | struct xfs_btree_block; | ||
24 | struct xfs_btree_lblock; | 25 | struct xfs_btree_lblock; |
25 | struct xfs_mount; | 26 | struct xfs_mount; |
26 | struct xfs_inode; | 27 | struct xfs_inode; |
@@ -151,33 +152,50 @@ typedef struct xfs_btree_lblock xfs_bmbt_block_t; | |||
151 | 152 | ||
152 | #define XFS_BUF_TO_BMBT_BLOCK(bp) ((xfs_bmbt_block_t *)XFS_BUF_PTR(bp)) | 153 | #define XFS_BUF_TO_BMBT_BLOCK(bp) ((xfs_bmbt_block_t *)XFS_BUF_PTR(bp)) |
153 | 154 | ||
154 | #define XFS_BMAP_REC_DADDR(bb,i,cur) (XFS_BTREE_REC_ADDR(xfs_bmbt, bb, i)) | 155 | #define XFS_BMBT_REC_ADDR(mp, block, index) \ |
155 | 156 | ((xfs_bmbt_rec_t *) \ | |
156 | #define XFS_BMAP_REC_IADDR(bb,i,cur) (XFS_BTREE_REC_ADDR(xfs_bmbt, bb, i)) | 157 | ((char *)(block) + \ |
157 | 158 | sizeof(struct xfs_btree_lblock) + \ | |
158 | #define XFS_BMAP_KEY_DADDR(bb,i,cur) \ | 159 | ((index) - 1) * sizeof(xfs_bmbt_rec_t))) |
159 | (XFS_BTREE_KEY_ADDR(xfs_bmbt, bb, i)) | 160 | |
160 | 161 | #define XFS_BMBT_KEY_ADDR(mp, block, index) \ | |
161 | #define XFS_BMAP_KEY_IADDR(bb,i,cur) \ | 162 | ((xfs_bmbt_key_t *) \ |
162 | (XFS_BTREE_KEY_ADDR(xfs_bmbt, bb, i)) | 163 | ((char *)(block) + \ |
163 | 164 | sizeof(struct xfs_btree_lblock) + \ | |
164 | #define XFS_BMAP_PTR_DADDR(bb,i,cur) \ | 165 | ((index) - 1) * sizeof(xfs_bmbt_key_t))) |
165 | (XFS_BTREE_PTR_ADDR(xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \ | 166 | |
166 | be16_to_cpu((bb)->bb_level), cur))) | 167 | #define XFS_BMBT_PTR_ADDR(mp, block, index, maxrecs) \ |
167 | #define XFS_BMAP_PTR_IADDR(bb,i,cur) \ | 168 | ((xfs_bmbt_ptr_t *) \ |
168 | (XFS_BTREE_PTR_ADDR(xfs_bmbt, bb, i, xfs_bmbt_get_maxrecs(cur, \ | 169 | ((char *)(block) + \ |
169 | be16_to_cpu((bb)->bb_level)))) | 170 | sizeof(struct xfs_btree_lblock) + \ |
171 | (maxrecs) * sizeof(xfs_bmbt_key_t) + \ | ||
172 | ((index) - 1) * sizeof(xfs_bmbt_ptr_t))) | ||
173 | |||
174 | #define XFS_BMDR_REC_ADDR(block, index) \ | ||
175 | ((xfs_bmdr_rec_t *) \ | ||
176 | ((char *)(block) + \ | ||
177 | sizeof(struct xfs_bmdr_block) + \ | ||
178 | ((index) - 1) * sizeof(xfs_bmdr_rec_t))) | ||
179 | |||
180 | #define XFS_BMDR_KEY_ADDR(block, index) \ | ||
181 | ((xfs_bmdr_key_t *) \ | ||
182 | ((char *)(block) + \ | ||
183 | sizeof(struct xfs_bmdr_block) + \ | ||
184 | ((index) - 1) * sizeof(xfs_bmdr_key_t))) | ||
185 | |||
186 | #define XFS_BMDR_PTR_ADDR(block, index, maxrecs) \ | ||
187 | ((xfs_bmdr_ptr_t *) \ | ||
188 | ((char *)(block) + \ | ||
189 | sizeof(struct xfs_bmdr_block) + \ | ||
190 | (maxrecs) * sizeof(xfs_bmdr_key_t) + \ | ||
191 | ((index) - 1) * sizeof(xfs_bmdr_ptr_t))) | ||
170 | 192 | ||
171 | /* | 193 | /* |
172 | * These are to be used when we know the size of the block and | 194 | * These are to be used when we know the size of the block and |
173 | * we don't have a cursor. | 195 | * we don't have a cursor. |
174 | */ | 196 | */ |
175 | #define XFS_BMAP_BROOT_REC_ADDR(bb,i,sz) \ | 197 | #define XFS_BMAP_BROOT_PTR_ADDR(mp, bb, i, sz) \ |
176 | (XFS_BTREE_REC_ADDR(xfs_bmbt,bb,i)) | 198 | XFS_BMBT_PTR_ADDR(mp, bb, i, xfs_bmbt_maxrecs(mp, sz, 0)) |
177 | #define XFS_BMAP_BROOT_KEY_ADDR(bb,i,sz) \ | ||
178 | (XFS_BTREE_KEY_ADDR(xfs_bmbt,bb,i)) | ||
179 | #define XFS_BMAP_BROOT_PTR_ADDR(mp, bb,i,sz) \ | ||
180 | (XFS_BTREE_PTR_ADDR(xfs_bmbt,bb,i,xfs_bmbt_maxrecs(mp, sz, 0))) | ||
181 | 199 | ||
182 | #define XFS_BMAP_BROOT_SPACE_CALC(nrecs) \ | 200 | #define XFS_BMAP_BROOT_SPACE_CALC(nrecs) \ |
183 | (int)(sizeof(xfs_bmbt_block_t) + \ | 201 | (int)(sizeof(xfs_bmbt_block_t) + \ |
diff --git a/fs/xfs/xfs_btree.h b/fs/xfs/xfs_btree.h index 795a124cee6f..d6120a749060 100644 --- a/fs/xfs/xfs_btree.h +++ b/fs/xfs/xfs_btree.h | |||
@@ -149,21 +149,6 @@ do { \ | |||
149 | } \ | 149 | } \ |
150 | } while (0) | 150 | } while (0) |
151 | 151 | ||
152 | /* | ||
153 | * Record, key, and pointer address calculation macros. | ||
154 | * Given block size, type prefix, block pointer, and index of requested entry | ||
155 | * (first entry numbered 1). | ||
156 | */ | ||
157 | #define XFS_BTREE_REC_ADDR(t,bb,i) \ | ||
158 | ((t ## _rec_t *)((char *)(bb) + sizeof(t ## _block_t) + \ | ||
159 | ((i) - 1) * sizeof(t ## _rec_t))) | ||
160 | #define XFS_BTREE_KEY_ADDR(t,bb,i) \ | ||
161 | ((t ## _key_t *)((char *)(bb) + sizeof(t ## _block_t) + \ | ||
162 | ((i) - 1) * sizeof(t ## _key_t))) | ||
163 | #define XFS_BTREE_PTR_ADDR(t,bb,i,mxr) \ | ||
164 | ((t ## _ptr_t *)((char *)(bb) + sizeof(t ## _block_t) + \ | ||
165 | (mxr) * sizeof(t ## _key_t) + ((i) - 1) * sizeof(t ## _ptr_t))) | ||
166 | |||
167 | #define XFS_BTREE_MAXLEVELS 8 /* max of all btrees */ | 152 | #define XFS_BTREE_MAXLEVELS 8 /* max of all btrees */ |
168 | 153 | ||
169 | struct xfs_btree_ops { | 154 | struct xfs_btree_ops { |
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index 84583cf73db3..8ce72aba027f 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c | |||
@@ -258,7 +258,7 @@ xfs_growfs_data_private( | |||
258 | block->bb_numrecs = cpu_to_be16(1); | 258 | block->bb_numrecs = cpu_to_be16(1); |
259 | block->bb_leftsib = cpu_to_be32(NULLAGBLOCK); | 259 | block->bb_leftsib = cpu_to_be32(NULLAGBLOCK); |
260 | block->bb_rightsib = cpu_to_be32(NULLAGBLOCK); | 260 | block->bb_rightsib = cpu_to_be32(NULLAGBLOCK); |
261 | arec = XFS_BTREE_REC_ADDR(xfs_alloc, block, 1); | 261 | arec = XFS_ALLOC_REC_ADDR(mp, block, 1); |
262 | arec->ar_startblock = cpu_to_be32(XFS_PREALLOC_BLOCKS(mp)); | 262 | arec->ar_startblock = cpu_to_be32(XFS_PREALLOC_BLOCKS(mp)); |
263 | arec->ar_blockcount = cpu_to_be32( | 263 | arec->ar_blockcount = cpu_to_be32( |
264 | agsize - be32_to_cpu(arec->ar_startblock)); | 264 | agsize - be32_to_cpu(arec->ar_startblock)); |
@@ -279,7 +279,7 @@ xfs_growfs_data_private( | |||
279 | block->bb_numrecs = cpu_to_be16(1); | 279 | block->bb_numrecs = cpu_to_be16(1); |
280 | block->bb_leftsib = cpu_to_be32(NULLAGBLOCK); | 280 | block->bb_leftsib = cpu_to_be32(NULLAGBLOCK); |
281 | block->bb_rightsib = cpu_to_be32(NULLAGBLOCK); | 281 | block->bb_rightsib = cpu_to_be32(NULLAGBLOCK); |
282 | arec = XFS_BTREE_REC_ADDR(xfs_alloc, block, 1); | 282 | arec = XFS_ALLOC_REC_ADDR(mp, block, 1); |
283 | arec->ar_startblock = cpu_to_be32(XFS_PREALLOC_BLOCKS(mp)); | 283 | arec->ar_startblock = cpu_to_be32(XFS_PREALLOC_BLOCKS(mp)); |
284 | arec->ar_blockcount = cpu_to_be32( | 284 | arec->ar_blockcount = cpu_to_be32( |
285 | agsize - be32_to_cpu(arec->ar_startblock)); | 285 | agsize - be32_to_cpu(arec->ar_startblock)); |
diff --git a/fs/xfs/xfs_ialloc_btree.h b/fs/xfs/xfs_ialloc_btree.h index f0fc1e46e62b..fa12c85db340 100644 --- a/fs/xfs/xfs_ialloc_btree.h +++ b/fs/xfs/xfs_ialloc_btree.h | |||
@@ -97,16 +97,27 @@ typedef struct xfs_btree_sblock xfs_inobt_block_t; | |||
97 | 97 | ||
98 | /* | 98 | /* |
99 | * Record, key, and pointer address macros for btree blocks. | 99 | * Record, key, and pointer address macros for btree blocks. |
100 | * | ||
101 | * (note that some of these may appear unused, but they are used in userspace) | ||
100 | */ | 102 | */ |
101 | #define XFS_INOBT_REC_ADDR(bb,i,cur) \ | 103 | #define XFS_INOBT_REC_ADDR(mp, block, index) \ |
102 | (XFS_BTREE_REC_ADDR(xfs_inobt, bb, i)) | 104 | ((xfs_inobt_rec_t *) \ |
103 | 105 | ((char *)(block) + \ | |
104 | #define XFS_INOBT_KEY_ADDR(bb,i,cur) \ | 106 | sizeof(struct xfs_btree_sblock) + \ |
105 | (XFS_BTREE_KEY_ADDR(xfs_inobt, bb, i)) | 107 | (((index) - 1) * sizeof(xfs_inobt_rec_t)))) |
106 | 108 | ||
107 | #define XFS_INOBT_PTR_ADDR(bb,i,cur) \ | 109 | #define XFS_INOBT_KEY_ADDR(mp, block, index) \ |
108 | (XFS_BTREE_PTR_ADDR(xfs_inobt, bb, \ | 110 | ((xfs_inobt_key_t *) \ |
109 | i, XFS_INOBT_BLOCK_MAXRECS(1, cur))) | 111 | ((char *)(block) + \ |
112 | sizeof(struct xfs_btree_sblock) + \ | ||
113 | ((index) - 1) * sizeof(xfs_inobt_key_t))) | ||
114 | |||
115 | #define XFS_INOBT_PTR_ADDR(mp, block, index, maxrecs) \ | ||
116 | ((xfs_inobt_ptr_t *) \ | ||
117 | ((char *)(block) + \ | ||
118 | sizeof(struct xfs_btree_sblock) + \ | ||
119 | (maxrecs) * sizeof(xfs_inobt_key_t) + \ | ||
120 | ((index) - 1) * sizeof(xfs_inobt_ptr_t))) | ||
110 | 121 | ||
111 | extern struct xfs_btree_cur *xfs_inobt_init_cursor(struct xfs_mount *, | 122 | extern struct xfs_btree_cur *xfs_inobt_init_cursor(struct xfs_mount *, |
112 | struct xfs_trans *, struct xfs_buf *, xfs_agnumber_t); | 123 | struct xfs_trans *, struct xfs_buf *, xfs_agnumber_t); |
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 73b604e15dcd..7b4f13c710d6 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c | |||
@@ -2435,10 +2435,8 @@ xfs_iroot_realloc( | |||
2435 | /* | 2435 | /* |
2436 | * First copy the records. | 2436 | * First copy the records. |
2437 | */ | 2437 | */ |
2438 | op = (char *)XFS_BMAP_BROOT_REC_ADDR(ifp->if_broot, 1, | 2438 | op = (char *)XFS_BMBT_REC_ADDR(mp, ifp->if_broot, 1); |
2439 | ifp->if_broot_bytes); | 2439 | np = (char *)XFS_BMBT_REC_ADDR(mp, new_broot, 1); |
2440 | np = (char *)XFS_BMAP_BROOT_REC_ADDR(new_broot, 1, | ||
2441 | (int)new_size); | ||
2442 | memcpy(np, op, new_max * (uint)sizeof(xfs_bmbt_rec_t)); | 2440 | memcpy(np, op, new_max * (uint)sizeof(xfs_bmbt_rec_t)); |
2443 | 2441 | ||
2444 | /* | 2442 | /* |