rbd: add error message "snapshot is already protected"

Fixes: http://tracker.ceph.com/issues/15807

Signed-off-by: Vikhyat Umrao <vumrao@redhat.com>
This commit is contained in:
Vikhyat Umrao 2016-06-02 22:45:48 +05:30
parent b262e46599
commit a00720d9aa

View File

@ -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) {