From e91fb910653a672560867d4a81aa30f9d5dc0af8 Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Tue, 31 Dec 2013 16:26:04 -0800 Subject: [PATCH] librbd: better error when unprotect fails on unprotected snap This will show up on the command line and logs, making it more clear than EINVAL. Fixes #6851 and #4045 Signed-off-by: Josh Durgin --- qa/qa_scripts/RbdLib.pm | 3 +-- src/librbd/internal.cc | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/qa/qa_scripts/RbdLib.pm b/qa/qa_scripts/RbdLib.pm index f203b8ac084..83a506e96c3 100755 --- a/qa/qa_scripts/RbdLib.pm +++ b/qa/qa_scripts/RbdLib.pm @@ -81,8 +81,7 @@ our $SNAP_PROTECT_ERR = "Device or resource busy"; our $SNAP_PROTECT_RM_ERR = "protected from removal"; our $SNAP_PROTECT_ERR1 = "No such file or directory"; our $SNAP_UNPROT_ERR = "snap_unprotect: image must support layering"; -our $SNAP_UNPROT_ERR1 = "snap_unprotect: can't unprotect"; -#our $SNAP_UNPROTECT_ERR - bug # 4045 +our $SNAP_UNPROT_ERR1 = "snap_unprotect: snapshot is already unprotected"; our $SNAP_PROT_ERR = "snap_protect: image must support layering"; our $CLONE_UNPROTECT_ERR = "parent snapshot must be protected"; our $CLONE_ARG_ERR = "destination image name was not specified"; diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index 81b70dd310c..3d73bd0251b 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -616,8 +616,11 @@ namespace librbd { if (r < 0) return r; - if (is_unprotected) + if (is_unprotected) { + lderr(ictx->cct) << "snap_unprotect: snapshot is already unprotected" + << dendl; return -EINVAL; + } r = cls_client::set_protection_status(&ictx->md_ctx, ictx->header_oid, -- 2.47.3