diff options
author | Vikhyat Umrao <vumrao@redhat.com> | 2016-06-02 19:15:48 +0200 |
---|---|---|
committer | Vikhyat Umrao <vumrao@redhat.com> | 2016-06-07 05:36:25 +0200 |
commit | a00720d9aac309a34801b5ef68e28bed1a7501ea (patch) | |
tree | 7dc812bf7aac5ef0445c92d57982c70155328134 /src/tools/rbd | |
parent | Merge pull request #9527 from linuxbox2/rgw-ldap (diff) | |
download | ceph-a00720d9aac309a34801b5ef68e28bed1a7501ea.tar.xz ceph-a00720d9aac309a34801b5ef68e28bed1a7501ea.zip |
rbd: add error message "snapshot is already protected"
Fixes: http://tracker.ceph.com/issues/15807
Signed-off-by: Vikhyat Umrao <vumrao@redhat.com>
Diffstat (limited to 'src/tools/rbd')
-rw-r--r-- | src/tools/rbd/action/Snap.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/tools/rbd/action/Snap.cc b/src/tools/rbd/action/Snap.cc index 345e747fb9c..1818e4ed313 100644 --- a/src/tools/rbd/action/Snap.cc +++ b/src/tools/rbd/action/Snap.cc @@ -365,6 +365,17 @@ int execute_protect(const po::variables_map &vm) { return r; } + bool is_protected = false; + r = image.snap_is_protected(snap_name.c_str(), &is_protected); + if (r < 0) { + std::cerr << "rbd: protecting snap failed: " << cpp_strerror(r) + << std::endl; + return r; + } else if (is_protected) { + std::cerr << "rbd: snap is already protected" << std::endl; + return -EBUSY; + } + r = do_protect_snap(image, snap_name.c_str()); if (r < 0) { std::cerr << "rbd: protecting snap failed: " << cpp_strerror(r) @@ -399,6 +410,17 @@ int execute_unprotect(const po::variables_map &vm) { if (r < 0) { return r; } + + bool is_protected = false; + r = image.snap_is_protected(snap_name.c_str(), &is_protected); + if (r < 0) { + std::cerr << "rbd: unprotecting snap failed: " << cpp_strerror(r) + << std::endl; + return r; + } else if (!is_protected) { + std::cerr << "rbd: snap is already unprotected" << std::endl; + return -EINVAL; + } r = do_unprotect_snap(image, snap_name.c_str()); if (r < 0) { |