librbd: fixed bug in disabling non-primary image mirroring

librbd: fixed bug in disabling non-primary image mirroring

Reviewed-by: Jason Dillaman <dillaman@redhat.com>
This commit is contained in:
Jason Dillaman 2016-04-11 12:33:25 -04:00
commit 5e6783cce5

View File

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