diff options
Diffstat (limited to 'fs/xfs/libxfs/xfs_btree.c')
-rw-r--r-- | fs/xfs/libxfs/xfs_btree.c | 49 |
1 files changed, 19 insertions, 30 deletions
diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c index bbdae2b4559f..f1048efa4268 100644 --- a/fs/xfs/libxfs/xfs_btree.c +++ b/fs/xfs/libxfs/xfs_btree.c | |||
@@ -11,16 +11,13 @@ | |||
11 | #include "xfs_trans_resv.h" | 11 | #include "xfs_trans_resv.h" |
12 | #include "xfs_bit.h" | 12 | #include "xfs_bit.h" |
13 | #include "xfs_mount.h" | 13 | #include "xfs_mount.h" |
14 | #include "xfs_defer.h" | ||
15 | #include "xfs_inode.h" | 14 | #include "xfs_inode.h" |
16 | #include "xfs_trans.h" | 15 | #include "xfs_trans.h" |
17 | #include "xfs_inode_item.h" | ||
18 | #include "xfs_buf_item.h" | 16 | #include "xfs_buf_item.h" |
19 | #include "xfs_btree.h" | 17 | #include "xfs_btree.h" |
20 | #include "xfs_errortag.h" | 18 | #include "xfs_errortag.h" |
21 | #include "xfs_error.h" | 19 | #include "xfs_error.h" |
22 | #include "xfs_trace.h" | 20 | #include "xfs_trace.h" |
23 | #include "xfs_cksum.h" | ||
24 | #include "xfs_alloc.h" | 21 | #include "xfs_alloc.h" |
25 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
26 | 23 | ||
@@ -276,7 +273,7 @@ xfs_btree_lblock_calc_crc( | |||
276 | struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); | 273 | struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); |
277 | struct xfs_buf_log_item *bip = bp->b_log_item; | 274 | struct xfs_buf_log_item *bip = bp->b_log_item; |
278 | 275 | ||
279 | if (!xfs_sb_version_hascrc(&bp->b_target->bt_mount->m_sb)) | 276 | if (!xfs_sb_version_hascrc(&bp->b_mount->m_sb)) |
280 | return; | 277 | return; |
281 | if (bip) | 278 | if (bip) |
282 | block->bb_u.l.bb_lsn = cpu_to_be64(bip->bli_item.li_lsn); | 279 | block->bb_u.l.bb_lsn = cpu_to_be64(bip->bli_item.li_lsn); |
@@ -288,7 +285,7 @@ xfs_btree_lblock_verify_crc( | |||
288 | struct xfs_buf *bp) | 285 | struct xfs_buf *bp) |
289 | { | 286 | { |
290 | struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); | 287 | struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); |
291 | struct xfs_mount *mp = bp->b_target->bt_mount; | 288 | struct xfs_mount *mp = bp->b_mount; |
292 | 289 | ||
293 | if (xfs_sb_version_hascrc(&mp->m_sb)) { | 290 | if (xfs_sb_version_hascrc(&mp->m_sb)) { |
294 | if (!xfs_log_check_lsn(mp, be64_to_cpu(block->bb_u.l.bb_lsn))) | 291 | if (!xfs_log_check_lsn(mp, be64_to_cpu(block->bb_u.l.bb_lsn))) |
@@ -314,7 +311,7 @@ xfs_btree_sblock_calc_crc( | |||
314 | struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); | 311 | struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); |
315 | struct xfs_buf_log_item *bip = bp->b_log_item; | 312 | struct xfs_buf_log_item *bip = bp->b_log_item; |
316 | 313 | ||
317 | if (!xfs_sb_version_hascrc(&bp->b_target->bt_mount->m_sb)) | 314 | if (!xfs_sb_version_hascrc(&bp->b_mount->m_sb)) |
318 | return; | 315 | return; |
319 | if (bip) | 316 | if (bip) |
320 | block->bb_u.s.bb_lsn = cpu_to_be64(bip->bli_item.li_lsn); | 317 | block->bb_u.s.bb_lsn = cpu_to_be64(bip->bli_item.li_lsn); |
@@ -326,7 +323,7 @@ xfs_btree_sblock_verify_crc( | |||
326 | struct xfs_buf *bp) | 323 | struct xfs_buf *bp) |
327 | { | 324 | { |
328 | struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); | 325 | struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); |
329 | struct xfs_mount *mp = bp->b_target->bt_mount; | 326 | struct xfs_mount *mp = bp->b_mount; |
330 | 327 | ||
331 | if (xfs_sb_version_hascrc(&mp->m_sb)) { | 328 | if (xfs_sb_version_hascrc(&mp->m_sb)) { |
332 | if (!xfs_log_check_lsn(mp, be64_to_cpu(block->bb_u.s.bb_lsn))) | 329 | if (!xfs_log_check_lsn(mp, be64_to_cpu(block->bb_u.s.bb_lsn))) |
@@ -691,14 +688,13 @@ xfs_buf_t * /* buffer for fsbno */ | |||
691 | xfs_btree_get_bufl( | 688 | xfs_btree_get_bufl( |
692 | xfs_mount_t *mp, /* file system mount point */ | 689 | xfs_mount_t *mp, /* file system mount point */ |
693 | xfs_trans_t *tp, /* transaction pointer */ | 690 | xfs_trans_t *tp, /* transaction pointer */ |
694 | xfs_fsblock_t fsbno, /* file system block number */ | 691 | xfs_fsblock_t fsbno) /* file system block number */ |
695 | uint lock) /* lock flags for get_buf */ | ||
696 | { | 692 | { |
697 | xfs_daddr_t d; /* real disk block address */ | 693 | xfs_daddr_t d; /* real disk block address */ |
698 | 694 | ||
699 | ASSERT(fsbno != NULLFSBLOCK); | 695 | ASSERT(fsbno != NULLFSBLOCK); |
700 | d = XFS_FSB_TO_DADDR(mp, fsbno); | 696 | d = XFS_FSB_TO_DADDR(mp, fsbno); |
701 | return xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, lock); | 697 | return xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, 0); |
702 | } | 698 | } |
703 | 699 | ||
704 | /* | 700 | /* |
@@ -710,15 +706,14 @@ xfs_btree_get_bufs( | |||
710 | xfs_mount_t *mp, /* file system mount point */ | 706 | xfs_mount_t *mp, /* file system mount point */ |
711 | xfs_trans_t *tp, /* transaction pointer */ | 707 | xfs_trans_t *tp, /* transaction pointer */ |
712 | xfs_agnumber_t agno, /* allocation group number */ | 708 | xfs_agnumber_t agno, /* allocation group number */ |
713 | xfs_agblock_t agbno, /* allocation group block number */ | 709 | xfs_agblock_t agbno) /* allocation group block number */ |
714 | uint lock) /* lock flags for get_buf */ | ||
715 | { | 710 | { |
716 | xfs_daddr_t d; /* real disk block address */ | 711 | xfs_daddr_t d; /* real disk block address */ |
717 | 712 | ||
718 | ASSERT(agno != NULLAGNUMBER); | 713 | ASSERT(agno != NULLAGNUMBER); |
719 | ASSERT(agbno != NULLAGBLOCK); | 714 | ASSERT(agbno != NULLAGBLOCK); |
720 | d = XFS_AGB_TO_DADDR(mp, agno, agbno); | 715 | d = XFS_AGB_TO_DADDR(mp, agno, agbno); |
721 | return xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, lock); | 716 | return xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, 0); |
722 | } | 717 | } |
723 | 718 | ||
724 | /* | 719 | /* |
@@ -845,7 +840,6 @@ xfs_btree_read_bufl( | |||
845 | struct xfs_mount *mp, /* file system mount point */ | 840 | struct xfs_mount *mp, /* file system mount point */ |
846 | struct xfs_trans *tp, /* transaction pointer */ | 841 | struct xfs_trans *tp, /* transaction pointer */ |
847 | xfs_fsblock_t fsbno, /* file system block number */ | 842 | xfs_fsblock_t fsbno, /* file system block number */ |
848 | uint lock, /* lock flags for read_buf */ | ||
849 | struct xfs_buf **bpp, /* buffer for fsbno */ | 843 | struct xfs_buf **bpp, /* buffer for fsbno */ |
850 | int refval, /* ref count value for buffer */ | 844 | int refval, /* ref count value for buffer */ |
851 | const struct xfs_buf_ops *ops) | 845 | const struct xfs_buf_ops *ops) |
@@ -858,7 +852,7 @@ xfs_btree_read_bufl( | |||
858 | return -EFSCORRUPTED; | 852 | return -EFSCORRUPTED; |
859 | d = XFS_FSB_TO_DADDR(mp, fsbno); | 853 | d = XFS_FSB_TO_DADDR(mp, fsbno); |
860 | error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, d, | 854 | error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, d, |
861 | mp->m_bsize, lock, &bp, ops); | 855 | mp->m_bsize, 0, &bp, ops); |
862 | if (error) | 856 | if (error) |
863 | return error; | 857 | return error; |
864 | if (bp) | 858 | if (bp) |
@@ -1185,11 +1179,10 @@ xfs_btree_init_block( | |||
1185 | xfs_btnum_t btnum, | 1179 | xfs_btnum_t btnum, |
1186 | __u16 level, | 1180 | __u16 level, |
1187 | __u16 numrecs, | 1181 | __u16 numrecs, |
1188 | __u64 owner, | 1182 | __u64 owner) |
1189 | unsigned int flags) | ||
1190 | { | 1183 | { |
1191 | xfs_btree_init_block_int(mp, XFS_BUF_TO_BLOCK(bp), bp->b_bn, | 1184 | xfs_btree_init_block_int(mp, XFS_BUF_TO_BLOCK(bp), bp->b_bn, |
1192 | btnum, level, numrecs, owner, flags); | 1185 | btnum, level, numrecs, owner, 0); |
1193 | } | 1186 | } |
1194 | 1187 | ||
1195 | STATIC void | 1188 | STATIC void |
@@ -1288,7 +1281,6 @@ STATIC int | |||
1288 | xfs_btree_get_buf_block( | 1281 | xfs_btree_get_buf_block( |
1289 | struct xfs_btree_cur *cur, | 1282 | struct xfs_btree_cur *cur, |
1290 | union xfs_btree_ptr *ptr, | 1283 | union xfs_btree_ptr *ptr, |
1291 | int flags, | ||
1292 | struct xfs_btree_block **block, | 1284 | struct xfs_btree_block **block, |
1293 | struct xfs_buf **bpp) | 1285 | struct xfs_buf **bpp) |
1294 | { | 1286 | { |
@@ -1296,14 +1288,11 @@ xfs_btree_get_buf_block( | |||
1296 | xfs_daddr_t d; | 1288 | xfs_daddr_t d; |
1297 | int error; | 1289 | int error; |
1298 | 1290 | ||
1299 | /* need to sort out how callers deal with failures first */ | ||
1300 | ASSERT(!(flags & XBF_TRYLOCK)); | ||
1301 | |||
1302 | error = xfs_btree_ptr_to_daddr(cur, ptr, &d); | 1291 | error = xfs_btree_ptr_to_daddr(cur, ptr, &d); |
1303 | if (error) | 1292 | if (error) |
1304 | return error; | 1293 | return error; |
1305 | *bpp = xfs_trans_get_buf(cur->bc_tp, mp->m_ddev_targp, d, | 1294 | *bpp = xfs_trans_get_buf(cur->bc_tp, mp->m_ddev_targp, d, |
1306 | mp->m_bsize, flags); | 1295 | mp->m_bsize, 0); |
1307 | 1296 | ||
1308 | if (!*bpp) | 1297 | if (!*bpp) |
1309 | return -ENOMEM; | 1298 | return -ENOMEM; |
@@ -2706,7 +2695,7 @@ __xfs_btree_split( | |||
2706 | XFS_BTREE_STATS_INC(cur, alloc); | 2695 | XFS_BTREE_STATS_INC(cur, alloc); |
2707 | 2696 | ||
2708 | /* Set up the new block as "right". */ | 2697 | /* Set up the new block as "right". */ |
2709 | error = xfs_btree_get_buf_block(cur, &rptr, 0, &right, &rbp); | 2698 | error = xfs_btree_get_buf_block(cur, &rptr, &right, &rbp); |
2710 | if (error) | 2699 | if (error) |
2711 | goto error0; | 2700 | goto error0; |
2712 | 2701 | ||
@@ -2961,7 +2950,7 @@ xfs_btree_new_iroot( | |||
2961 | XFS_BTREE_STATS_INC(cur, alloc); | 2950 | XFS_BTREE_STATS_INC(cur, alloc); |
2962 | 2951 | ||
2963 | /* Copy the root into a real block. */ | 2952 | /* Copy the root into a real block. */ |
2964 | error = xfs_btree_get_buf_block(cur, &nptr, 0, &cblock, &cbp); | 2953 | error = xfs_btree_get_buf_block(cur, &nptr, &cblock, &cbp); |
2965 | if (error) | 2954 | if (error) |
2966 | goto error0; | 2955 | goto error0; |
2967 | 2956 | ||
@@ -3058,7 +3047,7 @@ xfs_btree_new_root( | |||
3058 | XFS_BTREE_STATS_INC(cur, alloc); | 3047 | XFS_BTREE_STATS_INC(cur, alloc); |
3059 | 3048 | ||
3060 | /* Set up the new block. */ | 3049 | /* Set up the new block. */ |
3061 | error = xfs_btree_get_buf_block(cur, &lptr, 0, &new, &nbp); | 3050 | error = xfs_btree_get_buf_block(cur, &lptr, &new, &nbp); |
3062 | if (error) | 3051 | if (error) |
3063 | goto error0; | 3052 | goto error0; |
3064 | 3053 | ||
@@ -4433,7 +4422,7 @@ xfs_btree_lblock_v5hdr_verify( | |||
4433 | struct xfs_buf *bp, | 4422 | struct xfs_buf *bp, |
4434 | uint64_t owner) | 4423 | uint64_t owner) |
4435 | { | 4424 | { |
4436 | struct xfs_mount *mp = bp->b_target->bt_mount; | 4425 | struct xfs_mount *mp = bp->b_mount; |
4437 | struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); | 4426 | struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); |
4438 | 4427 | ||
4439 | if (!xfs_sb_version_hascrc(&mp->m_sb)) | 4428 | if (!xfs_sb_version_hascrc(&mp->m_sb)) |
@@ -4454,7 +4443,7 @@ xfs_btree_lblock_verify( | |||
4454 | struct xfs_buf *bp, | 4443 | struct xfs_buf *bp, |
4455 | unsigned int max_recs) | 4444 | unsigned int max_recs) |
4456 | { | 4445 | { |
4457 | struct xfs_mount *mp = bp->b_target->bt_mount; | 4446 | struct xfs_mount *mp = bp->b_mount; |
4458 | struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); | 4447 | struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); |
4459 | 4448 | ||
4460 | /* numrecs verification */ | 4449 | /* numrecs verification */ |
@@ -4484,7 +4473,7 @@ xfs_failaddr_t | |||
4484 | xfs_btree_sblock_v5hdr_verify( | 4473 | xfs_btree_sblock_v5hdr_verify( |
4485 | struct xfs_buf *bp) | 4474 | struct xfs_buf *bp) |
4486 | { | 4475 | { |
4487 | struct xfs_mount *mp = bp->b_target->bt_mount; | 4476 | struct xfs_mount *mp = bp->b_mount; |
4488 | struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); | 4477 | struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); |
4489 | struct xfs_perag *pag = bp->b_pag; | 4478 | struct xfs_perag *pag = bp->b_pag; |
4490 | 4479 | ||
@@ -4510,7 +4499,7 @@ xfs_btree_sblock_verify( | |||
4510 | struct xfs_buf *bp, | 4499 | struct xfs_buf *bp, |
4511 | unsigned int max_recs) | 4500 | unsigned int max_recs) |
4512 | { | 4501 | { |
4513 | struct xfs_mount *mp = bp->b_target->bt_mount; | 4502 | struct xfs_mount *mp = bp->b_mount; |
4514 | struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); | 4503 | struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); |
4515 | xfs_agblock_t agno; | 4504 | xfs_agblock_t agno; |
4516 | 4505 | ||