aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/btrfs/send.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index bff0b1ac3be7..5b6978516461 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -4752,6 +4752,7 @@ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_)
4752 u32 i; 4752 u32 i;
4753 u64 *clone_sources_tmp = NULL; 4753 u64 *clone_sources_tmp = NULL;
4754 int clone_sources_to_rollback = 0; 4754 int clone_sources_to_rollback = 0;
4755 int sort_clone_roots = 0;
4755 4756
4756 if (!capable(CAP_SYS_ADMIN)) 4757 if (!capable(CAP_SYS_ADMIN))
4757 return -EPERM; 4758 return -EPERM;
@@ -4942,6 +4943,7 @@ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_)
4942 sort(sctx->clone_roots, sctx->clone_roots_cnt, 4943 sort(sctx->clone_roots, sctx->clone_roots_cnt,
4943 sizeof(*sctx->clone_roots), __clone_root_cmp_sort, 4944 sizeof(*sctx->clone_roots), __clone_root_cmp_sort,
4944 NULL); 4945 NULL);
4946 sort_clone_roots = 1;
4945 4947
4946 ret = send_subvol(sctx); 4948 ret = send_subvol(sctx);
4947 if (ret < 0) 4949 if (ret < 0)
@@ -4957,11 +4959,19 @@ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_)
4957 } 4959 }
4958 4960
4959out: 4961out:
4960 for (i = 0; sctx && i < clone_sources_to_rollback; i++) 4962 if (sort_clone_roots) {
4961 btrfs_root_dec_send_in_progress(sctx->clone_roots[i].root); 4963 for (i = 0; i < sctx->clone_roots_cnt; i++)
4964 btrfs_root_dec_send_in_progress(
4965 sctx->clone_roots[i].root);
4966 } else {
4967 for (i = 0; sctx && i < clone_sources_to_rollback; i++)
4968 btrfs_root_dec_send_in_progress(
4969 sctx->clone_roots[i].root);
4970
4971 btrfs_root_dec_send_in_progress(send_root);
4972 }
4962 if (sctx && !IS_ERR_OR_NULL(sctx->parent_root)) 4973 if (sctx && !IS_ERR_OR_NULL(sctx->parent_root))
4963 btrfs_root_dec_send_in_progress(sctx->parent_root); 4974 btrfs_root_dec_send_in_progress(sctx->parent_root);
4964 btrfs_root_dec_send_in_progress(send_root);
4965 4975
4966 kfree(arg); 4976 kfree(arg);
4967 vfree(clone_sources_tmp); 4977 vfree(clone_sources_tmp);