]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: store migration progress on both source+destination images
authorJason Dillaman <dillaman@redhat.com>
Wed, 21 Oct 2020 18:16:57 +0000 (14:16 -0400)
committerJason Dillaman <dillaman@redhat.com>
Sun, 1 Nov 2020 14:22:38 +0000 (09:22 -0500)
When migrating from an import-only source-spec like an external
file, it will be important to also store the progress on the
destination image.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/api/Migration.cc

index 565257168ebdc4185f96ea177ce153768d162828..e27a7ebd8b3dbc3b1c29eef36d1bb761931418c7 100644 (file)
@@ -800,22 +800,31 @@ int Migration<I>::execute() {
     return r;
   }
 
-  while (true) {
-    MigrationProgressContext prog_ctx(m_src_image_ctx->md_ctx,
-                                      m_src_image_ctx->header_oid,
-                                      cls::rbd::MIGRATION_STATE_EXECUTING,
-                                      m_prog_ctx);
-    r = m_dst_image_ctx->operations->migrate(prog_ctx);
-    if (r == -EROFS) {
-      std::shared_lock owner_locker{m_dst_image_ctx->owner_lock};
-      if (m_dst_image_ctx->exclusive_lock != nullptr &&
+  {
+    MigrationProgressContext dst_prog_ctx(
+      m_dst_image_ctx->md_ctx, m_dst_image_ctx->header_oid,
+      cls::rbd::MIGRATION_STATE_EXECUTING, m_prog_ctx);
+    std::optional<MigrationProgressContext> src_prog_ctx;
+    if (m_src_image_ctx != nullptr) {
+      src_prog_ctx.emplace(m_src_image_ctx->md_ctx, m_src_image_ctx->header_oid,
+                           cls::rbd::MIGRATION_STATE_EXECUTING, &dst_prog_ctx);
+    }
+
+    while (true) {
+      r = m_dst_image_ctx->operations->migrate(
+        *(src_prog_ctx ? &src_prog_ctx.value() : &dst_prog_ctx));
+      if (r == -EROFS) {
+        std::shared_lock owner_locker{m_dst_image_ctx->owner_lock};
+        if (m_dst_image_ctx->exclusive_lock != nullptr &&
           !m_dst_image_ctx->exclusive_lock->accept_ops()) {
-        ldout(m_cct, 5) << "lost exclusive lock, retrying remote" << dendl;
-        continue;
+          ldout(m_cct, 5) << "lost exclusive lock, retrying remote" << dendl;
+          continue;
+        }
       }
+      break;
     }
-    break;
   }
+
   if (r < 0) {
     lderr(m_cct) << "migration failed: " << cpp_strerror(r) << dendl;
     return r;