From 89cfa6c8d328b9294c7f7efd53d82edcec59e66d Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Mon, 1 Apr 2019 14:48:47 -0400 Subject: [PATCH] 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 --- src/librbd/deep_copy/ObjectCopyRequest.cc | 7 +++++++ src/librbd/deep_copy/ObjectCopyRequest.h | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/src/librbd/deep_copy/ObjectCopyRequest.cc b/src/librbd/deep_copy/ObjectCopyRequest.cc index f3b5e67413cd..b28fde452b2c 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); -- 2.47.3