]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rbd-mirror: fix issues around health state
authorPrasanna Kumar Kalever <prasanna.kalever@redhat.com>
Tue, 1 Apr 2025 13:17:21 +0000 (18:47 +0530)
committerIlya Dryomov <idryomov@gmail.com>
Sun, 28 Sep 2025 18:25:03 +0000 (20:25 +0200)
* move m_status_state & m_state_desc under lock
* fix unit test build issue

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
src/test/rbd_mirror/test_mock_InstanceReplayer.cc
src/tools/rbd_mirror/GroupReplayer.cc

index 57138c56942fc034586e8ab35e083265736c1e17..2eb406cc35c379e3f777e792f9119335d88535c6 100644 (file)
@@ -107,7 +107,7 @@ struct GroupReplayer<librbd::MockTestImageCtx> {
   MOCK_CONST_METHOD0(is_finished, bool());
   MOCK_METHOD1(set_finished, void(bool));
 
-  MOCK_CONST_METHOD0(get_health_state, image_replayer::HealthState());
+  MOCK_CONST_METHOD0(get_health_state, group_replayer::HealthState());
 };
 
 GroupReplayer<librbd::MockTestImageCtx>* GroupReplayer<librbd::MockTestImageCtx>::s_instance = nullptr;
index fddc59fd8aabc5d477da7a086b47ef640decd26c..d44987f40d4cf28de4359ac4ca55dc900eb92d72 100644 (file)
@@ -828,12 +828,12 @@ template <typename I>
 void GroupReplayer<I>::finish_start_fail(int r, const std::string &desc) {
   dout(10) << "r=" << r << ", desc=" << desc << dendl;
   Context *ctx = new LambdaContext([this, r, desc](int _r) {
-    m_status_state = cls::rbd::MIRROR_GROUP_STATUS_STATE_STOPPED;
-    m_state_desc = desc;
     {
       std::lock_guard locker{m_lock};
       ceph_assert(m_state == STATE_STARTING);
       m_state = STATE_STOPPING;
+      m_status_state = cls::rbd::MIRROR_GROUP_STATUS_STATE_STOPPED;
+      m_state_desc = desc;
       if (r < 0) {
        if (r == -ECANCELED) {
          dout(10) << "start canceled" << dendl;
@@ -1080,7 +1080,7 @@ void GroupReplayer<I>::set_mirror_group_status_update(
   auto remote_status = local_status;
 
   {
-    std::unique_lock locker{m_lock};
+    std::lock_guard locker{m_lock};
     for (auto &[_, ir] : m_image_replayers) {
       cls::rbd::MirrorImageSiteStatus mirror_image;
       if (ir->is_running()) {
@@ -1130,8 +1130,12 @@ void GroupReplayer<I>::set_mirror_group_status_update(
     m_remote_group_peer.mirror_status_updater->set_mirror_group_status(
         m_global_group_id, remote_status, true);
   }
-  m_status_state = local_status.state;
-  m_state_desc = local_status.description;
+
+  {
+    std::lock_guard locker{m_lock};
+    m_status_state = local_status.state;
+    m_state_desc = local_status.description;
+  }
 }
 
 } // namespace mirror