diff options
Diffstat (limited to 'fs/btrfs/transaction.c')
| -rw-r--r-- | fs/btrfs/transaction.c | 39 | 
1 files changed, 17 insertions, 22 deletions
| diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 34cd83184c4a..a04707f740d6 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
| @@ -683,7 +683,8 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans, | |||
| 683 | int lock = (trans->type != TRANS_JOIN_NOLOCK); | 683 | int lock = (trans->type != TRANS_JOIN_NOLOCK); | 
| 684 | int err = 0; | 684 | int err = 0; | 
| 685 | 685 | ||
| 686 | if (--trans->use_count) { | 686 | if (trans->use_count > 1) { | 
| 687 | trans->use_count--; | ||
| 687 | trans->block_rsv = trans->orig_rsv; | 688 | trans->block_rsv = trans->orig_rsv; | 
| 688 | return 0; | 689 | return 0; | 
| 689 | } | 690 | } | 
| @@ -731,17 +732,10 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans, | |||
| 731 | } | 732 | } | 
| 732 | 733 | ||
| 733 | if (lock && ACCESS_ONCE(cur_trans->state) == TRANS_STATE_BLOCKED) { | 734 | if (lock && ACCESS_ONCE(cur_trans->state) == TRANS_STATE_BLOCKED) { | 
| 734 | if (throttle) { | 735 | if (throttle) | 
| 735 | /* | ||
| 736 | * We may race with somebody else here so end up having | ||
| 737 | * to call end_transaction on ourselves again, so inc | ||
| 738 | * our use_count. | ||
| 739 | */ | ||
| 740 | trans->use_count++; | ||
| 741 | return btrfs_commit_transaction(trans, root); | 736 | return btrfs_commit_transaction(trans, root); | 
| 742 | } else { | 737 | else | 
| 743 | wake_up_process(info->transaction_kthread); | 738 | wake_up_process(info->transaction_kthread); | 
| 744 | } | ||
| 745 | } | 739 | } | 
| 746 | 740 | ||
| 747 | if (trans->type & __TRANS_FREEZABLE) | 741 | if (trans->type & __TRANS_FREEZABLE) | 
| @@ -1578,10 +1572,9 @@ static void cleanup_transaction(struct btrfs_trans_handle *trans, | |||
| 1578 | 1572 | ||
| 1579 | trace_btrfs_transaction_commit(root); | 1573 | trace_btrfs_transaction_commit(root); | 
| 1580 | 1574 | ||
| 1581 | btrfs_scrub_continue(root); | ||
| 1582 | |||
| 1583 | if (current->journal_info == trans) | 1575 | if (current->journal_info == trans) | 
| 1584 | current->journal_info = NULL; | 1576 | current->journal_info = NULL; | 
| 1577 | btrfs_scrub_cancel(root->fs_info); | ||
| 1585 | 1578 | ||
| 1586 | kmem_cache_free(btrfs_trans_handle_cachep, trans); | 1579 | kmem_cache_free(btrfs_trans_handle_cachep, trans); | 
| 1587 | } | 1580 | } | 
| @@ -1621,7 +1614,7 @@ static int btrfs_flush_all_pending_stuffs(struct btrfs_trans_handle *trans, | |||
| 1621 | static inline int btrfs_start_delalloc_flush(struct btrfs_fs_info *fs_info) | 1614 | static inline int btrfs_start_delalloc_flush(struct btrfs_fs_info *fs_info) | 
| 1622 | { | 1615 | { | 
| 1623 | if (btrfs_test_opt(fs_info->tree_root, FLUSHONCOMMIT)) | 1616 | if (btrfs_test_opt(fs_info->tree_root, FLUSHONCOMMIT)) | 
| 1624 | return btrfs_start_delalloc_roots(fs_info, 1); | 1617 | return btrfs_start_delalloc_roots(fs_info, 1, -1); | 
| 1625 | return 0; | 1618 | return 0; | 
| 1626 | } | 1619 | } | 
| 1627 | 1620 | ||
| @@ -1754,7 +1747,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, | |||
| 1754 | /* ->aborted might be set after the previous check, so check it */ | 1747 | /* ->aborted might be set after the previous check, so check it */ | 
| 1755 | if (unlikely(ACCESS_ONCE(cur_trans->aborted))) { | 1748 | if (unlikely(ACCESS_ONCE(cur_trans->aborted))) { | 
| 1756 | ret = cur_trans->aborted; | 1749 | ret = cur_trans->aborted; | 
| 1757 | goto cleanup_transaction; | 1750 | goto scrub_continue; | 
| 1758 | } | 1751 | } | 
| 1759 | /* | 1752 | /* | 
| 1760 | * the reloc mutex makes sure that we stop | 1753 | * the reloc mutex makes sure that we stop | 
| @@ -1771,7 +1764,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, | |||
| 1771 | ret = create_pending_snapshots(trans, root->fs_info); | 1764 | ret = create_pending_snapshots(trans, root->fs_info); | 
| 1772 | if (ret) { | 1765 | if (ret) { | 
| 1773 | mutex_unlock(&root->fs_info->reloc_mutex); | 1766 | mutex_unlock(&root->fs_info->reloc_mutex); | 
| 1774 | goto cleanup_transaction; | 1767 | goto scrub_continue; | 
| 1775 | } | 1768 | } | 
| 1776 | 1769 | ||
| 1777 | /* | 1770 | /* | 
| @@ -1787,13 +1780,13 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, | |||
| 1787 | ret = btrfs_run_delayed_items(trans, root); | 1780 | ret = btrfs_run_delayed_items(trans, root); | 
| 1788 | if (ret) { | 1781 | if (ret) { | 
| 1789 | mutex_unlock(&root->fs_info->reloc_mutex); | 1782 | mutex_unlock(&root->fs_info->reloc_mutex); | 
| 1790 | goto cleanup_transaction; | 1783 | goto scrub_continue; | 
| 1791 | } | 1784 | } | 
| 1792 | 1785 | ||
| 1793 | ret = btrfs_run_delayed_refs(trans, root, (unsigned long)-1); | 1786 | ret = btrfs_run_delayed_refs(trans, root, (unsigned long)-1); | 
| 1794 | if (ret) { | 1787 | if (ret) { | 
| 1795 | mutex_unlock(&root->fs_info->reloc_mutex); | 1788 | mutex_unlock(&root->fs_info->reloc_mutex); | 
| 1796 | goto cleanup_transaction; | 1789 | goto scrub_continue; | 
| 1797 | } | 1790 | } | 
| 1798 | 1791 | ||
| 1799 | /* | 1792 | /* | 
| @@ -1823,7 +1816,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, | |||
| 1823 | if (ret) { | 1816 | if (ret) { | 
| 1824 | mutex_unlock(&root->fs_info->tree_log_mutex); | 1817 | mutex_unlock(&root->fs_info->tree_log_mutex); | 
| 1825 | mutex_unlock(&root->fs_info->reloc_mutex); | 1818 | mutex_unlock(&root->fs_info->reloc_mutex); | 
| 1826 | goto cleanup_transaction; | 1819 | goto scrub_continue; | 
| 1827 | } | 1820 | } | 
| 1828 | 1821 | ||
| 1829 | /* | 1822 | /* | 
| @@ -1844,7 +1837,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, | |||
| 1844 | if (ret) { | 1837 | if (ret) { | 
| 1845 | mutex_unlock(&root->fs_info->tree_log_mutex); | 1838 | mutex_unlock(&root->fs_info->tree_log_mutex); | 
| 1846 | mutex_unlock(&root->fs_info->reloc_mutex); | 1839 | mutex_unlock(&root->fs_info->reloc_mutex); | 
| 1847 | goto cleanup_transaction; | 1840 | goto scrub_continue; | 
| 1848 | } | 1841 | } | 
| 1849 | 1842 | ||
| 1850 | /* | 1843 | /* | 
| @@ -1855,7 +1848,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, | |||
| 1855 | ret = cur_trans->aborted; | 1848 | ret = cur_trans->aborted; | 
| 1856 | mutex_unlock(&root->fs_info->tree_log_mutex); | 1849 | mutex_unlock(&root->fs_info->tree_log_mutex); | 
| 1857 | mutex_unlock(&root->fs_info->reloc_mutex); | 1850 | mutex_unlock(&root->fs_info->reloc_mutex); | 
| 1858 | goto cleanup_transaction; | 1851 | goto scrub_continue; | 
| 1859 | } | 1852 | } | 
| 1860 | 1853 | ||
| 1861 | btrfs_prepare_extent_commit(trans, root); | 1854 | btrfs_prepare_extent_commit(trans, root); | 
| @@ -1891,13 +1884,13 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, | |||
| 1891 | btrfs_error(root->fs_info, ret, | 1884 | btrfs_error(root->fs_info, ret, | 
| 1892 | "Error while writing out transaction"); | 1885 | "Error while writing out transaction"); | 
| 1893 | mutex_unlock(&root->fs_info->tree_log_mutex); | 1886 | mutex_unlock(&root->fs_info->tree_log_mutex); | 
| 1894 | goto cleanup_transaction; | 1887 | goto scrub_continue; | 
| 1895 | } | 1888 | } | 
| 1896 | 1889 | ||
| 1897 | ret = write_ctree_super(trans, root, 0); | 1890 | ret = write_ctree_super(trans, root, 0); | 
| 1898 | if (ret) { | 1891 | if (ret) { | 
| 1899 | mutex_unlock(&root->fs_info->tree_log_mutex); | 1892 | mutex_unlock(&root->fs_info->tree_log_mutex); | 
| 1900 | goto cleanup_transaction; | 1893 | goto scrub_continue; | 
| 1901 | } | 1894 | } | 
| 1902 | 1895 | ||
| 1903 | /* | 1896 | /* | 
| @@ -1940,6 +1933,8 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, | |||
| 1940 | 1933 | ||
| 1941 | return ret; | 1934 | return ret; | 
| 1942 | 1935 | ||
| 1936 | scrub_continue: | ||
| 1937 | btrfs_scrub_continue(root); | ||
| 1943 | cleanup_transaction: | 1938 | cleanup_transaction: | 
| 1944 | btrfs_trans_release_metadata(trans, root); | 1939 | btrfs_trans_release_metadata(trans, root); | 
| 1945 | trans->block_rsv = NULL; | 1940 | trans->block_rsv = NULL; | 
