diff options
Diffstat (limited to 'fs/xfs/xfs_bmap.c')
-rw-r--r-- | fs/xfs/xfs_bmap.c | 71 |
1 files changed, 37 insertions, 34 deletions
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c index 3dab937d4b85..7796a0c140eb 100644 --- a/fs/xfs/xfs_bmap.c +++ b/fs/xfs/xfs_bmap.c | |||
@@ -394,7 +394,7 @@ xfs_bmap_count_leaves( | |||
394 | STATIC void | 394 | STATIC void |
395 | xfs_bmap_disk_count_leaves( | 395 | xfs_bmap_disk_count_leaves( |
396 | struct xfs_mount *mp, | 396 | struct xfs_mount *mp, |
397 | xfs_bmbt_block_t *block, | 397 | struct xfs_btree_block *block, |
398 | int numrecs, | 398 | int numrecs, |
399 | int *count); | 399 | int *count); |
400 | 400 | ||
@@ -3042,14 +3042,14 @@ xfs_bmap_btree_to_extents( | |||
3042 | int whichfork) /* data or attr fork */ | 3042 | int whichfork) /* data or attr fork */ |
3043 | { | 3043 | { |
3044 | /* REFERENCED */ | 3044 | /* REFERENCED */ |
3045 | xfs_bmbt_block_t *cblock;/* child btree block */ | 3045 | struct xfs_btree_block *cblock;/* child btree block */ |
3046 | xfs_fsblock_t cbno; /* child block number */ | 3046 | xfs_fsblock_t cbno; /* child block number */ |
3047 | xfs_buf_t *cbp; /* child block's buffer */ | 3047 | xfs_buf_t *cbp; /* child block's buffer */ |
3048 | int error; /* error return value */ | 3048 | int error; /* error return value */ |
3049 | xfs_ifork_t *ifp; /* inode fork data */ | 3049 | xfs_ifork_t *ifp; /* inode fork data */ |
3050 | xfs_mount_t *mp; /* mount point structure */ | 3050 | xfs_mount_t *mp; /* mount point structure */ |
3051 | __be64 *pp; /* ptr to block address */ | 3051 | __be64 *pp; /* ptr to block address */ |
3052 | xfs_bmbt_block_t *rblock;/* root btree block */ | 3052 | struct xfs_btree_block *rblock;/* root btree block */ |
3053 | 3053 | ||
3054 | mp = ip->i_mount; | 3054 | mp = ip->i_mount; |
3055 | ifp = XFS_IFORK_PTR(ip, whichfork); | 3055 | ifp = XFS_IFORK_PTR(ip, whichfork); |
@@ -3069,8 +3069,8 @@ xfs_bmap_btree_to_extents( | |||
3069 | if ((error = xfs_btree_read_bufl(mp, tp, cbno, 0, &cbp, | 3069 | if ((error = xfs_btree_read_bufl(mp, tp, cbno, 0, &cbp, |
3070 | XFS_BMAP_BTREE_REF))) | 3070 | XFS_BMAP_BTREE_REF))) |
3071 | return error; | 3071 | return error; |
3072 | cblock = XFS_BUF_TO_BMBT_BLOCK(cbp); | 3072 | cblock = XFS_BUF_TO_BLOCK(cbp); |
3073 | if ((error = xfs_btree_check_lblock(cur, cblock, 0, cbp))) | 3073 | if ((error = xfs_btree_check_block(cur, cblock, 0, cbp))) |
3074 | return error; | 3074 | return error; |
3075 | xfs_bmap_add_free(cbno, 1, cur->bc_private.b.flist, mp); | 3075 | xfs_bmap_add_free(cbno, 1, cur->bc_private.b.flist, mp); |
3076 | ip->i_d.di_nblocks--; | 3076 | ip->i_d.di_nblocks--; |
@@ -3450,11 +3450,11 @@ xfs_bmap_extents_to_btree( | |||
3450 | int *logflagsp, /* inode logging flags */ | 3450 | int *logflagsp, /* inode logging flags */ |
3451 | int whichfork) /* data or attr fork */ | 3451 | int whichfork) /* data or attr fork */ |
3452 | { | 3452 | { |
3453 | xfs_bmbt_block_t *ablock; /* allocated (child) bt block */ | 3453 | struct xfs_btree_block *ablock; /* allocated (child) bt block */ |
3454 | xfs_buf_t *abp; /* buffer for ablock */ | 3454 | xfs_buf_t *abp; /* buffer for ablock */ |
3455 | xfs_alloc_arg_t args; /* allocation arguments */ | 3455 | xfs_alloc_arg_t args; /* allocation arguments */ |
3456 | xfs_bmbt_rec_t *arp; /* child record pointer */ | 3456 | xfs_bmbt_rec_t *arp; /* child record pointer */ |
3457 | xfs_bmbt_block_t *block; /* btree root block */ | 3457 | struct xfs_btree_block *block; /* btree root block */ |
3458 | xfs_btree_cur_t *cur; /* bmap btree cursor */ | 3458 | xfs_btree_cur_t *cur; /* bmap btree cursor */ |
3459 | xfs_bmbt_rec_host_t *ep; /* extent record pointer */ | 3459 | xfs_bmbt_rec_host_t *ep; /* extent record pointer */ |
3460 | int error; /* error return value */ | 3460 | int error; /* error return value */ |
@@ -3474,6 +3474,7 @@ xfs_bmap_extents_to_btree( | |||
3474 | */ | 3474 | */ |
3475 | xfs_iroot_realloc(ip, 1, whichfork); | 3475 | xfs_iroot_realloc(ip, 1, whichfork); |
3476 | ifp->if_flags |= XFS_IFBROOT; | 3476 | ifp->if_flags |= XFS_IFBROOT; |
3477 | |||
3477 | /* | 3478 | /* |
3478 | * Fill in the root. | 3479 | * Fill in the root. |
3479 | */ | 3480 | */ |
@@ -3481,8 +3482,9 @@ xfs_bmap_extents_to_btree( | |||
3481 | block->bb_magic = cpu_to_be32(XFS_BMAP_MAGIC); | 3482 | block->bb_magic = cpu_to_be32(XFS_BMAP_MAGIC); |
3482 | block->bb_level = cpu_to_be16(1); | 3483 | block->bb_level = cpu_to_be16(1); |
3483 | block->bb_numrecs = cpu_to_be16(1); | 3484 | block->bb_numrecs = cpu_to_be16(1); |
3484 | block->bb_leftsib = cpu_to_be64(NULLDFSBNO); | 3485 | block->bb_u.l.bb_leftsib = cpu_to_be64(NULLDFSBNO); |
3485 | block->bb_rightsib = cpu_to_be64(NULLDFSBNO); | 3486 | block->bb_u.l.bb_rightsib = cpu_to_be64(NULLDFSBNO); |
3487 | |||
3486 | /* | 3488 | /* |
3487 | * Need a cursor. Can't allocate until bb_level is filled in. | 3489 | * Need a cursor. Can't allocate until bb_level is filled in. |
3488 | */ | 3490 | */ |
@@ -3534,11 +3536,11 @@ xfs_bmap_extents_to_btree( | |||
3534 | /* | 3536 | /* |
3535 | * Fill in the child block. | 3537 | * Fill in the child block. |
3536 | */ | 3538 | */ |
3537 | ablock = XFS_BUF_TO_BMBT_BLOCK(abp); | 3539 | ablock = XFS_BUF_TO_BLOCK(abp); |
3538 | ablock->bb_magic = cpu_to_be32(XFS_BMAP_MAGIC); | 3540 | ablock->bb_magic = cpu_to_be32(XFS_BMAP_MAGIC); |
3539 | ablock->bb_level = 0; | 3541 | ablock->bb_level = 0; |
3540 | ablock->bb_leftsib = cpu_to_be64(NULLDFSBNO); | 3542 | ablock->bb_u.l.bb_leftsib = cpu_to_be64(NULLDFSBNO); |
3541 | ablock->bb_rightsib = cpu_to_be64(NULLDFSBNO); | 3543 | ablock->bb_u.l.bb_rightsib = cpu_to_be64(NULLDFSBNO); |
3542 | arp = XFS_BMBT_REC_ADDR(mp, ablock, 1); | 3544 | arp = XFS_BMBT_REC_ADDR(mp, ablock, 1); |
3543 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); | 3545 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); |
3544 | for (cnt = i = 0; i < nextents; i++) { | 3546 | for (cnt = i = 0; i < nextents; i++) { |
@@ -3550,7 +3552,8 @@ xfs_bmap_extents_to_btree( | |||
3550 | } | 3552 | } |
3551 | } | 3553 | } |
3552 | ASSERT(cnt == XFS_IFORK_NEXTENTS(ip, whichfork)); | 3554 | ASSERT(cnt == XFS_IFORK_NEXTENTS(ip, whichfork)); |
3553 | ablock->bb_numrecs = cpu_to_be16(cnt); | 3555 | xfs_btree_set_numrecs(ablock, cnt); |
3556 | |||
3554 | /* | 3557 | /* |
3555 | * Fill in the root key and pointer. | 3558 | * Fill in the root key and pointer. |
3556 | */ | 3559 | */ |
@@ -4533,7 +4536,7 @@ xfs_bmap_read_extents( | |||
4533 | xfs_inode_t *ip, /* incore inode */ | 4536 | xfs_inode_t *ip, /* incore inode */ |
4534 | int whichfork) /* data or attr fork */ | 4537 | int whichfork) /* data or attr fork */ |
4535 | { | 4538 | { |
4536 | xfs_bmbt_block_t *block; /* current btree block */ | 4539 | struct xfs_btree_block *block; /* current btree block */ |
4537 | xfs_fsblock_t bno; /* block # of "block" */ | 4540 | xfs_fsblock_t bno; /* block # of "block" */ |
4538 | xfs_buf_t *bp; /* buffer for "block" */ | 4541 | xfs_buf_t *bp; /* buffer for "block" */ |
4539 | int error; /* error return value */ | 4542 | int error; /* error return value */ |
@@ -4570,7 +4573,7 @@ xfs_bmap_read_extents( | |||
4570 | if ((error = xfs_btree_read_bufl(mp, tp, bno, 0, &bp, | 4573 | if ((error = xfs_btree_read_bufl(mp, tp, bno, 0, &bp, |
4571 | XFS_BMAP_BTREE_REF))) | 4574 | XFS_BMAP_BTREE_REF))) |
4572 | return error; | 4575 | return error; |
4573 | block = XFS_BUF_TO_BMBT_BLOCK(bp); | 4576 | block = XFS_BUF_TO_BLOCK(bp); |
4574 | XFS_WANT_CORRUPTED_GOTO( | 4577 | XFS_WANT_CORRUPTED_GOTO( |
4575 | XFS_BMAP_SANITY_CHECK(mp, block, level), | 4578 | XFS_BMAP_SANITY_CHECK(mp, block, level), |
4576 | error0); | 4579 | error0); |
@@ -4596,7 +4599,7 @@ xfs_bmap_read_extents( | |||
4596 | xfs_extnum_t start; | 4599 | xfs_extnum_t start; |
4597 | 4600 | ||
4598 | 4601 | ||
4599 | num_recs = be16_to_cpu(block->bb_numrecs); | 4602 | num_recs = xfs_btree_get_numrecs(block); |
4600 | if (unlikely(i + num_recs > room)) { | 4603 | if (unlikely(i + num_recs > room)) { |
4601 | ASSERT(i + num_recs <= room); | 4604 | ASSERT(i + num_recs <= room); |
4602 | xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, | 4605 | xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount, |
@@ -4613,7 +4616,7 @@ xfs_bmap_read_extents( | |||
4613 | /* | 4616 | /* |
4614 | * Read-ahead the next leaf block, if any. | 4617 | * Read-ahead the next leaf block, if any. |
4615 | */ | 4618 | */ |
4616 | nextbno = be64_to_cpu(block->bb_rightsib); | 4619 | nextbno = be64_to_cpu(block->bb_u.l.bb_rightsib); |
4617 | if (nextbno != NULLFSBLOCK) | 4620 | if (nextbno != NULLFSBLOCK) |
4618 | xfs_btree_reada_bufl(mp, nextbno, 1); | 4621 | xfs_btree_reada_bufl(mp, nextbno, 1); |
4619 | /* | 4622 | /* |
@@ -4650,7 +4653,7 @@ xfs_bmap_read_extents( | |||
4650 | if ((error = xfs_btree_read_bufl(mp, tp, bno, 0, &bp, | 4653 | if ((error = xfs_btree_read_bufl(mp, tp, bno, 0, &bp, |
4651 | XFS_BMAP_BTREE_REF))) | 4654 | XFS_BMAP_BTREE_REF))) |
4652 | return error; | 4655 | return error; |
4653 | block = XFS_BUF_TO_BMBT_BLOCK(bp); | 4656 | block = XFS_BUF_TO_BLOCK(bp); |
4654 | } | 4657 | } |
4655 | ASSERT(i == (ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t))); | 4658 | ASSERT(i == (ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t))); |
4656 | ASSERT(i == XFS_IFORK_NEXTENTS(ip, whichfork)); | 4659 | ASSERT(i == XFS_IFORK_NEXTENTS(ip, whichfork)); |
@@ -6175,7 +6178,7 @@ xfs_bmap_get_bp( | |||
6175 | 6178 | ||
6176 | void | 6179 | void |
6177 | xfs_check_block( | 6180 | xfs_check_block( |
6178 | xfs_bmbt_block_t *block, | 6181 | struct xfs_btree_block *block, |
6179 | xfs_mount_t *mp, | 6182 | xfs_mount_t *mp, |
6180 | int root, | 6183 | int root, |
6181 | short sz) | 6184 | short sz) |
@@ -6187,7 +6190,7 @@ xfs_check_block( | |||
6187 | ASSERT(be16_to_cpu(block->bb_level) > 0); | 6190 | ASSERT(be16_to_cpu(block->bb_level) > 0); |
6188 | 6191 | ||
6189 | prevp = NULL; | 6192 | prevp = NULL; |
6190 | for( i = 1; i <= be16_to_cpu(block->bb_numrecs); i++) { | 6193 | for( i = 1; i <= xfs_btree_get_numrecs(block); i++) { |
6191 | dmxr = mp->m_bmap_dmxr[0]; | 6194 | dmxr = mp->m_bmap_dmxr[0]; |
6192 | keyp = XFS_BMBT_KEY_ADDR(mp, block, i); | 6195 | keyp = XFS_BMBT_KEY_ADDR(mp, block, i); |
6193 | 6196 | ||
@@ -6232,7 +6235,7 @@ xfs_bmap_check_leaf_extents( | |||
6232 | xfs_inode_t *ip, /* incore inode pointer */ | 6235 | xfs_inode_t *ip, /* incore inode pointer */ |
6233 | int whichfork) /* data or attr fork */ | 6236 | int whichfork) /* data or attr fork */ |
6234 | { | 6237 | { |
6235 | xfs_bmbt_block_t *block; /* current btree block */ | 6238 | struct xfs_btree_block *block; /* current btree block */ |
6236 | xfs_fsblock_t bno; /* block # of "block" */ | 6239 | xfs_fsblock_t bno; /* block # of "block" */ |
6237 | xfs_buf_t *bp; /* buffer for "block" */ | 6240 | xfs_buf_t *bp; /* buffer for "block" */ |
6238 | int error; /* error return value */ | 6241 | int error; /* error return value */ |
@@ -6282,7 +6285,7 @@ xfs_bmap_check_leaf_extents( | |||
6282 | if (!bp && (error = xfs_btree_read_bufl(mp, NULL, bno, 0, &bp, | 6285 | if (!bp && (error = xfs_btree_read_bufl(mp, NULL, bno, 0, &bp, |
6283 | XFS_BMAP_BTREE_REF))) | 6286 | XFS_BMAP_BTREE_REF))) |
6284 | goto error_norelse; | 6287 | goto error_norelse; |
6285 | block = XFS_BUF_TO_BMBT_BLOCK(bp); | 6288 | block = XFS_BUF_TO_BLOCK(bp); |
6286 | XFS_WANT_CORRUPTED_GOTO( | 6289 | XFS_WANT_CORRUPTED_GOTO( |
6287 | XFS_BMAP_SANITY_CHECK(mp, block, level), | 6290 | XFS_BMAP_SANITY_CHECK(mp, block, level), |
6288 | error0); | 6291 | error0); |
@@ -6317,13 +6320,13 @@ xfs_bmap_check_leaf_extents( | |||
6317 | xfs_extnum_t num_recs; | 6320 | xfs_extnum_t num_recs; |
6318 | 6321 | ||
6319 | 6322 | ||
6320 | num_recs = be16_to_cpu(block->bb_numrecs); | 6323 | num_recs = xfs_btree_get_numrecs(block); |
6321 | 6324 | ||
6322 | /* | 6325 | /* |
6323 | * Read-ahead the next leaf block, if any. | 6326 | * Read-ahead the next leaf block, if any. |
6324 | */ | 6327 | */ |
6325 | 6328 | ||
6326 | nextbno = be64_to_cpu(block->bb_rightsib); | 6329 | nextbno = be64_to_cpu(block->bb_u.l.bb_rightsib); |
6327 | 6330 | ||
6328 | /* | 6331 | /* |
6329 | * Check all the extents to make sure they are OK. | 6332 | * Check all the extents to make sure they are OK. |
@@ -6367,7 +6370,7 @@ xfs_bmap_check_leaf_extents( | |||
6367 | if (!bp && (error = xfs_btree_read_bufl(mp, NULL, bno, 0, &bp, | 6370 | if (!bp && (error = xfs_btree_read_bufl(mp, NULL, bno, 0, &bp, |
6368 | XFS_BMAP_BTREE_REF))) | 6371 | XFS_BMAP_BTREE_REF))) |
6369 | goto error_norelse; | 6372 | goto error_norelse; |
6370 | block = XFS_BUF_TO_BMBT_BLOCK(bp); | 6373 | block = XFS_BUF_TO_BLOCK(bp); |
6371 | } | 6374 | } |
6372 | if (bp_release) { | 6375 | if (bp_release) { |
6373 | bp_release = 0; | 6376 | bp_release = 0; |
@@ -6397,7 +6400,7 @@ xfs_bmap_count_blocks( | |||
6397 | int whichfork, /* data or attr fork */ | 6400 | int whichfork, /* data or attr fork */ |
6398 | int *count) /* out: count of blocks */ | 6401 | int *count) /* out: count of blocks */ |
6399 | { | 6402 | { |
6400 | xfs_bmbt_block_t *block; /* current btree block */ | 6403 | struct xfs_btree_block *block; /* current btree block */ |
6401 | xfs_fsblock_t bno; /* block # of "block" */ | 6404 | xfs_fsblock_t bno; /* block # of "block" */ |
6402 | xfs_ifork_t *ifp; /* fork structure */ | 6405 | xfs_ifork_t *ifp; /* fork structure */ |
6403 | int level; /* btree level, for checking */ | 6406 | int level; /* btree level, for checking */ |
@@ -6454,24 +6457,24 @@ xfs_bmap_count_tree( | |||
6454 | __be64 *pp; | 6457 | __be64 *pp; |
6455 | xfs_fsblock_t bno = blockno; | 6458 | xfs_fsblock_t bno = blockno; |
6456 | xfs_fsblock_t nextbno; | 6459 | xfs_fsblock_t nextbno; |
6457 | xfs_bmbt_block_t *block, *nextblock; | 6460 | struct xfs_btree_block *block, *nextblock; |
6458 | int numrecs; | 6461 | int numrecs; |
6459 | 6462 | ||
6460 | if ((error = xfs_btree_read_bufl(mp, tp, bno, 0, &bp, XFS_BMAP_BTREE_REF))) | 6463 | if ((error = xfs_btree_read_bufl(mp, tp, bno, 0, &bp, XFS_BMAP_BTREE_REF))) |
6461 | return error; | 6464 | return error; |
6462 | *count += 1; | 6465 | *count += 1; |
6463 | block = XFS_BUF_TO_BMBT_BLOCK(bp); | 6466 | block = XFS_BUF_TO_BLOCK(bp); |
6464 | 6467 | ||
6465 | if (--level) { | 6468 | if (--level) { |
6466 | /* Not at node above leafs, count this level of nodes */ | 6469 | /* Not at node above leafs, count this level of nodes */ |
6467 | nextbno = be64_to_cpu(block->bb_rightsib); | 6470 | nextbno = be64_to_cpu(block->bb_u.l.bb_rightsib); |
6468 | while (nextbno != NULLFSBLOCK) { | 6471 | while (nextbno != NULLFSBLOCK) { |
6469 | if ((error = xfs_btree_read_bufl(mp, tp, nextbno, | 6472 | if ((error = xfs_btree_read_bufl(mp, tp, nextbno, |
6470 | 0, &nbp, XFS_BMAP_BTREE_REF))) | 6473 | 0, &nbp, XFS_BMAP_BTREE_REF))) |
6471 | return error; | 6474 | return error; |
6472 | *count += 1; | 6475 | *count += 1; |
6473 | nextblock = XFS_BUF_TO_BMBT_BLOCK(nbp); | 6476 | nextblock = XFS_BUF_TO_BLOCK(nbp); |
6474 | nextbno = be64_to_cpu(nextblock->bb_rightsib); | 6477 | nextbno = be64_to_cpu(nextblock->bb_u.l.bb_rightsib); |
6475 | xfs_trans_brelse(tp, nbp); | 6478 | xfs_trans_brelse(tp, nbp); |
6476 | } | 6479 | } |
6477 | 6480 | ||
@@ -6489,7 +6492,7 @@ xfs_bmap_count_tree( | |||
6489 | } else { | 6492 | } else { |
6490 | /* count all level 1 nodes and their leaves */ | 6493 | /* count all level 1 nodes and their leaves */ |
6491 | for (;;) { | 6494 | for (;;) { |
6492 | nextbno = be64_to_cpu(block->bb_rightsib); | 6495 | nextbno = be64_to_cpu(block->bb_u.l.bb_rightsib); |
6493 | numrecs = be16_to_cpu(block->bb_numrecs); | 6496 | numrecs = be16_to_cpu(block->bb_numrecs); |
6494 | xfs_bmap_disk_count_leaves(mp, block, numrecs, count); | 6497 | xfs_bmap_disk_count_leaves(mp, block, numrecs, count); |
6495 | xfs_trans_brelse(tp, bp); | 6498 | xfs_trans_brelse(tp, bp); |
@@ -6500,7 +6503,7 @@ xfs_bmap_count_tree( | |||
6500 | XFS_BMAP_BTREE_REF))) | 6503 | XFS_BMAP_BTREE_REF))) |
6501 | return error; | 6504 | return error; |
6502 | *count += 1; | 6505 | *count += 1; |
6503 | block = XFS_BUF_TO_BMBT_BLOCK(bp); | 6506 | block = XFS_BUF_TO_BLOCK(bp); |
6504 | } | 6507 | } |
6505 | } | 6508 | } |
6506 | return 0; | 6509 | return 0; |
@@ -6531,7 +6534,7 @@ xfs_bmap_count_leaves( | |||
6531 | STATIC void | 6534 | STATIC void |
6532 | xfs_bmap_disk_count_leaves( | 6535 | xfs_bmap_disk_count_leaves( |
6533 | struct xfs_mount *mp, | 6536 | struct xfs_mount *mp, |
6534 | xfs_bmbt_block_t *block, | 6537 | struct xfs_btree_block *block, |
6535 | int numrecs, | 6538 | int numrecs, |
6536 | int *count) | 6539 | int *count) |
6537 | { | 6540 | { |