aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_bmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_bmap.c')
-rw-r--r--fs/xfs/xfs_bmap.c90
1 files changed, 46 insertions, 44 deletions
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
index bf46fae303af..5b050c06795f 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(cur, INT_GET(*pp, ARCH_CONVERT), 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;
@@ -3512,9 +3512,9 @@ xfs_bmap_extents_to_btree(
3512 */ 3512 */
3513 kp = XFS_BMAP_KEY_IADDR(block, 1, cur); 3513 kp = XFS_BMAP_KEY_IADDR(block, 1, cur);
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 kp->br_startoff = cpu_to_be64(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.
@@ -3705,7 +3705,7 @@ STATIC xfs_bmbt_rec_t * /* pointer to found extent entry */
3705xfs_bmap_search_extents( 3705xfs_bmap_search_extents(
3706 xfs_inode_t *ip, /* incore inode pointer */ 3706 xfs_inode_t *ip, /* incore inode pointer */
3707 xfs_fileoff_t bno, /* block number searched for */ 3707 xfs_fileoff_t bno, /* block number searched for */
3708 int whichfork, /* data or attr fork */ 3708 int fork, /* data or attr fork */
3709 int *eofp, /* out: end of file found */ 3709 int *eofp, /* out: end of file found */
3710 xfs_extnum_t *lastxp, /* out: last extent index */ 3710 xfs_extnum_t *lastxp, /* out: last extent index */
3711 xfs_bmbt_irec_t *gotp, /* out: extent entry found */ 3711 xfs_bmbt_irec_t *gotp, /* out: extent entry found */
@@ -3713,25 +3713,28 @@ xfs_bmap_search_extents(
3713{ 3713{
3714 xfs_ifork_t *ifp; /* inode fork pointer */ 3714 xfs_ifork_t *ifp; /* inode fork pointer */
3715 xfs_bmbt_rec_t *ep; /* extent record pointer */ 3715 xfs_bmbt_rec_t *ep; /* extent record pointer */
3716 int rt; /* realtime flag */
3717 3716
3718 XFS_STATS_INC(xs_look_exlist); 3717 XFS_STATS_INC(xs_look_exlist);
3719 ifp = XFS_IFORK_PTR(ip, whichfork); 3718 ifp = XFS_IFORK_PTR(ip, fork);
3720 3719
3721 ep = xfs_bmap_search_multi_extents(ifp, bno, eofp, lastxp, gotp, prevp); 3720 ep = xfs_bmap_search_multi_extents(ifp, bno, eofp, lastxp, gotp, prevp);
3722 3721
3723 rt = (whichfork == XFS_DATA_FORK) && XFS_IS_REALTIME_INODE(ip); 3722 if (unlikely(!(gotp->br_startblock) && (*lastxp != NULLEXTNUM) &&
3724 if (unlikely(!rt && !gotp->br_startblock && (*lastxp != NULLEXTNUM))) { 3723 !(XFS_IS_REALTIME_INODE(ip) && fork == XFS_DATA_FORK))) {
3725 cmn_err(CE_PANIC,"Access to block zero: fs: <%s> inode: %lld " 3724 xfs_cmn_err(XFS_PTAG_FSBLOCK_ZERO, CE_ALERT, ip->i_mount,
3726 "start_block : %llx start_off : %llx blkcnt : %llx " 3725 "Access to block zero in inode %llu "
3727 "extent-state : %x \n", 3726 "start_block: %llx start_off: %llx "
3728 (ip->i_mount)->m_fsname, (long long)ip->i_ino, 3727 "blkcnt: %llx extent-state: %x lastx: %x\n",
3728 (unsigned long long)ip->i_ino,
3729 (unsigned long long)gotp->br_startblock, 3729 (unsigned long long)gotp->br_startblock,
3730 (unsigned long long)gotp->br_startoff, 3730 (unsigned long long)gotp->br_startoff,
3731 (unsigned long long)gotp->br_blockcount, 3731 (unsigned long long)gotp->br_blockcount,
3732 gotp->br_state); 3732 gotp->br_state, *lastxp);
3733 } 3733 *lastxp = NULLEXTNUM;
3734 return ep; 3734 *eofp = 1;
3735 return NULL;
3736 }
3737 return ep;
3735} 3738}
3736 3739
3737 3740
@@ -4494,7 +4497,7 @@ xfs_bmap_read_extents(
4494 xfs_ifork_t *ifp; /* fork structure */ 4497 xfs_ifork_t *ifp; /* fork structure */
4495 int level; /* btree level, for checking */ 4498 int level; /* btree level, for checking */
4496 xfs_mount_t *mp; /* file system mount structure */ 4499 xfs_mount_t *mp; /* file system mount structure */
4497 xfs_bmbt_ptr_t *pp; /* pointer to block address */ 4500 __be64 *pp; /* pointer to block address */
4498 /* REFERENCED */ 4501 /* REFERENCED */
4499 xfs_extnum_t room; /* number of entries there's room for */ 4502 xfs_extnum_t room; /* number of entries there's room for */
4500 4503
@@ -4510,10 +4513,10 @@ xfs_bmap_read_extents(
4510 level = be16_to_cpu(block->bb_level); 4513 level = be16_to_cpu(block->bb_level);
4511 ASSERT(level > 0); 4514 ASSERT(level > 0);
4512 pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes); 4515 pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes);
4513 ASSERT(INT_GET(*pp, ARCH_CONVERT) != NULLDFSBNO); 4516 bno = be64_to_cpu(*pp);
4514 ASSERT(XFS_FSB_TO_AGNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agcount); 4517 ASSERT(bno != NULLDFSBNO);
4515 ASSERT(XFS_FSB_TO_AGBNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agblocks); 4518 ASSERT(XFS_FSB_TO_AGNO(mp, bno) < mp->m_sb.sb_agcount);
4516 bno = INT_GET(*pp, ARCH_CONVERT); 4519 ASSERT(XFS_FSB_TO_AGBNO(mp, bno) < mp->m_sb.sb_agblocks);
4517 /* 4520 /*
4518 * Go down the tree until leaf level is reached, following the first 4521 * Go down the tree until leaf level is reached, following the first
4519 * pointer (leftmost) at each level. 4522 * pointer (leftmost) at each level.
@@ -4530,10 +4533,8 @@ xfs_bmap_read_extents(
4530 break; 4533 break;
4531 pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt, block, 4534 pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt, block,
4532 1, mp->m_bmap_dmxr[1]); 4535 1, mp->m_bmap_dmxr[1]);
4533 XFS_WANT_CORRUPTED_GOTO( 4536 bno = be64_to_cpu(*pp);
4534 XFS_FSB_SANITY_CHECK(mp, INT_GET(*pp, ARCH_CONVERT)), 4537 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); 4538 xfs_trans_brelse(tp, bp);
4538 } 4539 }
4539 /* 4540 /*
@@ -6141,7 +6142,7 @@ xfs_check_block(
6141 short sz) 6142 short sz)
6142{ 6143{
6143 int i, j, dmxr; 6144 int i, j, dmxr;
6144 xfs_bmbt_ptr_t *pp, *thispa; /* pointer to block address */ 6145 __be64 *pp, *thispa; /* pointer to block address */
6145 xfs_bmbt_key_t *prevp, *keyp; 6146 xfs_bmbt_key_t *prevp, *keyp;
6146 6147
6147 ASSERT(be16_to_cpu(block->bb_level) > 0); 6148 ASSERT(be16_to_cpu(block->bb_level) > 0);
@@ -6179,11 +6180,10 @@ xfs_check_block(
6179 thispa = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, 6180 thispa = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize,
6180 xfs_bmbt, block, j, dmxr); 6181 xfs_bmbt, block, j, dmxr);
6181 } 6182 }
6182 if (INT_GET(*thispa, ARCH_CONVERT) == 6183 if (*thispa == *pp) {
6183 INT_GET(*pp, ARCH_CONVERT)) {
6184 cmn_err(CE_WARN, "%s: thispa(%d) == pp(%d) %Ld", 6184 cmn_err(CE_WARN, "%s: thispa(%d) == pp(%d) %Ld",
6185 __FUNCTION__, j, i, 6185 __FUNCTION__, j, i,
6186 INT_GET(*thispa, ARCH_CONVERT)); 6186 (unsigned long long)be64_to_cpu(*thispa));
6187 panic("%s: ptrs are equal in node\n", 6187 panic("%s: ptrs are equal in node\n",
6188 __FUNCTION__); 6188 __FUNCTION__);
6189 } 6189 }
@@ -6210,7 +6210,7 @@ xfs_bmap_check_leaf_extents(
6210 xfs_ifork_t *ifp; /* fork structure */ 6210 xfs_ifork_t *ifp; /* fork structure */
6211 int level; /* btree level, for checking */ 6211 int level; /* btree level, for checking */
6212 xfs_mount_t *mp; /* file system mount structure */ 6212 xfs_mount_t *mp; /* file system mount structure */
6213 xfs_bmbt_ptr_t *pp; /* pointer to block address */ 6213 __be64 *pp; /* pointer to block address */
6214 xfs_bmbt_rec_t *ep; /* pointer to current extent */ 6214 xfs_bmbt_rec_t *ep; /* pointer to current extent */
6215 xfs_bmbt_rec_t *lastp; /* pointer to previous extent */ 6215 xfs_bmbt_rec_t *lastp; /* pointer to previous extent */
6216 xfs_bmbt_rec_t *nextp; /* pointer to next extent */ 6216 xfs_bmbt_rec_t *nextp; /* pointer to next extent */
@@ -6231,10 +6231,12 @@ xfs_bmap_check_leaf_extents(
6231 ASSERT(level > 0); 6231 ASSERT(level > 0);
6232 xfs_check_block(block, mp, 1, ifp->if_broot_bytes); 6232 xfs_check_block(block, mp, 1, ifp->if_broot_bytes);
6233 pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes); 6233 pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes);
6234 ASSERT(INT_GET(*pp, ARCH_CONVERT) != NULLDFSBNO); 6234 bno = be64_to_cpu(*pp);
6235 ASSERT(XFS_FSB_TO_AGNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agcount); 6235
6236 ASSERT(XFS_FSB_TO_AGBNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agblocks); 6236 ASSERT(bno != NULLDFSBNO);
6237 bno = INT_GET(*pp, ARCH_CONVERT); 6237 ASSERT(XFS_FSB_TO_AGNO(mp, bno) < mp->m_sb.sb_agcount);
6238 ASSERT(XFS_FSB_TO_AGBNO(mp, bno) < mp->m_sb.sb_agblocks);
6239
6238 /* 6240 /*
6239 * Go down the tree until leaf level is reached, following the first 6241 * Go down the tree until leaf level is reached, following the first
6240 * pointer (leftmost) at each level. 6242 * pointer (leftmost) at each level.
@@ -6265,8 +6267,8 @@ xfs_bmap_check_leaf_extents(
6265 xfs_check_block(block, mp, 0, 0); 6267 xfs_check_block(block, mp, 0, 0);
6266 pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt, block, 6268 pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt, block,
6267 1, mp->m_bmap_dmxr[1]); 6269 1, mp->m_bmap_dmxr[1]);
6268 XFS_WANT_CORRUPTED_GOTO(XFS_FSB_SANITY_CHECK(mp, INT_GET(*pp, ARCH_CONVERT)), error0); 6270 bno = be64_to_cpu(*pp);
6269 bno = INT_GET(*pp, ARCH_CONVERT); 6271 XFS_WANT_CORRUPTED_GOTO(XFS_FSB_SANITY_CHECK(mp, bno), error0);
6270 if (bp_release) { 6272 if (bp_release) {
6271 bp_release = 0; 6273 bp_release = 0;
6272 xfs_trans_brelse(NULL, bp); 6274 xfs_trans_brelse(NULL, bp);
@@ -6372,7 +6374,7 @@ xfs_bmap_count_blocks(
6372 xfs_ifork_t *ifp; /* fork structure */ 6374 xfs_ifork_t *ifp; /* fork structure */
6373 int level; /* btree level, for checking */ 6375 int level; /* btree level, for checking */
6374 xfs_mount_t *mp; /* file system mount structure */ 6376 xfs_mount_t *mp; /* file system mount structure */
6375 xfs_bmbt_ptr_t *pp; /* pointer to block address */ 6377 __be64 *pp; /* pointer to block address */
6376 6378
6377 bno = NULLFSBLOCK; 6379 bno = NULLFSBLOCK;
6378 mp = ip->i_mount; 6380 mp = ip->i_mount;
@@ -6395,10 +6397,10 @@ xfs_bmap_count_blocks(
6395 level = be16_to_cpu(block->bb_level); 6397 level = be16_to_cpu(block->bb_level);
6396 ASSERT(level > 0); 6398 ASSERT(level > 0);
6397 pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes); 6399 pp = XFS_BMAP_BROOT_PTR_ADDR(block, 1, ifp->if_broot_bytes);
6398 ASSERT(INT_GET(*pp, ARCH_CONVERT) != NULLDFSBNO); 6400 bno = be64_to_cpu(*pp);
6399 ASSERT(XFS_FSB_TO_AGNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agcount); 6401 ASSERT(bno != NULLDFSBNO);
6400 ASSERT(XFS_FSB_TO_AGBNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agblocks); 6402 ASSERT(XFS_FSB_TO_AGNO(mp, bno) < mp->m_sb.sb_agcount);
6401 bno = INT_GET(*pp, ARCH_CONVERT); 6403 ASSERT(XFS_FSB_TO_AGBNO(mp, bno) < mp->m_sb.sb_agblocks);
6402 6404
6403 if (unlikely(xfs_bmap_count_tree(mp, tp, ifp, bno, level, count) < 0)) { 6405 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, 6406 XFS_ERROR_REPORT("xfs_bmap_count_blocks(2)", XFS_ERRLEVEL_LOW,
@@ -6425,7 +6427,7 @@ xfs_bmap_count_tree(
6425 int error; 6427 int error;
6426 xfs_buf_t *bp, *nbp; 6428 xfs_buf_t *bp, *nbp;
6427 int level = levelin; 6429 int level = levelin;
6428 xfs_bmbt_ptr_t *pp; 6430 __be64 *pp;
6429 xfs_fsblock_t bno = blockno; 6431 xfs_fsblock_t bno = blockno;
6430 xfs_fsblock_t nextbno; 6432 xfs_fsblock_t nextbno;
6431 xfs_bmbt_block_t *block, *nextblock; 6433 xfs_bmbt_block_t *block, *nextblock;
@@ -6452,7 +6454,7 @@ xfs_bmap_count_tree(
6452 /* Dive to the next level */ 6454 /* Dive to the next level */
6453 pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, 6455 pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize,
6454 xfs_bmbt, block, 1, mp->m_bmap_dmxr[1]); 6456 xfs_bmbt, block, 1, mp->m_bmap_dmxr[1]);
6455 bno = INT_GET(*pp, ARCH_CONVERT); 6457 bno = be64_to_cpu(*pp);
6456 if (unlikely((error = 6458 if (unlikely((error =
6457 xfs_bmap_count_tree(mp, tp, ifp, bno, level, count)) < 0)) { 6459 xfs_bmap_count_tree(mp, tp, ifp, bno, level, count)) < 0)) {
6458 xfs_trans_brelse(tp, bp); 6460 xfs_trans_brelse(tp, bp);