summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ioctl.c
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@gmail.com>2014-05-25 03:55:44 +0100
committerChris Mason <clm@fb.com>2014-06-09 17:21:03 -0700
commitc55bfa67e94e22ec0449fe7c55b3ef20fbe13348 (patch)
tree5c56b113d932a22ef584926f7ef9429baa9f3396 /fs/btrfs/ioctl.c
parentc125b8bff1d9f6c8c91ce4eb8bd5616058c7d510 (diff)
downloadlinux-c55bfa67e94e22ec0449fe7c55b3ef20fbe13348.tar.bz2
Btrfs: set dead flag on the right root when destroying snapshot
We were setting the BTRFS_ROOT_SUBVOL_DEAD flag on the root of the parent of our target snapshot, instead of setting it in the target snapshot's root. This is easy to observe by running the following scenario: mkfs.btrfs -f /dev/sdd mount /dev/sdd /mnt btrfs subvolume create /mnt/first_subvol btrfs subvolume snapshot -r /mnt /mnt/mysnap1 btrfs subvolume delete /mnt/first_subvol btrfs subvolume snapshot -r /mnt /mnt/mysnap2 btrfs send -p /mnt/mysnap1 /mnt/mysnap2 -f /tmp/send.data The send command failed because the send ioctl returned -EPERM. A test case for xfstests follows. Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Reviewed-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/ioctl.c')
-rw-r--r--fs/btrfs/ioctl.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 362720a3fea2..38f2169b73a4 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2312,16 +2312,16 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
* again is not run concurrently.
*/
spin_lock(&dest->root_item_lock);
- root_flags = btrfs_root_flags(&root->root_item);
- if (root->send_in_progress == 0) {
- btrfs_set_root_flags(&root->root_item,
+ root_flags = btrfs_root_flags(&dest->root_item);
+ if (dest->send_in_progress == 0) {
+ btrfs_set_root_flags(&dest->root_item,
root_flags | BTRFS_ROOT_SUBVOL_DEAD);
spin_unlock(&dest->root_item_lock);
} else {
spin_unlock(&dest->root_item_lock);
btrfs_warn(root->fs_info,
"Attempt to delete subvolume %llu during send",
- root->root_key.objectid);
+ dest->root_key.objectid);
err = -EPERM;
goto out_dput;
}
@@ -2416,8 +2416,8 @@ out_up_write:
out_unlock:
if (err) {
spin_lock(&dest->root_item_lock);
- root_flags = btrfs_root_flags(&root->root_item);
- btrfs_set_root_flags(&root->root_item,
+ root_flags = btrfs_root_flags(&dest->root_item);
+ btrfs_set_root_flags(&dest->root_item,
root_flags & ~BTRFS_ROOT_SUBVOL_DEAD);
spin_unlock(&dest->root_item_lock);
}