|
@@ -2835,6 +2835,7 @@ int btrfs_should_throttle_delayed_refs(struct btrfs_trans_handle *trans,
|
|
|
|
|
|
struct async_delayed_refs {
|
|
|
struct btrfs_root *root;
|
|
|
+ u64 transid;
|
|
|
int count;
|
|
|
int error;
|
|
|
int sync;
|
|
@@ -2850,9 +2851,16 @@ static void delayed_ref_async_start(struct btrfs_work *work)
|
|
|
|
|
|
async = container_of(work, struct async_delayed_refs, work);
|
|
|
|
|
|
- trans = btrfs_join_transaction(async->root);
|
|
|
+ trans = btrfs_attach_transaction(async->root);
|
|
|
if (IS_ERR(trans)) {
|
|
|
- async->error = PTR_ERR(trans);
|
|
|
+ if (PTR_ERR(trans) != -ENOENT)
|
|
|
+ async->error = PTR_ERR(trans);
|
|
|
+ goto done;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* Don't bother flushing if we got into a different transaction */
|
|
|
+ if (trans->transid != async->transid) {
|
|
|
+ btrfs_end_transaction(trans, async->root);
|
|
|
goto done;
|
|
|
}
|
|
|
|
|
@@ -2876,7 +2884,7 @@ done:
|
|
|
}
|
|
|
|
|
|
int btrfs_async_run_delayed_refs(struct btrfs_root *root,
|
|
|
- unsigned long count, int wait)
|
|
|
+ unsigned long count, u64 transid, int wait)
|
|
|
{
|
|
|
struct async_delayed_refs *async;
|
|
|
int ret;
|
|
@@ -2888,6 +2896,7 @@ int btrfs_async_run_delayed_refs(struct btrfs_root *root,
|
|
|
async->root = root->fs_info->tree_root;
|
|
|
async->count = count;
|
|
|
async->error = 0;
|
|
|
+ async->transid = transid;
|
|
|
if (wait)
|
|
|
async->sync = 1;
|
|
|
else
|