]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: reverting changes to ImageSync
authorPrasanna Kumar Kalever <prasanna.kalever@redhat.com>
Thu, 6 Mar 2025 07:53:19 +0000 (13:23 +0530)
committerPrasanna Kumar Kalever <prasanna.kalever@redhat.com>
Thu, 24 Apr 2025 15:56:32 +0000 (21:26 +0530)
ImageSync should never be needed for snapshot-based mirroring.

Credits and thanks to Nithya and Ilya for highlighting it.

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
src/test/rbd_mirror/test_ImageSync.cc
src/tools/rbd_mirror/ImageSync.cc
src/tools/rbd_mirror/ImageSync.h
src/tools/rbd_mirror/image_replayer/BootstrapRequest.cc

index 06cc0f65f3cfc0ca3ac85bff24afb82f390fc811..9418496bce2d44cd646a8f3375377b92659b736e 100644 (file)
@@ -136,10 +136,9 @@ public:
   }
 
   ImageSync<> *create_request(Context *ctx) {
-    return new ImageSync<>(m_threads, nullptr, m_local_image_ctx,
-                           m_remote_image_ctx, "mirror-uuid",
-                           m_sync_point_handler, m_instance_watcher, nullptr,
-                           ctx);
+    return new ImageSync<>(m_threads, m_local_image_ctx, m_remote_image_ctx,
+                           "mirror-uuid", m_sync_point_handler,
+                           m_instance_watcher, nullptr, ctx);
   }
 
   librbd::ImageCtx *m_remote_image_ctx;
index fcd659131994efac04426e0f22d2ae4cd41de9a0..b0434bef6c5ac6f05464407835df810c5dee1b77 100644 (file)
@@ -15,7 +15,6 @@
 #include "librbd/asio/ContextWQ.h"
 #include "librbd/deep_copy/Handler.h"
 #include "tools/rbd_mirror/Threads.h"
-#include "tools/rbd_mirror/Types.h"
 #include "tools/rbd_mirror/image_sync/SyncPointCreateRequest.h"
 #include "tools/rbd_mirror/image_sync/SyncPointPruneRequest.h"
 #include "tools/rbd_mirror/image_sync/Types.h"
@@ -54,7 +53,6 @@ public:
 template <typename I>
 ImageSync<I>::ImageSync(
     Threads<I>* threads,
-    GroupCtx *local_group_ctx,
     I *local_image_ctx,
     I *remote_image_ctx,
     const std::string &local_mirror_uuid,
@@ -75,12 +73,6 @@ ImageSync<I>::ImageSync(
     m_update_sync_point_interval(
       m_local_image_ctx->cct->_conf.template get_val<double>(
         "rbd_mirror_sync_point_update_age")) {
-  if (local_group_ctx == nullptr) {
-    m_sync_id = m_local_image_ctx->id;
-  } else {
-    m_sync_id = stringify(m_local_image_ctx->md_ctx.get_id()) + ":" +
-        m_local_image_ctx->id;
-  }
 }
 
 template <typename I>
@@ -103,7 +95,7 @@ void ImageSync<I>::cancel() {
 
   m_canceled = true;
 
-  if (m_instance_watcher->cancel_sync_request(m_sync_id)) {
+  if (m_instance_watcher->cancel_sync_request(m_local_image_ctx->id)) {
     return;
   }
 
@@ -128,7 +120,7 @@ void ImageSync<I>::send_notify_sync_request() {
   Context *ctx = create_async_context_callback(
     m_threads->work_queue, create_context_callback<
       ImageSync<I>, &ImageSync<I>::handle_notify_sync_request>(this));
-  m_instance_watcher->notify_sync_request(m_sync_id, ctx);
+  m_instance_watcher->notify_sync_request(m_local_image_ctx->id, ctx);
   m_lock.unlock();
 }
 
@@ -469,7 +461,7 @@ template <typename I>
 void ImageSync<I>::finish(int r) {
   dout(20) << ": r=" << r << dendl;
 
-  m_instance_watcher->notify_sync_complete(m_sync_id);
+  m_instance_watcher->notify_sync_complete(m_local_image_ctx->id);
   CancelableRequest::finish(r);
 }
 
index c56d376d9522c270d2830602125c012b17193336..b3389ce18fec89d6d28e0d34e5ae64774116825b 100644 (file)
@@ -21,7 +21,6 @@ namespace mirror {
 class ProgressContext;
 template <typename> class InstanceWatcher;
 template <typename> class Threads;
-struct GroupCtx;
 
 namespace image_sync { struct SyncPointHandler; }
 
@@ -30,7 +29,6 @@ class ImageSync : public CancelableRequest {
 public:
   static ImageSync* create(
       Threads<ImageCtxT>* threads,
-      GroupCtx *local_group_ctx,
       ImageCtxT *local_image_ctx,
       ImageCtxT *remote_image_ctx,
       const std::string &local_mirror_uuid,
@@ -38,15 +36,13 @@ public:
       InstanceWatcher<ImageCtxT> *instance_watcher,
       ProgressContext *progress_ctx,
       Context *on_finish) {
-    return new ImageSync(threads, local_group_ctx, local_image_ctx,
-                         remote_image_ctx, local_mirror_uuid,
-                         sync_point_handler, instance_watcher, progress_ctx,
-                         on_finish);
+    return new ImageSync(threads, local_image_ctx, remote_image_ctx,
+                         local_mirror_uuid, sync_point_handler,
+                         instance_watcher, progress_ctx, on_finish);
   }
 
   ImageSync(
       Threads<ImageCtxT>* threads,
-      GroupCtx *local_group_ctx,
       ImageCtxT *local_image_ctx,
       ImageCtxT *remote_image_ctx,
       const std::string &local_mirror_uuid,
@@ -104,7 +100,6 @@ private:
 
   ceph::mutex m_lock;
   bool m_canceled = false;
-  std::string m_sync_id;
 
   librbd::DeepCopyRequest<ImageCtxT> *m_image_copy_request = nullptr;
   ImageCopyProgressHandler *m_image_copy_prog_handler = nullptr;
index 10312769e2c4be6e30ddf4ac0cd919fd64a29a39..e9a17b98584471c23fe3dd1d87bb36ca14131dc4 100644 (file)
@@ -407,9 +407,9 @@ void BootstrapRequest<I>::image_sync() {
   Context *ctx = create_context_callback<
     BootstrapRequest<I>, &BootstrapRequest<I>::handle_image_sync>(this);
   m_image_sync = ImageSync<I>::create(
-    m_threads, m_local_group_ctx, state_builder->local_image_ctx,
-    state_builder->remote_image_ctx, m_local_mirror_uuid, sync_point_handler,
-    m_instance_watcher, m_progress_ctx, ctx);
+    m_threads, state_builder->local_image_ctx, state_builder->remote_image_ctx,
+    m_local_mirror_uuid, sync_point_handler, m_instance_watcher,
+    m_progress_ctx, ctx);
   m_image_sync->get();
   locker.unlock();