From: Jason Dillaman Date: Mon, 1 Apr 2019 18:48:47 +0000 (-0400) Subject: librbd: deep-copy object copy should register an in-flight op X-Git-Tag: v14.2.2~183^2~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=69fbdeacd3c896da8046b2b5e20ae398910be0da;p=ceph.git librbd: deep-copy object copy should register an in-flight op When handling live migrations, the source image is the parent image of the destination image. To prevent the parent image from being closed while a request is in-flight, the object copy state machine now registers an async operation with the source image. Signed-off-by: Jason Dillaman (cherry picked from commit 89cfa6c8d328b9294c7f7efd53d82edcec59e66d) --- diff --git a/src/librbd/deep_copy/ObjectCopyRequest.cc b/src/librbd/deep_copy/ObjectCopyRequest.cc index 0546186208ed..14acda37edfb 100644 --- a/src/librbd/deep_copy/ObjectCopyRequest.cc +++ b/src/librbd/deep_copy/ObjectCopyRequest.cc @@ -8,6 +8,7 @@ #include "librbd/ObjectMap.h" #include "librbd/Utils.h" #include "librbd/io/AioCompletion.h" +#include "librbd/io/AsyncOperation.h" #include "librbd/io/ImageRequest.h" #include "librbd/io/ReadResult.h" #include "osdc/Striper.h" @@ -51,6 +52,9 @@ ObjectCopyRequest::ObjectCopyRequest(I *src_image_ctx, m_flatten(flatten), m_on_finish(on_finish) { ceph_assert(!m_snap_map.empty()); + m_src_async_op = new io::AsyncOperation(); + m_src_async_op->start_op(*util::get_image_ctx(m_src_image_ctx)); + m_src_io_ctx.dup(m_src_image_ctx->data_ctx); m_dst_io_ctx.dup(m_dst_image_ctx->data_ctx); @@ -958,6 +962,9 @@ void ObjectCopyRequest::finish(int r) { // ensure IoCtxs are closed prior to proceeding auto on_finish = m_on_finish; + + m_src_async_op->finish_op(); + delete m_src_async_op; delete this; on_finish->complete(r); diff --git a/src/librbd/deep_copy/ObjectCopyRequest.h b/src/librbd/deep_copy/ObjectCopyRequest.h index 4b3f88e1fc6c..6df98e695ad0 100644 --- a/src/librbd/deep_copy/ObjectCopyRequest.h +++ b/src/librbd/deep_copy/ObjectCopyRequest.h @@ -19,6 +19,9 @@ class Context; class RWLock; namespace librbd { + +namespace io { class AsyncOperation; } + namespace deep_copy { template @@ -161,6 +164,8 @@ private: std::map m_dst_object_may_exist; bufferlist m_read_from_parent_data; + io::AsyncOperation* m_src_async_op = nullptr; + void send_list_snaps(); void handle_list_snaps(int r);