From: Ricardo Dias Date: Fri, 8 Apr 2016 20:40:20 +0000 (+0100) Subject: librbd: Fixed bug in disabling non-primary image mirroring X-Git-Tag: v10.1.2~6^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F8512%2Fhead;p=ceph.git librbd: Fixed bug in disabling non-primary image mirroring It is only possible to remove image from rbd_mirroring object if the mirroring image state is set to DISABLING. Signed-off-by: Ricardo Dias --- diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index 2abc1a2559b7..983e622b9da9 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -312,13 +312,10 @@ int mirror_image_disable_internal(ImageCtx *ictx, bool force) { return r; } - if (!is_primary) { - if (!force) { - lderr(cct) << "Mirrored image is not the primary, add force option to" - " disable mirroring" << dendl; - return -EINVAL; - } - goto remove_mirroring_image; + if (!is_primary && !force) { + lderr(cct) << "Mirrored image is not the primary, add force option to" + " disable mirroring" << dendl; + return -EINVAL; } mirror_image_internal.state = cls::rbd::MIRROR_IMAGE_STATE_DISABLING; @@ -329,6 +326,10 @@ int mirror_image_disable_internal(ImageCtx *ictx, bool force) { return r; } + if (!is_primary) { + goto remove_mirroring_image; + } + r = MirroringWatcher<>::notify_image_updated( ictx->md_ctx, cls::rbd::MIRROR_IMAGE_STATE_DISABLING, ictx->id, mirror_image_internal.global_image_id);