From: Ricardo Dias Date: Thu, 17 Mar 2016 11:40:48 +0000 (+0000) Subject: rbd: rbd-mirroring: Enable image mirroring when journaling feature is enabled X-Git-Tag: v10.1.0~19^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ba6c0c9d4cc7675a71741bddf2e8266117b689c8;p=ceph.git rbd: rbd-mirroring: Enable image mirroring when journaling feature is enabled Signed-off-by: Ricardo Dias --- diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index 94c33b5faa4c..df658354a9b0 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -1391,6 +1391,7 @@ int validate_mirroring_enabled(ImageCtx *ictx) { return 0; } + bool enable_mirroring = false; uint64_t features_mask = features; uint64_t disable_flags = 0; if (enabled) { @@ -1427,6 +1428,16 @@ int validate_mirroring_enabled(ImageCtx *ictx) { << dendl; return r; } + + rbd_mirror_mode_t mirror_mode; + r = librbd::mirror_mode_get(ictx->md_ctx, &mirror_mode); + if (r < 0) { + lderr(cct) << "error in retrieving pool mirroring status: " + << cpp_strerror(r) << dendl; + return r; + } + + enable_mirroring = (mirror_mode == RBD_MIRROR_MODE_POOL); } if (enable_flags != 0) { @@ -1495,7 +1506,24 @@ int validate_mirroring_enabled(ImageCtx *ictx) { return r; } } - } + + if (enable_mirroring) { + ImageCtx *img_ctx = new ImageCtx("", ictx->id, nullptr, + ictx->md_ctx, false); + r = img_ctx->state->open(); + if (r < 0) { + lderr(cct) << "error opening image: " << cpp_strerror(r) << dendl; + delete img_ctx; + } else { + r = mirror_image_enable(img_ctx); + if (r < 0) { + lderr(cct) << "error enabling mirroring: " << cpp_strerror(r) + << dendl; + } + img_ctx->state->close(); + } + } + } ictx->notify_update(); return 0;