From: Jason Dillaman Date: Wed, 21 Oct 2020 18:16:57 +0000 (-0400) Subject: librbd: store migration progress on both source+destination images X-Git-Tag: v16.1.0~702^2~15 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e5398d14298763f684c2fda0a4cea2e07bea3c6a;p=ceph.git librbd: store migration progress on both source+destination images 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 --- diff --git a/src/librbd/api/Migration.cc b/src/librbd/api/Migration.cc index 565257168ebd..e27a7ebd8b3d 100644 --- a/src/librbd/api/Migration.cc +++ b/src/librbd/api/Migration.cc @@ -800,22 +800,31 @@ int Migration::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 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;