aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_bmap.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2008-10-30 02:11:40 -0400
committerLachlan McIlroy <lachlan@sgi.com>2008-10-30 02:11:40 -0400
commit136341b41ad4883bd668120f727a52c42331fe8a (patch)
tree0cb1b220073948f2632911354a828606a9e276bb /fs/xfs/xfs_bmap.c
parent6c7699c047c50403149ad91331dd39de47dea070 (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/xfs/xfs_bmap.c')
-rw-r--r--fs/xfs/xfs_bmap.c54
1 files changed, 24 insertions, 30 deletions
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
394STATIC void 394STATIC void
395xfs_bmap_disk_count_leaves( 395xfs_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 */
6537STATIC void 6531STATIC void
6538xfs_bmap_disk_count_leaves( 6532xfs_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}