Skip to content

Commit b8db14c

Browse files
authored
Merge pull request ceph#59401 from nbalacha/wip-nbalacha-check-mirror-ns
rbd-mirror: use correct ioctx for namespace Reviewed-by: Ilya Dryomov <[email protected]> Reviewed-by: Ramana Raja <[email protected]>
2 parents 6fc2552 + 2346cd9 commit b8db14c

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/test/rbd_mirror/test_mock_PoolReplayer.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,14 @@ class TestMockPoolReplayer : public TestMockFixture {
363363
Return(0)));
364364
}
365365

366+
void expect_clone(librados::MockTestMemIoCtxImpl* mock_io_ctx) {
367+
EXPECT_CALL(*mock_io_ctx, clone())
368+
.WillRepeatedly(Invoke([mock_io_ctx]() {
369+
mock_io_ctx->get();
370+
return mock_io_ctx;
371+
}));
372+
}
373+
366374
void expect_leader_watcher_init(MockLeaderWatcher& mock_leader_watcher,
367375
int r) {
368376
EXPECT_CALL(mock_leader_watcher, init())
@@ -727,6 +735,7 @@ TEST_F(TestMockPoolReplayer, Namespaces) {
727735
auto mock_remote_rados_client = mock_cluster.do_create_rados_client(
728736
g_ceph_context);
729737

738+
expect_clone(mock_local_io_ctx);
730739
expect_mirror_mode_get(mock_local_io_ctx);
731740

732741
InSequence seq;
@@ -845,6 +854,7 @@ TEST_F(TestMockPoolReplayer, NamespacesError) {
845854
auto mock_remote_rados_client = mock_cluster.do_create_rados_client(
846855
g_ceph_context);
847856

857+
expect_clone(mock_local_io_ctx);
848858
expect_mirror_mode_get(mock_local_io_ctx);
849859

850860
InSequence seq;

src/tools/rbd_mirror/PoolReplayer.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,8 +747,12 @@ int PoolReplayer<I>::list_mirroring_namespaces(
747747
}
748748

749749
for (auto &name : names) {
750+
librados::IoCtx ns_ioctx;
751+
ns_ioctx.dup(m_local_io_ctx);
752+
ns_ioctx.set_namespace(name);
753+
750754
cls::rbd::MirrorMode mirror_mode = cls::rbd::MIRROR_MODE_DISABLED;
751-
int r = librbd::cls_client::mirror_mode_get(&m_local_io_ctx, &mirror_mode);
755+
int r = librbd::cls_client::mirror_mode_get(&ns_ioctx, &mirror_mode);
752756
if (r < 0 && r != -ENOENT) {
753757
derr << "failed to get namespace mirror mode: " << cpp_strerror(r)
754758
<< dendl;

0 commit comments

Comments
 (0)