diff options
author | Josef Bacik <josef@redhat.com> | 2011-06-14 15:16:14 -0400 |
---|---|---|
committer | Josef Bacik <josef@redhat.com> | 2011-06-15 13:24:46 -0400 |
commit | 8351583e3f6e430ce8f71913909a96ad5cc6a2f6 (patch) | |
tree | f345f40f94d12ffe090735f19aebc96c72be44bd /fs/btrfs | |
parent | 71d7aed014457147e8f71a843d5fbf03235e4a85 (diff) | |
download | linux-3.10-8351583e3f6e430ce8f71913909a96ad5cc6a2f6.tar.gz linux-3.10-8351583e3f6e430ce8f71913909a96ad5cc6a2f6.tar.bz2 linux-3.10-8351583e3f6e430ce8f71913909a96ad5cc6a2f6.zip |
Btrfs: protect the pending_snapshots list with trans_lock
Currently there is nothing protecting the pending_snapshots list on the
transaction. We only hold the directory mutex that we are snapshotting and a
read lock on the subvol_sem, so we could race with somebody else creating a
snapshot in a different directory and end up with list corruption. So protect
this list with the trans_lock. Thanks,
Signed-off-by: Josef Bacik <josef@redhat.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/ioctl.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index b793d112d1f..a3c4751e07d 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, |