]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: implement mirror image resync request API 8138/head
authorJason Dillaman <dillaman@redhat.com>
Tue, 15 Mar 2016 20:34:26 +0000 (16:34 -0400)
committerJason Dillaman <dillaman@redhat.com>
Wed, 16 Mar 2016 00:38:35 +0000 (20:38 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/internal.cc

index 8b10bd1bcdb927e3ba4c6eef0f17188c689aaea6..4aa480de1cbb929db33647d39aca08ae0b17929a 100644 (file)
@@ -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,