]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: use correct ioctx for namespace 59401/head
authorN Balachandran <nibalach@redhat.com>
Thu, 22 Aug 2024 08:15:36 +0000 (13:45 +0530)
committerN Balachandran <nibalach@redhat.com>
Tue, 27 Aug 2024 05:56:38 +0000 (11:26 +0530)
The PoolReplayer uses the ioctx for the default namespace
to check if other namespaces are enabled for mirroring, causing
it to incorrectly conclude that they are all enabled.

Fixes: https://tracker.ceph.com/issues/67676
Signed-off-by: N Balachandran <nibalach@redhat.com>
src/test/rbd_mirror/test_mock_PoolReplayer.cc
src/tools/rbd_mirror/PoolReplayer.cc

index 5a7d2348a17797cd7e6e6cca402df290fc3a014d..69fe799314810327ae010cc3ad38bd9fede606f2 100644 (file)
@@ -363,6 +363,14 @@ public:
           Return(0)));
   }
 
+  void expect_clone(librados::MockTestMemIoCtxImpl* mock_io_ctx) {
+    EXPECT_CALL(*mock_io_ctx, clone())
+      .WillRepeatedly(Invoke([mock_io_ctx]() {
+          mock_io_ctx->get();
+          return mock_io_ctx;
+        }));
+  }
+
   void expect_leader_watcher_init(MockLeaderWatcher& mock_leader_watcher,
                                   int r) {
     EXPECT_CALL(mock_leader_watcher, init())
@@ -727,6 +735,7 @@ TEST_F(TestMockPoolReplayer, Namespaces) {
   auto mock_remote_rados_client = mock_cluster.do_create_rados_client(
       g_ceph_context);
 
+  expect_clone(mock_local_io_ctx);
   expect_mirror_mode_get(mock_local_io_ctx);
 
   InSequence seq;
@@ -845,6 +854,7 @@ TEST_F(TestMockPoolReplayer, NamespacesError) {
   auto mock_remote_rados_client = mock_cluster.do_create_rados_client(
       g_ceph_context);
 
+  expect_clone(mock_local_io_ctx);
   expect_mirror_mode_get(mock_local_io_ctx);
 
   InSequence seq;
index cb88e6e96f7da6db75528fe36d383a2da2e5d1b9..dcbedc67e42350107e61c84d6cd6739a446ace8d 100644 (file)
@@ -747,8 +747,12 @@ int PoolReplayer<I>::list_mirroring_namespaces(
   }
 
   for (auto &name : names) {
+    librados::IoCtx ns_ioctx;
+    ns_ioctx.dup(m_local_io_ctx);
+    ns_ioctx.set_namespace(name);
+
     cls::rbd::MirrorMode mirror_mode = cls::rbd::MIRROR_MODE_DISABLED;
-    int r = librbd::cls_client::mirror_mode_get(&m_local_io_ctx, &mirror_mode);
+    int r = librbd::cls_client::mirror_mode_get(&ns_ioctx, &mirror_mode);
     if (r < 0 && r != -ENOENT) {
       derr << "failed to get namespace mirror mode: " << cpp_strerror(r)
            << dendl;