]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/deep_copy: added new migrating flag to object copy 38494/head
authorJason Dillaman <dillaman@redhat.com>
Tue, 8 Dec 2020 19:16:49 +0000 (14:16 -0500)
committerJason Dillaman <dillaman@redhat.com>
Fri, 11 Dec 2020 13:03:07 +0000 (08:03 -0500)
The migration operation and the copyup state machine will set
this flag when attempting to perform a deep-copy due to a
live-migration.

This flag will prevent a possible race condition between the
start of the object deep-copy when migration was enabled and
the writing portion of the deep-copy when migration might
have completed via external means.

Fixes: https://tracker.ceph.com/issues/45694
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/deep_copy/ObjectCopyRequest.cc
src/librbd/deep_copy/Types.h
src/librbd/io/CopyupRequest.cc
src/librbd/operation/MigrateRequest.cc

index 21153cfed084a5bc2e861a686f3db9d81fd26312..80b06c15cfbbe1bc33a66a4b38d6c20ab826cd83 100644 (file)
@@ -339,7 +339,9 @@ void ObjectCopyRequest<I>::send_write_object() {
                    << "dst_snaps=" << dst_snap_ids << dendl;
 
   librados::ObjectWriteOperation op;
-  if (!m_dst_image_ctx->migration_info.empty()) {
+
+  bool migration = ((m_flags & OBJECT_COPY_REQUEST_FLAG_MIGRATION) != 0);
+  if (migration) {
     ldout(m_cct, 20) << "assert_snapc_seq=" << dst_snap_seq << dendl;
     cls_client::assert_snapc_seq(&op, dst_snap_seq,
                                  cls::rbd::ASSERT_SNAPC_SEQ_GT_SNAPSET_SEQ);
@@ -381,7 +383,7 @@ void ObjectCopyRequest<I>::send_write_object() {
     }
   }
 
-  if (op.size() == (m_dst_image_ctx->migration_info.empty() ? 0 : 1)) {
+  if (op.size() == (migration ? 1 : 0)) {
     handle_write_object(0);
     return;
   }
index 0b24dae2bec1d97a5cae2edd5bdc4f0666d1ff62..e6aa980494b12a37236c34e1db2c7fe55a7f277a 100644 (file)
@@ -12,7 +12,8 @@ namespace librbd {
 namespace deep_copy {
 
 enum {
-  OBJECT_COPY_REQUEST_FLAG_FLATTEN = 1U << 0,
+  OBJECT_COPY_REQUEST_FLAG_FLATTEN   = 1U << 0,
+  OBJECT_COPY_REQUEST_FLAG_MIGRATION = 1U << 1,
 };
 
 typedef std::vector<librados::snap_t> SnapIds;
index 43c856173ce86f4cb4494a68ba7d4cfd1229e4bc..d70851409fd7a37d64f212b100673c6c7309e448 100644 (file)
@@ -258,7 +258,7 @@ void CopyupRequest<I>::deep_copy() {
 
   ldout(cct, 20) << "flatten=" << m_flatten << dendl;
 
-  uint32_t flags = 0;
+  uint32_t flags = deep_copy::OBJECT_COPY_REQUEST_FLAG_MIGRATION;
   if (m_flatten) {
     flags |= deep_copy::OBJECT_COPY_REQUEST_FLAG_FLATTEN;
   }
index 487df9970a874bcb610646fdc5d0d7cd2d8d3934..2b9adb7737807d13d125ff0849e2992349e10761 100644 (file)
@@ -128,7 +128,7 @@ private:
     } else {
       ceph_assert(image_ctx.parent != nullptr);
 
-      uint32_t flags = 0;
+      uint32_t flags = deep_copy::OBJECT_COPY_REQUEST_FLAG_MIGRATION;
       if (image_ctx.migration_info.flatten) {
         flags |= deep_copy::OBJECT_COPY_REQUEST_FLAG_FLATTEN;
       }