]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/tools/rbd_mirror/PoolWatcher.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / tools / rbd_mirror / PoolWatcher.h
index 1136a319fcada93d574f8329f35aa004bb6add5a..c5c84731da8cc2b069493659d5571db2bf3d6629 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "common/AsyncOpTracker.h"
 #include "common/ceph_context.h"
-#include "common/Mutex.h"
+#include "common/ceph_mutex.h"
 #include "include/rados/librados.hpp"
 #include "tools/rbd_mirror/Types.h"
 #include <boost/functional/hash.hpp>
@@ -34,12 +34,15 @@ template <typename ImageCtxT = librbd::ImageCtx>
 class PoolWatcher {
 public:
   static PoolWatcher* create(Threads<ImageCtxT> *threads,
-                             librados::IoCtx &remote_io_ctx,
+                             librados::IoCtx &io_ctx,
+                             const std::string& mirror_uuid,
                              pool_watcher::Listener &listener) {
-    return new PoolWatcher(threads, remote_io_ctx, listener);
+    return new PoolWatcher(threads, io_ctx, mirror_uuid, listener);
   }
 
-  PoolWatcher(Threads<ImageCtxT> *threads, librados::IoCtx &remote_io_ctx,
+  PoolWatcher(Threads<ImageCtxT> *threads,
+              librados::IoCtx &io_ctx,
+              const std::string& mirror_uuid,
               pool_watcher::Listener &listener);
   ~PoolWatcher();
   PoolWatcher(const PoolWatcher&) = delete;
@@ -51,7 +54,7 @@ public:
   void shut_down(Context *on_finish);
 
   inline uint64_t get_image_count() const {
-    Mutex::Locker locker(m_lock);
+    std::lock_guard locker{m_lock};
     return m_image_ids.size();
   }
 
@@ -75,9 +78,6 @@ private:
    *    |/----------------------------\   |
    *    |                             |   |
    *    v                             |   |
-   * GET_MIRROR_UUID                  |   |
-   *    |                             |   |
-   *    v                             |   |
    * NOTIFY_LISTENER                  |   |
    *    |                             |   |
    *    v                             |   |
@@ -103,18 +103,18 @@ private:
   class MirroringWatcher;
 
   Threads<ImageCtxT> *m_threads;
-  librados::IoCtx m_remote_io_ctx;
+  librados::IoCtx m_io_ctx;
+  std::string m_mirror_uuid;
   pool_watcher::Listener &m_listener;
 
   ImageIds m_refresh_image_ids;
   bufferlist m_out_bl;
 
-  mutable Mutex m_lock;
+  mutable ceph::mutex m_lock;
 
   Context *m_on_init_finish = nullptr;
 
   ImageIds m_image_ids;
-  std::string m_mirror_uuid;
 
   bool m_pending_updates = false;
   bool m_notify_listener_in_progress = false;
@@ -122,8 +122,6 @@ private:
   ImageIds m_pending_added_image_ids;
   ImageIds m_pending_removed_image_ids;
 
-  std::string m_pending_mirror_uuid;
-
   MirroringWatcher *m_mirroring_watcher;
 
   Context *m_timer_ctx = nullptr;
@@ -145,11 +143,8 @@ private:
   void schedule_refresh_images(double interval);
   void process_refresh_images();
 
-  void get_mirror_uuid();
-  void handle_get_mirror_uuid(int r);
-
   void handle_rewatch_complete(int r);
-  void handle_image_updated(const std::string &remote_image_id,
+  void handle_image_updated(const std::string &image_id,
                             const std::string &global_image_id,
                             bool enabled);