From 9b8d82009278cc275a71102914bcb34850ce03b8 Mon Sep 17 00:00:00 2001 From: Venky Shankar Date: Thu, 5 Aug 2021 04:35:10 -0400 Subject: [PATCH] cephfs-mirror: shutdown ClusterWatcher on termination Fixes: https://tracker.ceph.com/issues/52062 Signed-off-by: Venky Shankar --- src/tools/cephfs_mirror/ClusterWatcher.cc | 10 +++++++++- src/tools/cephfs_mirror/ClusterWatcher.h | 1 + src/tools/cephfs_mirror/Mirror.cc | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/tools/cephfs_mirror/ClusterWatcher.cc b/src/tools/cephfs_mirror/ClusterWatcher.cc index a5d04717a97..40aab756ee9 100644 --- a/src/tools/cephfs_mirror/ClusterWatcher.cc +++ b/src/tools/cephfs_mirror/ClusterWatcher.cc @@ -68,6 +68,7 @@ int ClusterWatcher::init() { void ClusterWatcher::shutdown() { dout(20) << dendl; std::scoped_lock locker(m_lock); + m_stopping = true; m_monc->sub_unwant("fsmap"); } @@ -84,6 +85,10 @@ void ClusterWatcher::handle_fsmap(const cref_t &m) { std::map fs_metadata_pools; { std::scoped_lock locker(m_lock); + if (m_stopping) { + return; + } + // deleted filesystems are considered mirroring disabled for (auto it = m_filesystem_peers.begin(); it != m_filesystem_peers.end();) { if (!fsmap.filesystem_exists(it->first.fscid)) { @@ -167,7 +172,10 @@ void ClusterWatcher::handle_fsmap(const cref_t &m) { } } - m_monc->sub_got("fsmap", fsmap.get_epoch()); + std::scoped_lock(m_lock); + if (!m_stopping) { + m_monc->sub_got("fsmap", fsmap.get_epoch()); + } // else we have already done a sub_unwant() } } // namespace mirror diff --git a/src/tools/cephfs_mirror/ClusterWatcher.h b/src/tools/cephfs_mirror/ClusterWatcher.h index e3bf6298b50..a418898f555 100644 --- a/src/tools/cephfs_mirror/ClusterWatcher.h +++ b/src/tools/cephfs_mirror/ClusterWatcher.h @@ -65,6 +65,7 @@ private: ServiceDaemon *m_service_daemon; Listener &m_listener; + bool m_stopping = false; std::map m_filesystem_peers; void handle_fsmap(const cref_t &m); diff --git a/src/tools/cephfs_mirror/Mirror.cc b/src/tools/cephfs_mirror/Mirror.cc index efaa27106e5..88648f2b3a1 100644 --- a/src/tools/cephfs_mirror/Mirror.cc +++ b/src/tools/cephfs_mirror/Mirror.cc @@ -222,7 +222,6 @@ Mirror::~Mirror() { { std::scoped_lock locker(m_lock); m_thread_pool->stop(); - m_cluster_watcher.reset(); } } @@ -285,6 +284,7 @@ int Mirror::init(std::string &reason) { void Mirror::shutdown() { dout(20) << dendl; m_stopping = true; + m_cluster_watcher->shutdown(); m_cond.notify_all(); } -- 2.39.5