]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/deep_copy: added new migrating flag to object copy
authorJason Dillaman <dillaman@redhat.com>
Tue, 8 Dec 2020 19:16:49 +0000 (14:16 -0500)
committerJason Dillaman <dillaman@redhat.com>
Fri, 19 Feb 2021 15:32:38 +0000 (10:32 -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>
(cherry picked from commit 1baba64e213cb808804796575d3f7969cf37a3c6)

Conflicts:
src/librbd/deep_copy/ObjectCopyRequest.cc: trivial resolution

src/librbd/deep_copy/ObjectCopyRequest.cc
src/librbd/deep_copy/Types.h
src/librbd/io/CopyupRequest.cc
src/librbd/operation/MigrateRequest.cc

index c38e9decb6ac4e2b1e0e7ccc05a67b8cddb1772d..dbe962d8b1d1e7fec393e9d22768ddbe1a3910ba 100644 (file)
@@ -428,7 +428,10 @@ void ObjectCopyRequest<I>::send_write_object() {
   librados::ObjectWriteOperation op;
   uint64_t buffer_offset;
 
-  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);
   }
@@ -470,7 +473,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 75379cc51ee593e6da049b8c8fe26a8f4a9dbea1..e461b4ec3e0042d813a6488dba12fcdc66df6a9e 100644 (file)
@@ -237,7 +237,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 f2ed0f0bb6b2228d58370f1f3f34c90588f5a506..65255b22abce4b154cce0f1dc99422b8804153c1 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;
       }