]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: deep-copy object copy should register an in-flight op
authorJason Dillaman <dillaman@redhat.com>
Mon, 1 Apr 2019 18:48:47 +0000 (14:48 -0400)
committerJason Dillaman <dillaman@redhat.com>
Wed, 15 May 2019 20:05:16 +0000 (16:05 -0400)
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 <dillaman@redhat.com>
(cherry picked from commit 89cfa6c8d328b9294c7f7efd53d82edcec59e66d)

src/librbd/deep_copy/ObjectCopyRequest.cc
src/librbd/deep_copy/ObjectCopyRequest.h

index 0546186208ed6d9c7b7559f98cac1b453aaf5d49..14acda37edfb696f44e55a9b0d9113cf47b92cfc 100644 (file)
@@ -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<I>::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<I>::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);
index 4b3f88e1fc6c7b550e3a0e82c69827bd8cfffb71..6df98e695ad0e97f83e1296c26bf3b14b7f49e7a 100644 (file)
@@ -19,6 +19,9 @@ class Context;
 class RWLock;
 
 namespace librbd {
+
+namespace io { class AsyncOperation; }
+
 namespace deep_copy {
 
 template <typename ImageCtxT = librbd::ImageCtx>
@@ -161,6 +164,8 @@ private:
   std::map<librados::snap_t, bool> 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);