]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rbd-mirror: add cluster fsid to remote meta cache key
authorMykola Golub <mykola.golub@clyso.com>
Fri, 3 Oct 2025 12:40:54 +0000 (15:40 +0300)
committerIlya Dryomov <idryomov@gmail.com>
Sun, 16 Nov 2025 22:31:43 +0000 (23:31 +0100)
Using just pool id is not enough when mirroring several clusters.

Fixes: https://tracker.ceph.com/issues/69492
Signed-off-by: Mykola Golub <mykola.golub@clyso.com>
(cherry picked from commit dfa23483aa2828004fe588f9c23f398a29b03323)

src/test/rbd_mirror/image_replayer/snapshot/test_mock_Replayer.cc
src/test/rbd_mirror/test_ImageReplayer.cc
src/tools/rbd_mirror/PoolMetaCache.cc
src/tools/rbd_mirror/PoolMetaCache.h
src/tools/rbd_mirror/PoolReplayer.cc
src/tools/rbd_mirror/PoolReplayer.h
src/tools/rbd_mirror/image_replayer/snapshot/Replayer.cc

index 21afa6d52bb552100d8b0c8f856d38e46205bea8..4a9b982bb49884b9152757c4082f7faa75ddc817 100644 (file)
@@ -407,6 +407,9 @@ public:
   void SetUp() override {
     TestMockFixture::SetUp();
 
+    librados::Rados remote_rados(m_remote_io_ctx);
+    EXPECT_EQ(0, remote_rados.cluster_fsid(&m_remote_fsid));
+
     librbd::RBD rbd;
     ASSERT_EQ(0, create_image(rbd, m_local_io_ctx, m_image_name, m_image_size));
     ASSERT_EQ(0, open_image(m_local_io_ctx, m_image_name, &m_local_image_ctx));
@@ -704,6 +707,7 @@ public:
   librbd::ImageCtx* m_local_image_ctx = nullptr;
   librbd::ImageCtx* m_remote_image_ctx = nullptr;
 
+  std::string m_remote_fsid;
   PoolMetaCache m_pool_meta_cache{g_ceph_context};
 
   ceph::mutex m_lock = ceph::make_mutex(
@@ -733,7 +737,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, InitShutDown) {
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -787,7 +791,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, SyncSnapshot) {
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -965,7 +969,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, InterruptedSyncInitial) {
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -1050,7 +1054,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, InterruptedSyncDelta) {
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -1171,7 +1175,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, InterruptedSyncDeltaDemote) {
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -1280,7 +1284,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, InterruptedPendingSyncInitial) {
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -1364,7 +1368,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, InterruptedPendingSyncDelta) {
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -1504,7 +1508,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, InterruptedPendingSyncDeltaDemote)
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -1632,7 +1636,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, RemoteImageDemoted) {
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -1721,7 +1725,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, LocalImagePromoted) {
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -1777,7 +1781,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, ResyncRequested) {
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -1833,7 +1837,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, ResyncRequestedRemoteNotPrimary) {
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -1922,7 +1926,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, RegisterLocalUpdateWatcherError) {
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   // init
@@ -1955,7 +1959,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, RegisterRemoteUpdateWatcherError)
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   // init
@@ -1994,7 +1998,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, UnregisterRemoteUpdateWatcherError
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -2036,7 +2040,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, UnregisterLocalUpdateWatcherError)
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -2078,7 +2082,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, LoadImageMetaError) {
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -2126,7 +2130,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, RefreshLocalImageError) {
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -2177,7 +2181,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, RefreshRemoteImageError) {
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -2227,7 +2231,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, CopySnapshotsError) {
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -2287,7 +2291,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, GetImageStateError) {
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -2349,7 +2353,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, CreateNonPrimarySnapshotError) {
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -2415,7 +2419,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, UpdateMirrorImageStateError) {
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -2483,7 +2487,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, RequestSyncError) {
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -2553,7 +2557,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, CopyImageError) {
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -2626,7 +2630,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, UpdateNonPrimarySnapshotError) {
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -2703,7 +2707,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, UnlinkPeerError) {
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -2791,7 +2795,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, SplitBrain) {
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -2854,7 +2858,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, RemoteSnapshotMissingSplitBrain) {
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -2922,7 +2926,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, RemoteFailover) {
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -3064,7 +3068,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, UnlinkRemoteSnapshot) {
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -3142,7 +3146,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, SkipImageSync) {
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -3221,7 +3225,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, ImageNameUpdated) {
                              "local mirror uuid", &m_pool_meta_cache,
                              &mock_state_builder, &mock_replayer_listener};
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -3284,7 +3288,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, ApplyImageStatePendingShutdown) {
                              &mock_state_builder, &mock_replayer_listener};
   C_SaferCond shutdown_ctx;
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
@@ -3371,7 +3375,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, ApplyImageStateErrorPendingShutdow
                              &mock_state_builder, &mock_replayer_listener};
   C_SaferCond shutdown_ctx;
   m_pool_meta_cache.set_remote_pool_meta(
-    m_remote_io_ctx.get_id(),
+    m_remote_fsid, m_remote_io_ctx.get_id(),
     {"remote mirror uuid", "remote mirror peer uuid"});
 
   librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
index 2aa1718834080ee4a589f8f2643bfa54e3bd907a..b8c26394dfeb73c0c713dfbbd8fd8528c7536627 100644 (file)
@@ -141,8 +141,13 @@ public:
                           cls::rbd::MIRROR_PEER_DIRECTION_RX_TX,
                           "siteA", "client", m_local_mirror_uuid}));
 
+      std::string remote_fsid;
+      librados::Rados remote_rados(m_remote_ioctx);
+      EXPECT_EQ(0, remote_rados.cluster_fsid(&remote_fsid));
+
       m_pool_meta_cache.set_remote_pool_meta(
-        m_remote_ioctx.get_id(), {m_remote_mirror_uuid, remote_peer_uuid});
+        remote_fsid, m_remote_ioctx.get_id(),
+        {m_remote_mirror_uuid, remote_peer_uuid});
     }
 
     EXPECT_EQ(0, librbd::api::Mirror<>::uuid_get(m_remote_ioctx,
index 261802a55c53483ce5b9c449effa8df1f895ad0b..c912e65b3b38385bb6d26c5a5ff944a6d12262a7 100644 (file)
@@ -48,12 +48,12 @@ void PoolMetaCache::remove_local_pool_meta(int64_t pool_id) {
 }
 
 int PoolMetaCache::get_remote_pool_meta(
-    int64_t pool_id,
+    const std::string& fsid, int64_t pool_id,
     RemotePoolMeta* remote_pool_meta) const {
-  dout(15) << "pool_id=" << pool_id << dendl;
+  dout(15) << "fsid=" << fsid << ", pool_id=" << pool_id << dendl;
 
   std::shared_lock locker{m_lock};
-  auto it = m_remote_pool_metas.find(pool_id);
+  auto it = m_remote_pool_metas.find({fsid, pool_id});
   if (it == m_remote_pool_metas.end()) {
     return -ENOENT;
   }
@@ -63,20 +63,21 @@ int PoolMetaCache::get_remote_pool_meta(
 }
 
 void PoolMetaCache::set_remote_pool_meta(
-    int64_t pool_id,
+    const std::string& fsid, int64_t pool_id,
     const RemotePoolMeta& remote_pool_meta) {
-  dout(15) << "pool_id=" << pool_id << ", "
-           << "remote_pool_meta=" << remote_pool_meta << dendl;
+  dout(15) << "fsid=" << fsid << ", pool_id=" << pool_id
+           << "remote_pool_meta=" << remote_pool_meta << dendl;
 
   std::unique_lock locker(m_lock);
-  m_remote_pool_metas[pool_id] = remote_pool_meta;
+  m_remote_pool_metas[{fsid, pool_id}] = remote_pool_meta;
 }
 
-void PoolMetaCache::remove_remote_pool_meta(int64_t pool_id) {
-  dout(15) << "pool_id=" << pool_id << dendl;
+void PoolMetaCache::remove_remote_pool_meta(
+    const std::string& fsid, int64_t pool_id) {
+  dout(15) << "fsid=" << fsid << ", pool_id=" << pool_id << dendl;
 
   std::unique_lock locker(m_lock);
-  m_remote_pool_metas.erase(pool_id);
+  m_remote_pool_metas.erase({fsid, pool_id});
 }
 
 } // namespace mirror
index f0440120fee06c31ff2b4b46374d56712a16b7ea..58fcf2b2e66a2f6453b5a09469f32d1c5efbe303 100644 (file)
@@ -26,11 +26,11 @@ public:
                            const LocalPoolMeta& local_pool_meta);
   void remove_local_pool_meta(int64_t pool_id);
 
-  int get_remote_pool_meta(int64_t pool_id,
+  int get_remote_pool_meta(const std::string& fsid, int64_t pool_id,
                            RemotePoolMeta* remote_pool_meta) const;
-  void set_remote_pool_meta(int64_t pool_id,
+  void set_remote_pool_meta(const std::string& fsid, int64_t pool_id,
                             const RemotePoolMeta& remote_pool_meta);
-  void remove_remote_pool_meta(int64_t pool_id);
+  void remove_remote_pool_meta(const std::string& fsid, int64_t pool_id);
 
 private:
   CephContext* m_cct;
@@ -38,7 +38,7 @@ private:
   mutable ceph::shared_mutex m_lock =
     ceph::make_shared_mutex("rbd::mirror::PoolMetaCache::m_lock");
   std::map<int64_t, LocalPoolMeta> m_local_pool_metas;
-  std::map<int64_t, RemotePoolMeta> m_remote_pool_metas;
+  std::map<std::pair<std::string, int64_t>, RemotePoolMeta> m_remote_pool_metas;
 };
 
 } // namespace mirror
index bed01e9ed4e25abaef1f11a2a0518d53506f82bf..4be22b5bd0a04225c81218d0be49107ed2e7981a 100644 (file)
@@ -326,6 +326,13 @@ void PoolReplayer<I>::init(const std::string& site_name) {
     return;
   }
 
+  r = m_remote_rados->cluster_fsid(&m_remote_fsid);
+  if (r < 0) {
+    derr << "failed to retrieve remote cluster fsid: " << cpp_strerror(r)
+        << dendl;
+    return;
+  }
+
   r = m_remote_rados->ioctx_create(m_local_io_ctx.get_pool_name().c_str(),
                                    m_remote_io_ctx);
   if (r < 0) {
@@ -362,9 +369,10 @@ void PoolReplayer<I>::init(const std::string& site_name) {
     m_remote_pool_poller.reset();
     return;
   }
+
   ceph_assert(!m_remote_pool_meta.mirror_uuid.empty());
   m_pool_meta_cache->set_remote_pool_meta(
-    m_remote_io_ctx.get_id(), m_remote_pool_meta);
+    m_remote_fsid, m_remote_io_ctx.get_id(), m_remote_pool_meta);
   m_pool_meta_cache->set_local_pool_meta(
     m_local_io_ctx.get_id(), {m_local_mirror_uuid});
 
@@ -439,7 +447,8 @@ void PoolReplayer<I>::shut_down() {
     m_remote_pool_poller->shut_down(&ctx);
     ctx.wait();
 
-    m_pool_meta_cache->remove_remote_pool_meta(m_remote_io_ctx.get_id());
+    m_pool_meta_cache->remove_remote_pool_meta(m_remote_fsid,
+                                               m_remote_io_ctx.get_id());
     m_pool_meta_cache->remove_local_pool_meta(m_local_io_ctx.get_id());
   }
   m_remote_pool_poller.reset();
index e0fd753778d92c449cab3afd3f58aa95f1e9843a..f94e9bd6029c14eff62ac62c472e1bd7a3e8a9c8 100644 (file)
@@ -214,6 +214,7 @@ private:
   librados::IoCtx m_remote_io_ctx;
 
   std::string m_local_mirror_uuid;
+  std::string m_remote_fsid;
 
   RemotePoolMeta m_remote_pool_meta;
   std::unique_ptr<remote_pool_poller::Listener> m_remote_pool_poller_listener;
index 1fdaddd2b4bb1e7908875a13dd4295e8b917d2c0..acb2aaf66e0826e5e511f235ad4e35810b794d45 100644 (file)
@@ -146,9 +146,19 @@ void Replayer<I>::init(Context* on_finish) {
 
   ceph_assert(m_state == STATE_INIT);
 
+  std::string remote_fsid;
+  librados::Rados remote_rados(m_state_builder->remote_image_ctx->md_ctx);
+  int r = remote_rados.cluster_fsid(&remote_fsid);
+  if (r < 0) {
+    derr << "failed to retrieve remote cluster fsid: " << cpp_strerror(r)
+        << dendl;
+    return;
+  }
+
   RemotePoolMeta remote_pool_meta;
-  int r = m_pool_meta_cache->get_remote_pool_meta(
-    m_state_builder->remote_image_ctx->md_ctx.get_id(), &remote_pool_meta);
+  r = m_pool_meta_cache->get_remote_pool_meta(
+    remote_fsid, m_state_builder->remote_image_ctx->md_ctx.get_id(),
+    &remote_pool_meta);
   if (r < 0 || remote_pool_meta.mirror_peer_uuid.empty()) {
     derr << "failed to retrieve mirror peer uuid from remote pool" << dendl;
     m_state = STATE_COMPLETE;