diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index c15636b17874bb1f1e181dabe5e344e2a19b45b4..5813dec5101cc1856762d33b5f1370069c8ecef5 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -3076,6 +3076,7 @@ int btrfs_unlink_subvol(struct btrfs_trans_handle *trans, ret = btrfs_update_inode(trans, root, dir); BUG_ON(ret); + btrfs_free_path(path); return 0; } diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index b793d112d1f65c80b95e06be70233cd5f5aa2654..a3c4751e07db0d7704e8ac1aa3269d7c75e3c48a 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -482,8 +482,10 @@ static int create_snapshot(struct btrfs_root *root, struct dentry *dentry, ret = btrfs_snap_reserve_metadata(trans, pending_snapshot); BUG_ON(ret); + spin_lock(&root->fs_info->trans_lock); list_add(&pending_snapshot->list, &trans->transaction->pending_snapshots); + spin_unlock(&root->fs_info->trans_lock); if (async_transid) { *async_transid = trans->transid; ret = btrfs_commit_transaction_async(trans, diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 833996a0c6286b66dc27c727525f44b35acc32b4..c073d85e14f315bd8efb38585d5cd97cf3557663 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -1298,12 +1298,20 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, schedule_timeout(1); finish_wait(&cur_trans->writer_wait, &wait); - spin_lock(&root->fs_info->trans_lock); - root->fs_info->trans_no_join = 1; - spin_unlock(&root->fs_info->trans_lock); } while (atomic_read(&cur_trans->num_writers) > 1 || (should_grow && cur_trans->num_joined != joined)); + /* + * Ok now we need to make sure to block out any other joins while we + * commit the transaction. We could have started a join before setting + * no_join so make sure to wait for num_writers to == 1 again. + */ + spin_lock(&root->fs_info->trans_lock); + root->fs_info->trans_no_join = 1; + spin_unlock(&root->fs_info->trans_lock); + wait_event(cur_trans->writer_wait, + atomic_read(&cur_trans->num_writers) == 1); + /* * the reloc mutex makes sure that we stop * the balancing code from coming in and moving