]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: eliminate use of image name during bootstrap
authorJason Dillaman <dillaman@redhat.com>
Fri, 21 Apr 2017 01:00:34 +0000 (21:00 -0400)
committerJason Dillaman <dillaman@redhat.com>
Fri, 21 Apr 2017 02:38:19 +0000 (22:38 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/test/rbd_mirror/image_replayer/test_mock_BootstrapRequest.cc
src/tools/rbd_mirror/ImageReplayer.cc
src/tools/rbd_mirror/ImageReplayer.h
src/tools/rbd_mirror/image_replayer/BootstrapRequest.cc
src/tools/rbd_mirror/image_replayer/BootstrapRequest.h
src/tools/rbd_mirror/image_replayer/OpenLocalImageRequest.cc
src/tools/rbd_mirror/image_replayer/OpenLocalImageRequest.h

index 197166b8c8ee350df31adcb223a0ad76e2560a98..4da8665799b4cf6157d112034a368297bcd6379f 100644 (file)
@@ -214,7 +214,6 @@ struct OpenLocalImageRequest<librbd::MockTestImageCtx> {
 
   static OpenLocalImageRequest* create(librados::IoCtx &local_io_ctx,
                                        librbd::MockTestImageCtx **local_image_ctx,
-                                       const std::string &local_image_name,
                                        const std::string &local_image_id,
                                        ContextWQ *work_queue,
                                        Context *on_finish) {
@@ -429,8 +428,7 @@ public:
     return new MockBootstrapRequest(m_local_io_ctx,
                                     m_remote_io_ctx,
                                     mock_image_sync_throttler,
-                                    &m_local_test_image_ctx,
-                                    "local image name",
+                                    &m_local_test_image_ctx, "",
                                     remote_image_id,
                                     global_image_id,
                                     m_threads->work_queue,
index 0a58a6b72c6b9bdd27cce3941e5b89abfdda43cf..fa4cb470b1f4cec4bb2223369de8d8f030f5c2b3 100644 (file)
@@ -421,15 +421,14 @@ void ImageReplayer<I>::start(Context *on_finish, bool manual)
 
 template <typename I>
 void ImageReplayer<I>::bootstrap() {
-  dout(20) << "bootstrap params: "
-          << "local_image_name=" << m_local_image_name << dendl;
+  dout(20) << dendl;
 
   Context *ctx = create_context_callback<
     ImageReplayer, &ImageReplayer<I>::handle_bootstrap>(this);
 
   BootstrapRequest<I> *request = BootstrapRequest<I>::create(
     m_local_ioctx, m_remote_image.io_ctx, m_image_sync_throttler,
-    &m_local_image_ctx, m_local_image_name, m_remote_image.image_id,
+    &m_local_image_ctx, m_local_image_id, m_remote_image.image_id,
     m_global_image_id, m_threads->work_queue, m_threads->timer,
     &m_threads->timer_lock, m_local_mirror_uuid, m_remote_image.mirror_uuid,
     m_remote_journaler, &m_client_meta, ctx, &m_do_resync, &m_progress_cxt);
@@ -455,7 +454,6 @@ void ImageReplayer<I>::handle_bootstrap(int r) {
     m_bootstrap_request = nullptr;
     if (m_local_image_ctx) {
       m_local_image_id = m_local_image_ctx->id;
-      m_local_image_name = m_local_image_ctx->name;
     }
   }
 
index 87902dae9fb5b1cf9f11fe04beca4e137f101c9e..79a744d9842a187fccffa47f0b5c045e904cf9f8 100644 (file)
@@ -122,10 +122,6 @@ public:
     Mutex::Locker locker(m_lock);
     return m_local_image_id;
   }
-  inline std::string get_local_image_name() {
-    Mutex::Locker locker(m_lock);
-    return m_local_image_name;
-  }
 
   void start(Context *on_finish = nullptr, bool manual = false);
   void stop(Context *on_finish = nullptr, bool manual = false,
@@ -296,7 +292,6 @@ private:
   int64_t m_local_pool_id;
   std::string m_local_image_id;
   std::string m_global_image_id;
-  std::string m_local_image_name;
   std::string m_name;
   mutable Mutex m_lock;
   State m_state = STATE_STOPPED;
index 3191daa672a95c0b91604d0ffa378796978c2af5..7d7d5ed1a6c31ae1fadaa0b23facfbd2a38114bd 100644 (file)
@@ -44,7 +44,7 @@ BootstrapRequest<I>::BootstrapRequest(
         librados::IoCtx &remote_io_ctx,
         std::shared_ptr<ImageSyncThrottler<I>> image_sync_throttler,
         I **local_image_ctx,
-        const std::string &local_image_name,
+        const std::string &local_image_id,
         const std::string &remote_image_id,
         const std::string &global_image_id,
         ContextWQ *work_queue, SafeTimer *timer,
@@ -60,7 +60,7 @@ BootstrapRequest<I>::BootstrapRequest(
                reinterpret_cast<CephContext*>(local_io_ctx.cct()), on_finish),
     m_local_io_ctx(local_io_ctx), m_remote_io_ctx(remote_io_ctx),
     m_image_sync_throttler(image_sync_throttler),
-    m_local_image_ctx(local_image_ctx), m_local_image_name(local_image_name),
+    m_local_image_ctx(local_image_ctx), m_local_image_id(local_image_id),
     m_remote_image_id(remote_image_id), m_global_image_id(global_image_id),
     m_work_queue(work_queue), m_timer(timer), m_timer_lock(timer_lock),
     m_local_mirror_uuid(local_mirror_uuid),
@@ -305,11 +305,6 @@ void BootstrapRequest<I>::handle_is_primary(int r) {
     return;
   }
 
-  // default local image name to the remote image name if not provided
-  if (m_local_image_name.empty()) {
-    m_local_image_name = m_remote_image_ctx->name;
-  }
-
   if (m_local_image_id.empty()) {
     create_local_image();
     return;
@@ -364,9 +359,8 @@ void BootstrapRequest<I>::open_local_image() {
     BootstrapRequest<I>, &BootstrapRequest<I>::handle_open_local_image>(
       this);
   OpenLocalImageRequest<I> *request = OpenLocalImageRequest<I>::create(
-    m_local_io_ctx, m_local_image_ctx,
-    (!m_local_image_id.empty() ? std::string() : m_local_image_name),
-    m_local_image_id, m_work_queue, ctx);
+    m_local_io_ctx, m_local_image_ctx, m_local_image_id, m_work_queue,
+    ctx);
   request->send();
 }
 
@@ -435,12 +429,16 @@ void BootstrapRequest<I>::create_local_image() {
   m_local_image_id = "";
   update_progress("CREATE_LOCAL_IMAGE");
 
+  m_remote_image_ctx->snap_lock.get_read();
+  std::string image_name = m_remote_image_ctx->name;
+  m_remote_image_ctx->snap_lock.put_read();
+
   Context *ctx = create_context_callback<
     BootstrapRequest<I>, &BootstrapRequest<I>::handle_create_local_image>(
       this);
   CreateImageRequest<I> *request = CreateImageRequest<I>::create(
     m_local_io_ctx, m_work_queue, m_global_image_id, m_remote_mirror_uuid,
-    m_local_image_name, m_remote_image_ctx, &m_local_image_id, ctx);
+    image_name, m_remote_image_ctx, &m_local_image_id, ctx);
   request->send();
 }
 
index 0d7017e705350642252fad9b189a97a2121825de..e367b2ae4826b34c4e5f5845c29f68103b5f6ca1 100644 (file)
@@ -42,7 +42,7 @@ public:
         librados::IoCtx &remote_io_ctx,
         ImageSyncThrottlerRef<ImageCtxT> image_sync_throttler,
         ImageCtxT **local_image_ctx,
-        const std::string &local_image_name,
+        const std::string &local_image_id,
         const std::string &remote_image_id,
         const std::string &global_image_id,
         ContextWQ *work_queue, SafeTimer *timer,
@@ -56,7 +56,7 @@ public:
         ProgressContext *progress_ctx = nullptr) {
     return new BootstrapRequest(local_io_ctx, remote_io_ctx,
                                 image_sync_throttler, local_image_ctx,
-                                local_image_name, remote_image_id,
+                                local_image_id, remote_image_id,
                                 global_image_id, work_queue, timer, timer_lock,
                                 local_mirror_uuid, remote_mirror_uuid,
                                 journaler, client_meta, on_finish, do_resync,
@@ -67,7 +67,7 @@ public:
                    librados::IoCtx &remote_io_ctx,
                    ImageSyncThrottlerRef<ImageCtxT> image_sync_throttler,
                    ImageCtxT **local_image_ctx,
-                   const std::string &local_image_name,
+                   const std::string &local_image_id,
                    const std::string &remote_image_id,
                    const std::string &global_image_id, ContextWQ *work_queue,
                    SafeTimer *timer, Mutex *timer_lock,
@@ -150,7 +150,6 @@ private:
   librados::IoCtx &m_remote_io_ctx;
   ImageSyncThrottlerRef<ImageCtxT> m_image_sync_throttler;
   ImageCtxT **m_local_image_ctx;
-  std::string m_local_image_name;
   std::string m_local_image_id;
   std::string m_remote_image_id;
   std::string m_global_image_id;
index 5f67c41cfa43028cabb23cec74b38db75e699ed2..2d7b8d1250409e66568aa23e17f5ed69a7784697 100644 (file)
@@ -70,13 +70,12 @@ struct MirrorJournalPolicy : public librbd::journal::Policy {
 template <typename I>
 OpenLocalImageRequest<I>::OpenLocalImageRequest(librados::IoCtx &local_io_ctx,
                                                 I **local_image_ctx,
-                                                const std::string &local_image_name,
                                                 const std::string &local_image_id,
                                                 ContextWQ *work_queue,
                                                 Context *on_finish)
   : m_local_io_ctx(local_io_ctx), m_local_image_ctx(local_image_ctx),
-    m_local_image_name(local_image_name), m_local_image_id(local_image_id),
-    m_work_queue(work_queue), m_on_finish(on_finish) {
+    m_local_image_id(local_image_id), m_work_queue(work_queue),
+    m_on_finish(on_finish) {
 }
 
 template <typename I>
@@ -88,7 +87,7 @@ template <typename I>
 void OpenLocalImageRequest<I>::send_open_image() {
   dout(20) << dendl;
 
-  *m_local_image_ctx = I::create(m_local_image_name, m_local_image_id, nullptr,
+  *m_local_image_ctx = I::create("", m_local_image_id, nullptr,
                                  m_local_io_ctx, false);
   {
     RWLock::WLocker owner_locker((*m_local_image_ctx)->owner_lock);
index 570728dd762bd4a9b6b97d5d6128e2804fe8582f..58de545fb3a20724920b9e84575fad9bbf4e3633 100644 (file)
@@ -21,18 +21,15 @@ class OpenLocalImageRequest {
 public:
   static OpenLocalImageRequest* create(librados::IoCtx &local_io_ctx,
                                        ImageCtxT **local_image_ctx,
-                                       const std::string &local_image_name,
                                        const std::string &local_image_id,
                                        ContextWQ *work_queue,
                                        Context *on_finish) {
     return new OpenLocalImageRequest(local_io_ctx, local_image_ctx,
-                                     local_image_name, local_image_id,
-                                     work_queue, on_finish);
+                                     local_image_id, work_queue, on_finish);
   }
 
   OpenLocalImageRequest(librados::IoCtx &local_io_ctx,
                         ImageCtxT **local_image_ctx,
-                        const std::string &local_image_name,
                         const std::string &local_image_id,
                         ContextWQ *m_work_queue,
                         Context *on_finish);
@@ -61,7 +58,6 @@ private:
    */
   librados::IoCtx &m_local_io_ctx;
   ImageCtxT **m_local_image_ctx;
-  std::string m_local_image_name;
   std::string m_local_image_id;
   ContextWQ *m_work_queue;
   Context *m_on_finish;