From: Jason Dillaman Date: Tue, 15 Mar 2016 20:34:26 +0000 (-0400) Subject: librbd: implement mirror image resync request API X-Git-Tag: v10.1.0~70^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F8138%2Fhead;p=ceph.git librbd: implement mirror image resync request API Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index 8b10bd1bcdb9..4aa480de1cbb 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -2580,7 +2580,31 @@ int validate_mirroring_enabled(ImageCtx *ictx) { int mirror_image_resync(ImageCtx *ictx) { CephContext *cct = ictx->cct; ldout(cct, 20) << __func__ << ": ictx=" << ictx << dendl; - return -EOPNOTSUPP; + + int r = validate_mirroring_enabled(ictx); + if (r < 0) { + return r; + } + + std::string mirror_uuid; + r = Journal<>::get_tag_owner(ictx, &mirror_uuid); + if (r < 0) { + lderr(cct) << "failed to determine tag ownership: " << cpp_strerror(r) + << dendl; + return r; + } else if (mirror_uuid == Journal<>::LOCAL_MIRROR_UUID) { + lderr(cct) << "image is primary, cannot resync to itself" << dendl; + return -EINVAL; + } + + // flag the journal indicating that we want to rebuild the local image + r = Journal<>::request_resync(ictx); + if (r < 0) { + lderr(cct) << "failed to request resync: " << cpp_strerror(r) << dendl; + return r; + } + + return 0; } int mirror_image_get_info(ImageCtx *ictx, mirror_image_info_t *mirror_image_info,