diff options
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 29e5d000bbee..ecfa52002363 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -2835,6 +2835,7 @@ int btrfs_should_throttle_delayed_refs(struct btrfs_trans_handle *trans, | |||
2835 | 2835 | ||
2836 | struct async_delayed_refs { | 2836 | struct async_delayed_refs { |
2837 | struct btrfs_root *root; | 2837 | struct btrfs_root *root; |
2838 | u64 transid; | ||
2838 | int count; | 2839 | int count; |
2839 | int error; | 2840 | int error; |
2840 | int sync; | 2841 | int sync; |
@@ -2850,9 +2851,16 @@ static void delayed_ref_async_start(struct btrfs_work *work) | |||
2850 | 2851 | ||
2851 | async = container_of(work, struct async_delayed_refs, work); | 2852 | async = container_of(work, struct async_delayed_refs, work); |
2852 | 2853 | ||
2853 | trans = btrfs_join_transaction(async->root); | 2854 | trans = btrfs_attach_transaction(async->root); |
2854 | if (IS_ERR(trans)) { | 2855 | if (IS_ERR(trans)) { |
2855 | async->error = PTR_ERR(trans); | 2856 | if (PTR_ERR(trans) != -ENOENT) |
2857 | async->error = PTR_ERR(trans); | ||
2858 | goto done; | ||
2859 | } | ||
2860 | |||
2861 | /* Don't bother flushing if we got into a different transaction */ | ||
2862 | if (trans->transid != async->transid) { | ||
2863 | btrfs_end_transaction(trans, async->root); | ||
2856 | goto done; | 2864 | goto done; |
2857 | } | 2865 | } |
2858 | 2866 | ||
@@ -2876,7 +2884,7 @@ done: | |||
2876 | } | 2884 | } |
2877 | 2885 | ||
2878 | int btrfs_async_run_delayed_refs(struct btrfs_root *root, | 2886 | int btrfs_async_run_delayed_refs(struct btrfs_root *root, |
2879 | unsigned long count, int wait) | 2887 | unsigned long count, u64 transid, int wait) |
2880 | { | 2888 | { |
2881 | struct async_delayed_refs *async; | 2889 | struct async_delayed_refs *async; |
2882 | int ret; | 2890 | int ret; |
@@ -2888,6 +2896,7 @@ int btrfs_async_run_delayed_refs(struct btrfs_root *root, | |||
2888 | async->root = root->fs_info->tree_root; | 2896 | async->root = root->fs_info->tree_root; |
2889 | async->count = count; | 2897 | async->count = count; |
2890 | async->error = 0; | 2898 | async->error = 0; |
2899 | async->transid = transid; | ||
2891 | if (wait) | 2900 | if (wait) |
2892 | async->sync = 1; | 2901 | async->sync = 1; |
2893 | else | 2902 | else |