diff options
author | Christoph Hellwig <hch@infradead.org> | 2011-09-18 16:41:05 -0400 |
---|---|---|
committer | Alex Elder <aelder@sgi.com> | 2011-10-11 22:15:07 -0400 |
commit | c6534249851d062113ab4d8d226be8dba8ecb92e (patch) | |
tree | a838779512f25dfe93b4aaa506ca5c895db6f28a /fs/xfs/xfs_bmap.c | |
parent | 572a4cf04ac7f46e9206aabfef03dae602812341 (diff) |
xfs: pass bmalloca to xfs_bmap_add_extent_hole_real
All the parameters passed to xfs_bmap_add_extent_hole_real() are in
the xfs_bmalloca structure now. Just pass the bmalloca parameter to
the function instead of 8 separate parameters.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Alex Elder <aelder@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_bmap.c')
-rw-r--r-- | fs/xfs/xfs_bmap.c | 161 |
1 files changed, 78 insertions, 83 deletions
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c index c8b9c4ec9f6f..2b31945ce9fe 100644 --- a/fs/xfs/xfs_bmap.c +++ b/fs/xfs/xfs_bmap.c | |||
@@ -1596,34 +1596,25 @@ xfs_bmap_add_extent_hole_delay( | |||
1596 | */ | 1596 | */ |
1597 | STATIC int /* error */ | 1597 | STATIC int /* error */ |
1598 | xfs_bmap_add_extent_hole_real( | 1598 | xfs_bmap_add_extent_hole_real( |
1599 | struct xfs_trans *tp, | 1599 | struct xfs_bmalloca *bma, |
1600 | xfs_inode_t *ip, /* incore inode pointer */ | 1600 | int whichfork) |
1601 | xfs_extnum_t *idx, /* extent number to update/insert */ | ||
1602 | xfs_btree_cur_t **curp, /* if null, not a btree */ | ||
1603 | xfs_bmbt_irec_t *new, /* new data to add to file extents */ | ||
1604 | xfs_fsblock_t *first, /* pointer to firstblock variable */ | ||
1605 | xfs_bmap_free_t *flist, /* list of extents to be freed */ | ||
1606 | int *logflagsp, /* inode logging flags */ | ||
1607 | int whichfork) /* data or attr fork */ | ||
1608 | { | 1601 | { |
1602 | struct xfs_bmbt_irec *new = &bma->got; | ||
1609 | int error; /* error return value */ | 1603 | int error; /* error return value */ |
1610 | int i; /* temp state */ | 1604 | int i; /* temp state */ |
1611 | xfs_btree_cur_t *cur; /* if null, not a btree */ | ||
1612 | xfs_ifork_t *ifp; /* inode fork pointer */ | 1605 | xfs_ifork_t *ifp; /* inode fork pointer */ |
1613 | xfs_bmbt_irec_t left; /* left neighbor extent entry */ | 1606 | xfs_bmbt_irec_t left; /* left neighbor extent entry */ |
1614 | xfs_bmbt_irec_t right; /* right neighbor extent entry */ | 1607 | xfs_bmbt_irec_t right; /* right neighbor extent entry */ |
1615 | int rval=0; /* return value (logging flags) */ | 1608 | int rval=0; /* return value (logging flags) */ |
1616 | int state; /* state bits, accessed thru macros */ | 1609 | int state; /* state bits, accessed thru macros */ |
1617 | 1610 | ||
1618 | *logflagsp = 0; | 1611 | ifp = XFS_IFORK_PTR(bma->ip, whichfork); |
1619 | |||
1620 | ifp = XFS_IFORK_PTR(ip, whichfork); | ||
1621 | cur = *curp; | ||
1622 | 1612 | ||
1623 | ASSERT(*idx >= 0); | 1613 | ASSERT(bma->idx >= 0); |
1624 | ASSERT(*idx <= ifp->if_bytes / sizeof(struct xfs_bmbt_rec)); | 1614 | ASSERT(bma->idx <= ifp->if_bytes / sizeof(struct xfs_bmbt_rec)); |
1625 | ASSERT(!isnullstartblock(new->br_startblock)); | 1615 | ASSERT(!isnullstartblock(new->br_startblock)); |
1626 | ASSERT(!cur || !(cur->bc_private.b.flags & XFS_BTCUR_BPRV_WASDEL)); | 1616 | ASSERT(!bma->cur || |
1617 | !(bma->cur->bc_private.b.flags & XFS_BTCUR_BPRV_WASDEL)); | ||
1627 | 1618 | ||
1628 | XFS_STATS_INC(xs_add_exlist); | 1619 | XFS_STATS_INC(xs_add_exlist); |
1629 | 1620 | ||
@@ -1634,9 +1625,9 @@ xfs_bmap_add_extent_hole_real( | |||
1634 | /* | 1625 | /* |
1635 | * Check and set flags if this segment has a left neighbor. | 1626 | * Check and set flags if this segment has a left neighbor. |
1636 | */ | 1627 | */ |
1637 | if (*idx > 0) { | 1628 | if (bma->idx > 0) { |
1638 | state |= BMAP_LEFT_VALID; | 1629 | state |= BMAP_LEFT_VALID; |
1639 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *idx - 1), &left); | 1630 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, bma->idx - 1), &left); |
1640 | if (isnullstartblock(left.br_startblock)) | 1631 | if (isnullstartblock(left.br_startblock)) |
1641 | state |= BMAP_LEFT_DELAY; | 1632 | state |= BMAP_LEFT_DELAY; |
1642 | } | 1633 | } |
@@ -1645,9 +1636,9 @@ xfs_bmap_add_extent_hole_real( | |||
1645 | * Check and set flags if this segment has a current value. | 1636 | * Check and set flags if this segment has a current value. |
1646 | * Not true if we're inserting into the "hole" at eof. | 1637 | * Not true if we're inserting into the "hole" at eof. |
1647 | */ | 1638 | */ |
1648 | if (*idx < ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t)) { | 1639 | if (bma->idx < ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t)) { |
1649 | state |= BMAP_RIGHT_VALID; | 1640 | state |= BMAP_RIGHT_VALID; |
1650 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *idx), &right); | 1641 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, bma->idx), &right); |
1651 | if (isnullstartblock(right.br_startblock)) | 1642 | if (isnullstartblock(right.br_startblock)) |
1652 | state |= BMAP_RIGHT_DELAY; | 1643 | state |= BMAP_RIGHT_DELAY; |
1653 | } | 1644 | } |
@@ -1684,39 +1675,42 @@ xfs_bmap_add_extent_hole_real( | |||
1684 | * left and on the right. | 1675 | * left and on the right. |
1685 | * Merge all three into a single extent record. | 1676 | * Merge all three into a single extent record. |
1686 | */ | 1677 | */ |
1687 | --*idx; | 1678 | --bma->idx; |
1688 | trace_xfs_bmap_pre_update(ip, *idx, state, _THIS_IP_); | 1679 | trace_xfs_bmap_pre_update(bma->ip, bma->idx, state, _THIS_IP_); |
1689 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, *idx), | 1680 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, bma->idx), |
1690 | left.br_blockcount + new->br_blockcount + | 1681 | left.br_blockcount + new->br_blockcount + |
1691 | right.br_blockcount); | 1682 | right.br_blockcount); |
1692 | trace_xfs_bmap_post_update(ip, *idx, state, _THIS_IP_); | 1683 | trace_xfs_bmap_post_update(bma->ip, bma->idx, state, _THIS_IP_); |
1693 | 1684 | ||
1694 | xfs_iext_remove(ip, *idx + 1, 1, state); | 1685 | xfs_iext_remove(bma->ip, bma->idx + 1, 1, state); |
1695 | 1686 | ||
1696 | XFS_IFORK_NEXT_SET(ip, whichfork, | 1687 | XFS_IFORK_NEXT_SET(bma->ip, whichfork, |
1697 | XFS_IFORK_NEXTENTS(ip, whichfork) - 1); | 1688 | XFS_IFORK_NEXTENTS(bma->ip, whichfork) - 1); |
1698 | if (cur == NULL) { | 1689 | if (bma->cur == NULL) { |
1699 | rval = XFS_ILOG_CORE | xfs_ilog_fext(whichfork); | 1690 | rval = XFS_ILOG_CORE | xfs_ilog_fext(whichfork); |
1700 | } else { | 1691 | } else { |
1701 | rval = XFS_ILOG_CORE; | 1692 | rval = XFS_ILOG_CORE; |
1702 | if ((error = xfs_bmbt_lookup_eq(cur, | 1693 | error = xfs_bmbt_lookup_eq(bma->cur, right.br_startoff, |
1703 | right.br_startoff, | 1694 | right.br_startblock, right.br_blockcount, |
1704 | right.br_startblock, | 1695 | &i); |
1705 | right.br_blockcount, &i))) | 1696 | if (error) |
1706 | goto done; | 1697 | goto done; |
1707 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); | 1698 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
1708 | if ((error = xfs_btree_delete(cur, &i))) | 1699 | error = xfs_btree_delete(bma->cur, &i); |
1700 | if (error) | ||
1709 | goto done; | 1701 | goto done; |
1710 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); | 1702 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
1711 | if ((error = xfs_btree_decrement(cur, 0, &i))) | 1703 | error = xfs_btree_decrement(bma->cur, 0, &i); |
1704 | if (error) | ||
1712 | goto done; | 1705 | goto done; |
1713 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); | 1706 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
1714 | if ((error = xfs_bmbt_update(cur, left.br_startoff, | 1707 | error = xfs_bmbt_update(bma->cur, left.br_startoff, |
1715 | left.br_startblock, | 1708 | left.br_startblock, |
1716 | left.br_blockcount + | 1709 | left.br_blockcount + |
1717 | new->br_blockcount + | 1710 | new->br_blockcount + |
1718 | right.br_blockcount, | 1711 | right.br_blockcount, |
1719 | left.br_state))) | 1712 | left.br_state); |
1713 | if (error) | ||
1720 | goto done; | 1714 | goto done; |
1721 | } | 1715 | } |
1722 | break; | 1716 | break; |
@@ -1727,27 +1721,28 @@ xfs_bmap_add_extent_hole_real( | |||
1727 | * on the left. | 1721 | * on the left. |
1728 | * Merge the new allocation with the left neighbor. | 1722 | * Merge the new allocation with the left neighbor. |
1729 | */ | 1723 | */ |
1730 | --*idx; | 1724 | --bma->idx; |
1731 | trace_xfs_bmap_pre_update(ip, *idx, state, _THIS_IP_); | 1725 | trace_xfs_bmap_pre_update(bma->ip, bma->idx, state, _THIS_IP_); |
1732 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, *idx), | 1726 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, bma->idx), |
1733 | left.br_blockcount + new->br_blockcount); | 1727 | left.br_blockcount + new->br_blockcount); |
1734 | trace_xfs_bmap_post_update(ip, *idx, state, _THIS_IP_); | 1728 | trace_xfs_bmap_post_update(bma->ip, bma->idx, state, _THIS_IP_); |
1735 | 1729 | ||
1736 | if (cur == NULL) { | 1730 | if (bma->cur == NULL) { |
1737 | rval = xfs_ilog_fext(whichfork); | 1731 | rval = xfs_ilog_fext(whichfork); |
1738 | } else { | 1732 | } else { |
1739 | rval = 0; | 1733 | rval = 0; |
1740 | if ((error = xfs_bmbt_lookup_eq(cur, | 1734 | error = xfs_bmbt_lookup_eq(bma->cur, left.br_startoff, |
1741 | left.br_startoff, | 1735 | left.br_startblock, left.br_blockcount, |
1742 | left.br_startblock, | 1736 | &i); |
1743 | left.br_blockcount, &i))) | 1737 | if (error) |
1744 | goto done; | 1738 | goto done; |
1745 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); | 1739 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
1746 | if ((error = xfs_bmbt_update(cur, left.br_startoff, | 1740 | error = xfs_bmbt_update(bma->cur, left.br_startoff, |
1747 | left.br_startblock, | 1741 | left.br_startblock, |
1748 | left.br_blockcount + | 1742 | left.br_blockcount + |
1749 | new->br_blockcount, | 1743 | new->br_blockcount, |
1750 | left.br_state))) | 1744 | left.br_state); |
1745 | if (error) | ||
1751 | goto done; | 1746 | goto done; |
1752 | } | 1747 | } |
1753 | break; | 1748 | break; |
@@ -1758,28 +1753,30 @@ xfs_bmap_add_extent_hole_real( | |||
1758 | * on the right. | 1753 | * on the right. |
1759 | * Merge the new allocation with the right neighbor. | 1754 | * Merge the new allocation with the right neighbor. |
1760 | */ | 1755 | */ |
1761 | trace_xfs_bmap_pre_update(ip, *idx, state, _THIS_IP_); | 1756 | trace_xfs_bmap_pre_update(bma->ip, bma->idx, state, _THIS_IP_); |
1762 | xfs_bmbt_set_allf(xfs_iext_get_ext(ifp, *idx), | 1757 | xfs_bmbt_set_allf(xfs_iext_get_ext(ifp, bma->idx), |
1763 | new->br_startoff, new->br_startblock, | 1758 | new->br_startoff, new->br_startblock, |
1764 | new->br_blockcount + right.br_blockcount, | 1759 | new->br_blockcount + right.br_blockcount, |
1765 | right.br_state); | 1760 | right.br_state); |
1766 | trace_xfs_bmap_post_update(ip, *idx, state, _THIS_IP_); | 1761 | trace_xfs_bmap_post_update(bma->ip, bma->idx, state, _THIS_IP_); |
1767 | 1762 | ||
1768 | if (cur == NULL) { | 1763 | if (bma->cur == NULL) { |
1769 | rval = xfs_ilog_fext(whichfork); | 1764 | rval = xfs_ilog_fext(whichfork); |
1770 | } else { | 1765 | } else { |
1771 | rval = 0; | 1766 | rval = 0; |
1772 | if ((error = xfs_bmbt_lookup_eq(cur, | 1767 | error = xfs_bmbt_lookup_eq(bma->cur, |
1773 | right.br_startoff, | 1768 | right.br_startoff, |
1774 | right.br_startblock, | 1769 | right.br_startblock, |
1775 | right.br_blockcount, &i))) | 1770 | right.br_blockcount, &i); |
1771 | if (error) | ||
1776 | goto done; | 1772 | goto done; |
1777 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); | 1773 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
1778 | if ((error = xfs_bmbt_update(cur, new->br_startoff, | 1774 | error = xfs_bmbt_update(bma->cur, new->br_startoff, |
1779 | new->br_startblock, | 1775 | new->br_startblock, |
1780 | new->br_blockcount + | 1776 | new->br_blockcount + |
1781 | right.br_blockcount, | 1777 | right.br_blockcount, |
1782 | right.br_state))) | 1778 | right.br_state); |
1779 | if (error) | ||
1783 | goto done; | 1780 | goto done; |
1784 | } | 1781 | } |
1785 | break; | 1782 | break; |
@@ -1790,21 +1787,23 @@ xfs_bmap_add_extent_hole_real( | |||
1790 | * real allocation. | 1787 | * real allocation. |
1791 | * Insert a new entry. | 1788 | * Insert a new entry. |
1792 | */ | 1789 | */ |
1793 | xfs_iext_insert(ip, *idx, 1, new, state); | 1790 | xfs_iext_insert(bma->ip, bma->idx, 1, new, state); |
1794 | XFS_IFORK_NEXT_SET(ip, whichfork, | 1791 | XFS_IFORK_NEXT_SET(bma->ip, whichfork, |
1795 | XFS_IFORK_NEXTENTS(ip, whichfork) + 1); | 1792 | XFS_IFORK_NEXTENTS(bma->ip, whichfork) + 1); |
1796 | if (cur == NULL) { | 1793 | if (bma->cur == NULL) { |
1797 | rval = XFS_ILOG_CORE | xfs_ilog_fext(whichfork); | 1794 | rval = XFS_ILOG_CORE | xfs_ilog_fext(whichfork); |
1798 | } else { | 1795 | } else { |
1799 | rval = XFS_ILOG_CORE; | 1796 | rval = XFS_ILOG_CORE; |
1800 | if ((error = xfs_bmbt_lookup_eq(cur, | 1797 | error = xfs_bmbt_lookup_eq(bma->cur, |
1801 | new->br_startoff, | 1798 | new->br_startoff, |
1802 | new->br_startblock, | 1799 | new->br_startblock, |
1803 | new->br_blockcount, &i))) | 1800 | new->br_blockcount, &i); |
1801 | if (error) | ||
1804 | goto done; | 1802 | goto done; |
1805 | XFS_WANT_CORRUPTED_GOTO(i == 0, done); | 1803 | XFS_WANT_CORRUPTED_GOTO(i == 0, done); |
1806 | cur->bc_rec.b.br_state = new->br_state; | 1804 | bma->cur->bc_rec.b.br_state = new->br_state; |
1807 | if ((error = xfs_btree_insert(cur, &i))) | 1805 | error = xfs_btree_insert(bma->cur, &i); |
1806 | if (error) | ||
1808 | goto done; | 1807 | goto done; |
1809 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); | 1808 | XFS_WANT_CORRUPTED_GOTO(i == 1, done); |
1810 | } | 1809 | } |
@@ -1812,26 +1811,26 @@ xfs_bmap_add_extent_hole_real( | |||
1812 | } | 1811 | } |
1813 | 1812 | ||
1814 | /* convert to a btree if necessary */ | 1813 | /* convert to a btree if necessary */ |
1815 | if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_EXTENTS && | 1814 | if (XFS_IFORK_FORMAT(bma->ip, whichfork) == XFS_DINODE_FMT_EXTENTS && |
1816 | XFS_IFORK_NEXTENTS(ip, whichfork) > ifp->if_ext_max) { | 1815 | XFS_IFORK_NEXTENTS(bma->ip, whichfork) > ifp->if_ext_max) { |
1817 | int tmp_logflags; /* partial log flag return val */ | 1816 | int tmp_logflags; /* partial log flag return val */ |
1818 | 1817 | ||
1819 | ASSERT(cur == NULL); | 1818 | ASSERT(bma->cur == NULL); |
1820 | error = xfs_bmap_extents_to_btree(tp, ip, first, | 1819 | error = xfs_bmap_extents_to_btree(bma->tp, bma->ip, |
1821 | flist, &cur, 0, &tmp_logflags, whichfork); | 1820 | bma->firstblock, bma->flist, &bma->cur, |
1822 | *logflagsp |= tmp_logflags; | 1821 | 0, &tmp_logflags, whichfork); |
1822 | bma->logflags |= tmp_logflags; | ||
1823 | if (error) | 1823 | if (error) |
1824 | goto done; | 1824 | goto done; |
1825 | } | 1825 | } |
1826 | 1826 | ||
1827 | /* clear out the allocated field, done with it now in any case. */ | 1827 | /* clear out the allocated field, done with it now in any case. */ |
1828 | if (cur) { | 1828 | if (bma->cur) |
1829 | cur->bc_private.b.allocated = 0; | 1829 | bma->cur->bc_private.b.allocated = 0; |
1830 | *curp = cur; | 1830 | |
1831 | } | 1831 | xfs_bmap_check_leaf_extents(bma->cur, bma->ip, whichfork); |
1832 | xfs_bmap_check_leaf_extents(cur, ip, whichfork); | ||
1833 | done: | 1832 | done: |
1834 | *logflagsp |= rval; | 1833 | bma->logflags |= rval; |
1835 | return error; | 1834 | return error; |
1836 | } | 1835 | } |
1837 | 1836 | ||
@@ -4709,14 +4708,10 @@ xfs_bmapi_allocate( | |||
4709 | xfs_sb_version_hasextflgbit(&mp->m_sb)) | 4708 | xfs_sb_version_hasextflgbit(&mp->m_sb)) |
4710 | bma->got.br_state = XFS_EXT_UNWRITTEN; | 4709 | bma->got.br_state = XFS_EXT_UNWRITTEN; |
4711 | 4710 | ||
4712 | if (bma->wasdel) { | 4711 | if (bma->wasdel) |
4713 | error = xfs_bmap_add_extent_delay_real(bma); | 4712 | error = xfs_bmap_add_extent_delay_real(bma); |
4714 | } else { | 4713 | else |
4715 | error = xfs_bmap_add_extent_hole_real(bma->tp, bma->ip, | 4714 | error = xfs_bmap_add_extent_hole_real(bma, whichfork); |
4716 | &bma->idx, &bma->cur, &bma->got, | ||
4717 | bma->firstblock, bma->flist, &tmp_logflags, | ||
4718 | whichfork); | ||
4719 | } | ||
4720 | 4715 | ||
4721 | bma->logflags |= tmp_logflags; | 4716 | bma->logflags |= tmp_logflags; |
4722 | if (error) | 4717 | if (error) |