diff options
-rw-r--r-- | fs/btrfs/transaction.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 2b3590b9fe98..56695595e036 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
@@ -1241,12 +1241,20 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, | |||
1241 | schedule_timeout(1); | 1241 | schedule_timeout(1); |
1242 | 1242 | ||
1243 | finish_wait(&cur_trans->writer_wait, &wait); | 1243 | finish_wait(&cur_trans->writer_wait, &wait); |
1244 | spin_lock(&root->fs_info->trans_lock); | ||
1245 | root->fs_info->trans_no_join = 1; | ||
1246 | spin_unlock(&root->fs_info->trans_lock); | ||
1247 | } while (atomic_read(&cur_trans->num_writers) > 1 || | 1244 | } while (atomic_read(&cur_trans->num_writers) > 1 || |
1248 | (should_grow && cur_trans->num_joined != joined)); | 1245 | (should_grow && cur_trans->num_joined != joined)); |
1249 | 1246 | ||
1247 | /* | ||
1248 | * Ok now we need to make sure to block out any other joins while we | ||
1249 | * commit the transaction. We could have started a join before setting | ||
1250 | * no_join so make sure to wait for num_writers to == 1 again. | ||
1251 | */ | ||
1252 | spin_lock(&root->fs_info->trans_lock); | ||
1253 | root->fs_info->trans_no_join = 1; | ||
1254 | spin_unlock(&root->fs_info->trans_lock); | ||
1255 | wait_event(cur_trans->writer_wait, | ||
1256 | atomic_read(&cur_trans->num_writers) == 1); | ||
1257 | |||
1250 | ret = create_pending_snapshots(trans, root->fs_info); | 1258 | ret = create_pending_snapshots(trans, root->fs_info); |
1251 | BUG_ON(ret); | 1259 | BUG_ON(ret); |
1252 | 1260 | ||