diff --git a/src/tools/cephfs_mirror/Mirror.cc b/src/tools/cephfs_mirror/Mirror.cc index edf903b921fb3..784e975fb14f2 100644 --- a/src/tools/cephfs_mirror/Mirror.cc +++ b/src/tools/cephfs_mirror/Mirror.cc @@ -318,19 +318,24 @@ void Mirror::handle_enable_mirroring(const Filesystem &filesystem, std::scoped_lock locker(m_lock); auto &mirror_action = m_mirror_actions.at(filesystem); - ceph_assert(mirror_action.action_in_progress); - mirror_action.action_in_progress = false; - m_cond.notify_all(); if (r < 0) { derr << ": failed to initialize FSMirror for filesystem=" << filesystem << ": " << cpp_strerror(r) << dendl; + // since init failed, don't assert, just unset it directly + mirror_action.action_in_progress = false; + m_cond.notify_all(); m_service_daemon->add_or_update_fs_attribute(filesystem.fscid, SERVICE_DAEMON_MIRROR_ENABLE_FAILED_KEY, true); return; } + ceph_assert(mirror_action.action_in_progress); + + mirror_action.action_in_progress = false; + m_cond.notify_all(); + for (auto &peer : peers) { mirror_action.fs_mirror->add_peer(peer); } @@ -343,19 +348,24 @@ void Mirror::handle_enable_mirroring(const Filesystem &filesystem, int r) { std::scoped_lock locker(m_lock); auto &mirror_action = m_mirror_actions.at(filesystem); - ceph_assert(mirror_action.action_in_progress); - - mirror_action.action_in_progress = false; - m_cond.notify_all(); + if (r < 0) { derr << ": failed to initialize FSMirror for filesystem=" << filesystem << ": " << cpp_strerror(r) << dendl; + // since init failed, don't assert, just unset it directly + mirror_action.action_in_progress = false; + m_cond.notify_all(); m_service_daemon->add_or_update_fs_attribute(filesystem.fscid, SERVICE_DAEMON_MIRROR_ENABLE_FAILED_KEY, true); return; } + ceph_assert(mirror_action.action_in_progress); + + mirror_action.action_in_progress = false; + m_cond.notify_all(); + dout(10) << ": Initialized FSMirror for filesystem=" << filesystem << dendl; }