diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/xfs/xfs_bmap_btree.c | 15 | ||||
-rw-r--r-- | fs/xfs/xfs_btree.c | 118 | ||||
-rw-r--r-- | fs/xfs/xfs_btree.h | 15 |
3 files changed, 76 insertions, 72 deletions
diff --git a/fs/xfs/xfs_bmap_btree.c b/fs/xfs/xfs_bmap_btree.c index 1ec494e111b5..519249e20536 100644 --- a/fs/xfs/xfs_bmap_btree.c +++ b/fs/xfs/xfs_bmap_btree.c | |||
@@ -1721,8 +1721,9 @@ xfs_bmbt_decrement( | |||
1721 | XFS_BMBT_TRACE_CURSOR(cur, ENTRY); | 1721 | XFS_BMBT_TRACE_CURSOR(cur, ENTRY); |
1722 | XFS_BMBT_TRACE_ARGI(cur, level); | 1722 | XFS_BMBT_TRACE_ARGI(cur, level); |
1723 | ASSERT(level < cur->bc_nlevels); | 1723 | ASSERT(level < cur->bc_nlevels); |
1724 | if (level < cur->bc_nlevels - 1) | 1724 | |
1725 | xfs_btree_readahead(cur, level, XFS_BTCUR_LEFTRA); | 1725 | xfs_btree_readahead(cur, level, XFS_BTCUR_LEFTRA); |
1726 | |||
1726 | if (--cur->bc_ptrs[level] > 0) { | 1727 | if (--cur->bc_ptrs[level] > 0) { |
1727 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 1728 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
1728 | *stat = 1; | 1729 | *stat = 1; |
@@ -1743,8 +1744,7 @@ xfs_bmbt_decrement( | |||
1743 | for (lev = level + 1; lev < cur->bc_nlevels; lev++) { | 1744 | for (lev = level + 1; lev < cur->bc_nlevels; lev++) { |
1744 | if (--cur->bc_ptrs[lev] > 0) | 1745 | if (--cur->bc_ptrs[lev] > 0) |
1745 | break; | 1746 | break; |
1746 | if (lev < cur->bc_nlevels - 1) | 1747 | xfs_btree_readahead(cur, lev, XFS_BTCUR_LEFTRA); |
1747 | xfs_btree_readahead(cur, lev, XFS_BTCUR_LEFTRA); | ||
1748 | } | 1748 | } |
1749 | if (lev == cur->bc_nlevels) { | 1749 | if (lev == cur->bc_nlevels) { |
1750 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 1750 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
@@ -1995,8 +1995,8 @@ xfs_bmbt_increment( | |||
1995 | XFS_BMBT_TRACE_CURSOR(cur, ENTRY); | 1995 | XFS_BMBT_TRACE_CURSOR(cur, ENTRY); |
1996 | XFS_BMBT_TRACE_ARGI(cur, level); | 1996 | XFS_BMBT_TRACE_ARGI(cur, level); |
1997 | ASSERT(level < cur->bc_nlevels); | 1997 | ASSERT(level < cur->bc_nlevels); |
1998 | if (level < cur->bc_nlevels - 1) | 1998 | |
1999 | xfs_btree_readahead(cur, level, XFS_BTCUR_RIGHTRA); | 1999 | xfs_btree_readahead(cur, level, XFS_BTCUR_RIGHTRA); |
2000 | block = xfs_bmbt_get_block(cur, level, &bp); | 2000 | block = xfs_bmbt_get_block(cur, level, &bp); |
2001 | #ifdef DEBUG | 2001 | #ifdef DEBUG |
2002 | if ((error = xfs_btree_check_lblock(cur, block, level, bp))) { | 2002 | if ((error = xfs_btree_check_lblock(cur, block, level, bp))) { |
@@ -2024,8 +2024,7 @@ xfs_bmbt_increment( | |||
2024 | #endif | 2024 | #endif |
2025 | if (++cur->bc_ptrs[lev] <= be16_to_cpu(block->bb_numrecs)) | 2025 | if (++cur->bc_ptrs[lev] <= be16_to_cpu(block->bb_numrecs)) |
2026 | break; | 2026 | break; |
2027 | if (lev < cur->bc_nlevels - 1) | 2027 | xfs_btree_readahead(cur, lev, XFS_BTCUR_RIGHTRA); |
2028 | xfs_btree_readahead(cur, lev, XFS_BTCUR_RIGHTRA); | ||
2029 | } | 2028 | } |
2030 | if (lev == cur->bc_nlevels) { | 2029 | if (lev == cur->bc_nlevels) { |
2031 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 2030 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
diff --git a/fs/xfs/xfs_btree.c b/fs/xfs/xfs_btree.c index 59796b42e9c4..4d793e4ccdcc 100644 --- a/fs/xfs/xfs_btree.c +++ b/fs/xfs/xfs_btree.c | |||
@@ -725,66 +725,84 @@ xfs_btree_reada_bufs( | |||
725 | xfs_baread(mp->m_ddev_targp, d, mp->m_bsize * count); | 725 | xfs_baread(mp->m_ddev_targp, d, mp->m_bsize * count); |
726 | } | 726 | } |
727 | 727 | ||
728 | STATIC int | ||
729 | xfs_btree_readahead_lblock( | ||
730 | struct xfs_btree_cur *cur, | ||
731 | int lr, | ||
732 | struct xfs_btree_block *block) | ||
733 | { | ||
734 | int rval = 0; | ||
735 | xfs_fsblock_t left = be64_to_cpu(block->bb_u.l.bb_leftsib); | ||
736 | xfs_fsblock_t right = be64_to_cpu(block->bb_u.l.bb_rightsib); | ||
737 | |||
738 | if ((lr & XFS_BTCUR_LEFTRA) && left != NULLDFSBNO) { | ||
739 | xfs_btree_reada_bufl(cur->bc_mp, left, 1); | ||
740 | rval++; | ||
741 | } | ||
742 | |||
743 | if ((lr & XFS_BTCUR_RIGHTRA) && right != NULLDFSBNO) { | ||
744 | xfs_btree_reada_bufl(cur->bc_mp, right, 1); | ||
745 | rval++; | ||
746 | } | ||
747 | |||
748 | return rval; | ||
749 | } | ||
750 | |||
751 | STATIC int | ||
752 | xfs_btree_readahead_sblock( | ||
753 | struct xfs_btree_cur *cur, | ||
754 | int lr, | ||
755 | struct xfs_btree_block *block) | ||
756 | { | ||
757 | int rval = 0; | ||
758 | xfs_agblock_t left = be32_to_cpu(block->bb_u.s.bb_leftsib); | ||
759 | xfs_agblock_t right = be32_to_cpu(block->bb_u.s.bb_rightsib); | ||
760 | |||
761 | |||
762 | if ((lr & XFS_BTCUR_LEFTRA) && left != NULLAGBLOCK) { | ||
763 | xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.a.agno, | ||
764 | left, 1); | ||
765 | rval++; | ||
766 | } | ||
767 | |||
768 | if ((lr & XFS_BTCUR_RIGHTRA) && right != NULLAGBLOCK) { | ||
769 | xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.a.agno, | ||
770 | right, 1); | ||
771 | rval++; | ||
772 | } | ||
773 | |||
774 | return rval; | ||
775 | } | ||
776 | |||
728 | /* | 777 | /* |
729 | * Read-ahead btree blocks, at the given level. | 778 | * Read-ahead btree blocks, at the given level. |
730 | * Bits in lr are set from XFS_BTCUR_{LEFT,RIGHT}RA. | 779 | * Bits in lr are set from XFS_BTCUR_{LEFT,RIGHT}RA. |
731 | */ | 780 | */ |
732 | int | 781 | int |
733 | xfs_btree_readahead_core( | 782 | xfs_btree_readahead( |
734 | xfs_btree_cur_t *cur, /* btree cursor */ | 783 | struct xfs_btree_cur *cur, /* btree cursor */ |
735 | int lev, /* level in btree */ | 784 | int lev, /* level in btree */ |
736 | int lr) /* left/right bits */ | 785 | int lr) /* left/right bits */ |
737 | { | 786 | { |
738 | xfs_alloc_block_t *a; | 787 | struct xfs_btree_block *block; |
739 | xfs_bmbt_block_t *b; | 788 | |
740 | xfs_inobt_block_t *i; | 789 | /* |
741 | int rval = 0; | 790 | * No readahead needed if we are at the root level and the |
791 | * btree root is stored in the inode. | ||
792 | */ | ||
793 | if ((cur->bc_flags & XFS_BTREE_ROOT_IN_INODE) && | ||
794 | (lev == cur->bc_nlevels - 1)) | ||
795 | return 0; | ||
796 | |||
797 | if ((cur->bc_ra[lev] | lr) == cur->bc_ra[lev]) | ||
798 | return 0; | ||
742 | 799 | ||
743 | ASSERT(cur->bc_bufs[lev] != NULL); | ||
744 | cur->bc_ra[lev] |= lr; | 800 | cur->bc_ra[lev] |= lr; |
745 | switch (cur->bc_btnum) { | 801 | block = XFS_BUF_TO_BLOCK(cur->bc_bufs[lev]); |
746 | case XFS_BTNUM_BNO: | 802 | |
747 | case XFS_BTNUM_CNT: | 803 | if (cur->bc_flags & XFS_BTREE_LONG_PTRS) |
748 | a = XFS_BUF_TO_ALLOC_BLOCK(cur->bc_bufs[lev]); | 804 | return xfs_btree_readahead_lblock(cur, lr, block); |
749 | if ((lr & XFS_BTCUR_LEFTRA) && be32_to_cpu(a->bb_leftsib) != NULLAGBLOCK) { | 805 | return xfs_btree_readahead_sblock(cur, lr, block); |
750 | xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.a.agno, | ||
751 | be32_to_cpu(a->bb_leftsib), 1); | ||
752 | rval++; | ||
753 | } | ||
754 | if ((lr & XFS_BTCUR_RIGHTRA) && be32_to_cpu(a->bb_rightsib) != NULLAGBLOCK) { | ||
755 | xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.a.agno, | ||
756 | be32_to_cpu(a->bb_rightsib), 1); | ||
757 | rval++; | ||
758 | } | ||
759 | break; | ||
760 | case XFS_BTNUM_BMAP: | ||
761 | b = XFS_BUF_TO_BMBT_BLOCK(cur->bc_bufs[lev]); | ||
762 | if ((lr & XFS_BTCUR_LEFTRA) && be64_to_cpu(b->bb_leftsib) != NULLDFSBNO) { | ||
763 | xfs_btree_reada_bufl(cur->bc_mp, be64_to_cpu(b->bb_leftsib), 1); | ||
764 | rval++; | ||
765 | } | ||
766 | if ((lr & XFS_BTCUR_RIGHTRA) && be64_to_cpu(b->bb_rightsib) != NULLDFSBNO) { | ||
767 | xfs_btree_reada_bufl(cur->bc_mp, be64_to_cpu(b->bb_rightsib), 1); | ||
768 | rval++; | ||
769 | } | ||
770 | break; | ||
771 | case XFS_BTNUM_INO: | ||
772 | i = XFS_BUF_TO_INOBT_BLOCK(cur->bc_bufs[lev]); | ||
773 | if ((lr & XFS_BTCUR_LEFTRA) && be32_to_cpu(i->bb_leftsib) != NULLAGBLOCK) { | ||
774 | xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.a.agno, | ||
775 | be32_to_cpu(i->bb_leftsib), 1); | ||
776 | rval++; | ||
777 | } | ||
778 | if ((lr & XFS_BTCUR_RIGHTRA) && be32_to_cpu(i->bb_rightsib) != NULLAGBLOCK) { | ||
779 | xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.a.agno, | ||
780 | be32_to_cpu(i->bb_rightsib), 1); | ||
781 | rval++; | ||
782 | } | ||
783 | break; | ||
784 | default: | ||
785 | ASSERT(0); | ||
786 | } | ||
787 | return rval; | ||
788 | } | 806 | } |
789 | 807 | ||
790 | /* | 808 | /* |
diff --git a/fs/xfs/xfs_btree.h b/fs/xfs/xfs_btree.h index dd93fd39c56a..8be838f0154a 100644 --- a/fs/xfs/xfs_btree.h +++ b/fs/xfs/xfs_btree.h | |||
@@ -421,23 +421,10 @@ xfs_btree_reada_bufs( | |||
421 | * Bits in lr are set from XFS_BTCUR_{LEFT,RIGHT}RA. | 421 | * Bits in lr are set from XFS_BTCUR_{LEFT,RIGHT}RA. |
422 | */ | 422 | */ |
423 | int /* readahead block count */ | 423 | int /* readahead block count */ |
424 | xfs_btree_readahead_core( | ||
425 | xfs_btree_cur_t *cur, /* btree cursor */ | ||
426 | int lev, /* level in btree */ | ||
427 | int lr); /* left/right bits */ | ||
428 | |||
429 | static inline int /* readahead block count */ | ||
430 | xfs_btree_readahead( | 424 | xfs_btree_readahead( |
431 | xfs_btree_cur_t *cur, /* btree cursor */ | 425 | xfs_btree_cur_t *cur, /* btree cursor */ |
432 | int lev, /* level in btree */ | 426 | int lev, /* level in btree */ |
433 | int lr) /* left/right bits */ | 427 | int lr); /* left/right bits */ |
434 | { | ||
435 | if ((cur->bc_ra[lev] | lr) == cur->bc_ra[lev]) | ||
436 | return 0; | ||
437 | |||
438 | return xfs_btree_readahead_core(cur, lev, lr); | ||
439 | } | ||
440 | |||
441 | 428 | ||
442 | /* | 429 | /* |
443 | * Set the buffer for level "lev" in the cursor to bp, releasing | 430 | * Set the buffer for level "lev" in the cursor to bp, releasing |