diff options
Diffstat (limited to 'fs/xfs/xfs_bmap.c')
-rw-r--r-- | fs/xfs/xfs_bmap.c | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c index b1efb906dbbd..76fe9ffb218e 100644 --- a/fs/xfs/xfs_bmap.c +++ b/fs/xfs/xfs_bmap.c | |||
@@ -2999,7 +2999,7 @@ xfs_bmap_btree_to_extents( | |||
2999 | int error; /* error return value */ | 2999 | int error; /* error return value */ |
3000 | xfs_ifork_t *ifp; /* inode fork data */ | 3000 | xfs_ifork_t *ifp; /* inode fork data */ |
3001 | xfs_mount_t *mp; /* mount point structure */ | 3001 | xfs_mount_t *mp; /* mount point structure */ |
3002 | xfs_bmbt_ptr_t *pp; /* ptr to block address */ | 3002 | __be64 *pp; /* ptr to block address */ |
3003 | xfs_bmbt_block_t *rblock;/* root btree block */ | 3003 | xfs_bmbt_block_t *rblock;/* root btree block */ |
3004 | 3004 | ||
3005 | ifp = XFS_IFORK_PTR(ip, whichfork); | 3005 | ifp = XFS_IFORK_PTR(ip, whichfork); |
@@ -3011,12 +3011,12 @@ xfs_bmap_btree_to_extents( | |||
3011 | ASSERT(XFS_BMAP_BROOT_MAXRECS(ifp->if_broot_bytes) == 1); | 3011 | ASSERT(XFS_BMAP_BROOT_MAXRECS(ifp->if_broot_bytes) == 1); |
3012 | mp = ip->i_mount; | 3012 | mp = ip->i_mount; |
3013 | pp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, ifp->if_broot_bytes); | 3013 | pp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, ifp->if_broot_bytes); |
3014 | cbno = be64_to_cpu(*pp); | ||
3014 | *logflagsp = 0; | 3015 | *logflagsp = 0; |
3015 | #ifdef DEBUG | 3016 | #ifdef DEBUG |
3016 | if ((error = xfs_btree_check_lptr_disk(cur, *pp, 1))) | 3017 | if ((error = xfs_btree_check_lptr(cur, cbno, 1))) |
3017 | return error; | 3018 | return error; |
3018 | #endif | 3019 | #endif |
3019 | cbno = INT_GET(*pp, ARCH_CONVERT); | ||
3020 | if ((error = xfs_btree_read_bufl(mp, tp, cbno, 0, &cbp, | 3020 | if ((error = xfs_btree_read_bufl(mp, tp, cbno, 0, &cbp, |
3021 | XFS_BMAP_BTREE_REF))) | 3021 | XFS_BMAP_BTREE_REF))) |
3022 | return error; | 3022 | return error; |
@@ -3514,7 +3514,7 @@ xfs_bmap_extents_to_btree( | |||
3514 | arp = XFS_BMAP_REC_IADDR(ablock, 1, cur); | 3514 | arp = XFS_BMAP_REC_IADDR(ablock, 1, cur); |
3515 | INT_SET(kp->br_startoff, ARCH_CONVERT, xfs_bmbt_disk_get_startoff(arp)); | 3515 | INT_SET(kp->br_startoff, ARCH_CONVERT, xfs_bmbt_disk_get_startoff(arp)); |
3516 | pp = XFS_BMAP_PTR_IADDR(block, 1, cur); | 3516 | pp = XFS_BMAP_PTR_IADDR(block, 1, cur); |
3517 | INT_SET(*pp, ARCH_CONVERT, args.fsbno); | 3517 | *pp = cpu_to_be64(args.fsbno); |
3518 | /* | 3518 | /* |
3519 | * Do all this logging at the end so that | 3519 | * Do all this logging at the end so that |
3520 | * the root is at the right level. | 3520 | * the root is at the right level. |
@@ -4494,7 +4494,7 @@ xfs_bmap_read_extents( | |||
4494 | xfs_ifork_t *ifp; /* fork structure */ | 4494 | xfs_ifork_t *ifp; /* fork structure */ |
4495 | int level; /* btree level, for checking */ | 4495 | int level; /* btree level, for checking */ |
4496 | xfs_mount_t *mp; /* file system mount structure */ | 4496 | xfs_mount_t *mp; /* file system mount structure */ |
4497 | xfs_bmbt_ptr_t *pp; /* pointer to block address */ | 4497 | __be64 *pp; /* pointer to block address */ |
4498 | /* REFERENCED */ | 4498 | /* REFERENCED */ |
4499 | xfs_extnum_t room; /* number of entries there's room for */ | 4499 | xfs_extnum_t room; /* number of entries there's room for */ |
4500 | 4500 | ||
@@ -4510,10 +4510,10 @@ xfs_bmap_read_extents( | |||
4510 | level = be16_to_cpu(block->bb_level); | 4510 | level = be16_to_cpu(block->bb_level); |
4511 | ASSERT(level > 0); | 4511 | ASSERT(level > 0); |
4512 | pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes); | 4512 | pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes); |
4513 | ASSERT(INT_GET(*pp, ARCH_CONVERT) != NULLDFSBNO); | 4513 | bno = be64_to_cpu(*pp); |
4514 | ASSERT(XFS_FSB_TO_AGNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agcount); | 4514 | ASSERT(bno != NULLDFSBNO); |
4515 | ASSERT(XFS_FSB_TO_AGBNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agblocks); | 4515 | ASSERT(XFS_FSB_TO_AGNO(mp, bno) < mp->m_sb.sb_agcount); |
4516 | bno = INT_GET(*pp, ARCH_CONVERT); | 4516 | ASSERT(XFS_FSB_TO_AGBNO(mp, bno) < mp->m_sb.sb_agblocks); |
4517 | /* | 4517 | /* |
4518 | * Go down the tree until leaf level is reached, following the first | 4518 | * Go down the tree until leaf level is reached, following the first |
4519 | * pointer (leftmost) at each level. | 4519 | * pointer (leftmost) at each level. |
@@ -4530,10 +4530,8 @@ xfs_bmap_read_extents( | |||
4530 | break; | 4530 | break; |
4531 | pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt, block, | 4531 | pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt, block, |
4532 | 1, mp->m_bmap_dmxr[1]); | 4532 | 1, mp->m_bmap_dmxr[1]); |
4533 | XFS_WANT_CORRUPTED_GOTO( | 4533 | bno = be64_to_cpu(*pp); |
4534 | XFS_FSB_SANITY_CHECK(mp, INT_GET(*pp, ARCH_CONVERT)), | 4534 | XFS_WANT_CORRUPTED_GOTO(XFS_FSB_SANITY_CHECK(mp, bno), error0); |
4535 | error0); | ||
4536 | bno = INT_GET(*pp, ARCH_CONVERT); | ||
4537 | xfs_trans_brelse(tp, bp); | 4535 | xfs_trans_brelse(tp, bp); |
4538 | } | 4536 | } |
4539 | /* | 4537 | /* |
@@ -6141,7 +6139,7 @@ xfs_check_block( | |||
6141 | short sz) | 6139 | short sz) |
6142 | { | 6140 | { |
6143 | int i, j, dmxr; | 6141 | int i, j, dmxr; |
6144 | xfs_bmbt_ptr_t *pp, *thispa; /* pointer to block address */ | 6142 | __be64 *pp, *thispa; /* pointer to block address */ |
6145 | xfs_bmbt_key_t *prevp, *keyp; | 6143 | xfs_bmbt_key_t *prevp, *keyp; |
6146 | 6144 | ||
6147 | ASSERT(be16_to_cpu(block->bb_level) > 0); | 6145 | ASSERT(be16_to_cpu(block->bb_level) > 0); |
@@ -6179,11 +6177,10 @@ xfs_check_block( | |||
6179 | thispa = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, | 6177 | thispa = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, |
6180 | xfs_bmbt, block, j, dmxr); | 6178 | xfs_bmbt, block, j, dmxr); |
6181 | } | 6179 | } |
6182 | if (INT_GET(*thispa, ARCH_CONVERT) == | 6180 | if (*thispa == *pp) { |
6183 | INT_GET(*pp, ARCH_CONVERT)) { | ||
6184 | cmn_err(CE_WARN, "%s: thispa(%d) == pp(%d) %Ld", | 6181 | cmn_err(CE_WARN, "%s: thispa(%d) == pp(%d) %Ld", |
6185 | __FUNCTION__, j, i, | 6182 | __FUNCTION__, j, i, |
6186 | INT_GET(*thispa, ARCH_CONVERT)); | 6183 | (unsigned long long)be64_to_cpu(*thispa)); |
6187 | panic("%s: ptrs are equal in node\n", | 6184 | panic("%s: ptrs are equal in node\n", |
6188 | __FUNCTION__); | 6185 | __FUNCTION__); |
6189 | } | 6186 | } |
@@ -6210,7 +6207,7 @@ xfs_bmap_check_leaf_extents( | |||
6210 | xfs_ifork_t *ifp; /* fork structure */ | 6207 | xfs_ifork_t *ifp; /* fork structure */ |
6211 | int level; /* btree level, for checking */ | 6208 | int level; /* btree level, for checking */ |
6212 | xfs_mount_t *mp; /* file system mount structure */ | 6209 | xfs_mount_t *mp; /* file system mount structure */ |
6213 | xfs_bmbt_ptr_t *pp; /* pointer to block address */ | 6210 | __be64 *pp; /* pointer to block address */ |
6214 | xfs_bmbt_rec_t *ep; /* pointer to current extent */ | 6211 | xfs_bmbt_rec_t *ep; /* pointer to current extent */ |
6215 | xfs_bmbt_rec_t *lastp; /* pointer to previous extent */ | 6212 | xfs_bmbt_rec_t *lastp; /* pointer to previous extent */ |
6216 | xfs_bmbt_rec_t *nextp; /* pointer to next extent */ | 6213 | xfs_bmbt_rec_t *nextp; /* pointer to next extent */ |
@@ -6231,10 +6228,12 @@ xfs_bmap_check_leaf_extents( | |||
6231 | ASSERT(level > 0); | 6228 | ASSERT(level > 0); |
6232 | xfs_check_block(block, mp, 1, ifp->if_broot_bytes); | 6229 | xfs_check_block(block, mp, 1, ifp->if_broot_bytes); |
6233 | pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes); | 6230 | pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes); |
6234 | ASSERT(INT_GET(*pp, ARCH_CONVERT) != NULLDFSBNO); | 6231 | bno = be64_to_cpu(*pp); |
6235 | ASSERT(XFS_FSB_TO_AGNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agcount); | 6232 | |
6236 | ASSERT(XFS_FSB_TO_AGBNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agblocks); | 6233 | ASSERT(bno != NULLDFSBNO); |
6237 | bno = INT_GET(*pp, ARCH_CONVERT); | 6234 | ASSERT(XFS_FSB_TO_AGNO(mp, bno) < mp->m_sb.sb_agcount); |
6235 | ASSERT(XFS_FSB_TO_AGBNO(mp, bno) < mp->m_sb.sb_agblocks); | ||
6236 | |||
6238 | /* | 6237 | /* |
6239 | * Go down the tree until leaf level is reached, following the first | 6238 | * Go down the tree until leaf level is reached, following the first |
6240 | * pointer (leftmost) at each level. | 6239 | * pointer (leftmost) at each level. |
@@ -6265,8 +6264,8 @@ xfs_bmap_check_leaf_extents( | |||
6265 | xfs_check_block(block, mp, 0, 0); | 6264 | xfs_check_block(block, mp, 0, 0); |
6266 | pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt, block, | 6265 | pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt, block, |
6267 | 1, mp->m_bmap_dmxr[1]); | 6266 | 1, mp->m_bmap_dmxr[1]); |
6268 | XFS_WANT_CORRUPTED_GOTO(XFS_FSB_SANITY_CHECK(mp, INT_GET(*pp, ARCH_CONVERT)), error0); | 6267 | bno = be64_to_cpu(*pp); |
6269 | bno = INT_GET(*pp, ARCH_CONVERT); | 6268 | XFS_WANT_CORRUPTED_GOTO(XFS_FSB_SANITY_CHECK(mp, bno), error0); |
6270 | if (bp_release) { | 6269 | if (bp_release) { |
6271 | bp_release = 0; | 6270 | bp_release = 0; |
6272 | xfs_trans_brelse(NULL, bp); | 6271 | xfs_trans_brelse(NULL, bp); |
@@ -6372,7 +6371,7 @@ xfs_bmap_count_blocks( | |||
6372 | xfs_ifork_t *ifp; /* fork structure */ | 6371 | xfs_ifork_t *ifp; /* fork structure */ |
6373 | int level; /* btree level, for checking */ | 6372 | int level; /* btree level, for checking */ |
6374 | xfs_mount_t *mp; /* file system mount structure */ | 6373 | xfs_mount_t *mp; /* file system mount structure */ |
6375 | xfs_bmbt_ptr_t *pp; /* pointer to block address */ | 6374 | __be64 *pp; /* pointer to block address */ |
6376 | 6375 | ||
6377 | bno = NULLFSBLOCK; | 6376 | bno = NULLFSBLOCK; |
6378 | mp = ip->i_mount; | 6377 | mp = ip->i_mount; |
@@ -6395,10 +6394,10 @@ xfs_bmap_count_blocks( | |||
6395 | level = be16_to_cpu(block->bb_level); | 6394 | level = be16_to_cpu(block->bb_level); |
6396 | ASSERT(level > 0); | 6395 | ASSERT(level > 0); |
6397 | pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes); | 6396 | pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes); |
6398 | ASSERT(INT_GET(*pp, ARCH_CONVERT) != NULLDFSBNO); | 6397 | bno = be64_to_cpu(*pp); |
6399 | ASSERT(XFS_FSB_TO_AGNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agcount); | 6398 | ASSERT(bno != NULLDFSBNO); |
6400 | ASSERT(XFS_FSB_TO_AGBNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agblocks); | 6399 | ASSERT(XFS_FSB_TO_AGNO(mp, bno) < mp->m_sb.sb_agcount); |
6401 | bno = INT_GET(*pp, ARCH_CONVERT); | 6400 | ASSERT(XFS_FSB_TO_AGBNO(mp, bno) < mp->m_sb.sb_agblocks); |
6402 | 6401 | ||
6403 | if (unlikely(xfs_bmap_count_tree(mp, tp, ifp, bno, level, count) < 0)) { | 6402 | if (unlikely(xfs_bmap_count_tree(mp, tp, ifp, bno, level, count) < 0)) { |
6404 | XFS_ERROR_REPORT("xfs_bmap_count_blocks(2)", XFS_ERRLEVEL_LOW, | 6403 | XFS_ERROR_REPORT("xfs_bmap_count_blocks(2)", XFS_ERRLEVEL_LOW, |
@@ -6425,7 +6424,7 @@ xfs_bmap_count_tree( | |||
6425 | int error; | 6424 | int error; |
6426 | xfs_buf_t *bp, *nbp; | 6425 | xfs_buf_t *bp, *nbp; |
6427 | int level = levelin; | 6426 | int level = levelin; |
6428 | xfs_bmbt_ptr_t *pp; | 6427 | __be64 *pp; |
6429 | xfs_fsblock_t bno = blockno; | 6428 | xfs_fsblock_t bno = blockno; |
6430 | xfs_fsblock_t nextbno; | 6429 | xfs_fsblock_t nextbno; |
6431 | xfs_bmbt_block_t *block, *nextblock; | 6430 | xfs_bmbt_block_t *block, *nextblock; |
@@ -6452,7 +6451,7 @@ xfs_bmap_count_tree( | |||
6452 | /* Dive to the next level */ | 6451 | /* Dive to the next level */ |
6453 | pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, | 6452 | pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, |
6454 | xfs_bmbt, block, 1, mp->m_bmap_dmxr[1]); | 6453 | xfs_bmbt, block, 1, mp->m_bmap_dmxr[1]); |
6455 | bno = INT_GET(*pp, ARCH_CONVERT); | 6454 | bno = be64_to_cpu(*pp); |
6456 | if (unlikely((error = | 6455 | if (unlikely((error = |
6457 | xfs_bmap_count_tree(mp, tp, ifp, bno, level, count)) < 0)) { | 6456 | xfs_bmap_count_tree(mp, tp, ifp, bno, level, count)) < 0)) { |
6458 | xfs_trans_brelse(tp, bp); | 6457 | xfs_trans_brelse(tp, bp); |