]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/deep_copy: added new migrating flag to object copy 41788/head
authorJason Dillaman <dillaman@redhat.com>
Tue, 8 Dec 2020 19:16:49 +0000 (14:16 -0500)
committerMykola Golub <mgolub@suse.com>
Wed, 9 Jun 2021 12:25:30 +0000 (15:25 +0300)
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)

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

index 682bdf24ed3f9ffd23c75728c8858e2bd4ce1d38..17723cdd2baa59373d78c15eee9857b0a7fff241 100644 (file)
@@ -342,7 +342,9 @@ 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);
   }
@@ -384,7 +386,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 f2422af526067f1dbc3307449eff24b394c820a5..fb630cec72344a4d76cda6eb6aec98423e0b29fc 100644 (file)
@@ -232,7 +232,7 @@ void CopyupRequest<I>::deep_copy() {
 
   ldout(cct, 20) << "oid=" << m_oid << ", 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 ddfd216c90e016081b3f35347f9b25d487b8c806..c6a14d6e9f607ab644436ed40c37545308a6ace0 100644 (file)
@@ -130,7 +130,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;
       }