diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-23 16:45:17 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-23 16:45:44 +0000 |
commit | 17d6a993fc17d533460c5f40f3908c708e057c18 (patch) | |
tree | 1a3bd93e0ecd74fa02f93a528fe2f87e5314c4b5 /src/tools/cephfs_mirror/FSMirror.cc | |
parent | Releasing progress-linux version 18.2.2-0progress7.99u1. (diff) | |
download | ceph-17d6a993fc17d533460c5f40f3908c708e057c18.tar.xz ceph-17d6a993fc17d533460c5f40f3908c708e057c18.zip |
Merging upstream version 18.2.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/cephfs_mirror/FSMirror.cc')
-rw-r--r-- | src/tools/cephfs_mirror/FSMirror.cc | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/tools/cephfs_mirror/FSMirror.cc b/src/tools/cephfs_mirror/FSMirror.cc index 7ea798e6b..3d5bf2d1c 100644 --- a/src/tools/cephfs_mirror/FSMirror.cc +++ b/src/tools/cephfs_mirror/FSMirror.cc @@ -8,6 +8,8 @@ #include "common/debug.h" #include "common/errno.h" #include "common/WorkQueue.h" +#include "common/perf_counters.h" +#include "common/perf_counters_key.h" #include "include/stringify.h" #include "msg/Messenger.h" #include "FSMirror.h" @@ -25,6 +27,14 @@ using namespace std; +// Performance Counters +enum { + l_cephfs_mirror_fs_mirror_first = 5000, + l_cephfs_mirror_fs_mirror_peers, + l_cephfs_mirror_fs_mirror_dir_count, + l_cephfs_mirror_fs_mirror_last, +}; + namespace cephfs { namespace mirror { @@ -107,6 +117,18 @@ FSMirror::FSMirror(CephContext *cct, const Filesystem &filesystem, uint64_t pool m_asok_hook(new MirrorAdminSocketHook(cct, filesystem, this)) { m_service_daemon->add_or_update_fs_attribute(m_filesystem.fscid, SERVICE_DAEMON_DIR_COUNT_KEY, (uint64_t)0); + + std::string labels = ceph::perf_counters::key_create("cephfs_mirror_mirrored_filesystems", + {{"filesystem", m_filesystem.fs_name}}); + PerfCountersBuilder plb(m_cct, labels, l_cephfs_mirror_fs_mirror_first, + l_cephfs_mirror_fs_mirror_last); + auto prio = m_cct->_conf.get_val<int64_t>("cephfs_mirror_perf_stats_prio"); + plb.add_u64(l_cephfs_mirror_fs_mirror_peers, + "mirroring_peers", "Mirroring Peers", "mpee", prio); + plb.add_u64(l_cephfs_mirror_fs_mirror_dir_count, + "directory_count", "Directory Count", "dirc", prio); + m_perf_counters = plb.create_perf_counters(); + m_cct->get_perfcounters_collection()->add(m_perf_counters); } FSMirror::~FSMirror() { @@ -120,6 +142,12 @@ FSMirror::~FSMirror() { // outside the lock so that in-progress commands can acquire // lock and finish executing. delete m_asok_hook; + PerfCounters *perf_counters = nullptr; + std::swap(perf_counters, m_perf_counters); + if (perf_counters != nullptr) { + m_cct->get_perfcounters_collection()->remove(perf_counters); + delete perf_counters; + } } int FSMirror::init_replayer(PeerReplayer *peer_replayer) { @@ -355,6 +383,9 @@ void FSMirror::handle_acquire_directory(string_view dir_path) { peer_replayer->add_directory(dir_path); } } + if (m_perf_counters) { + m_perf_counters->set(l_cephfs_mirror_fs_mirror_dir_count, m_directories.size()); + } } void FSMirror::handle_release_directory(string_view dir_path) { @@ -372,6 +403,9 @@ void FSMirror::handle_release_directory(string_view dir_path) { peer_replayer->remove_directory(dir_path); } } + if (m_perf_counters) { + m_perf_counters->set(l_cephfs_mirror_fs_mirror_dir_count, m_directories.size()); + } } } @@ -395,6 +429,9 @@ void FSMirror::add_peer(const Peer &peer) { } m_peer_replayers.emplace(peer, std::move(replayer)); ceph_assert(m_peer_replayers.size() == 1); // support only a single peer + if (m_perf_counters) { + m_perf_counters->inc(l_cephfs_mirror_fs_mirror_peers); + } } void FSMirror::remove_peer(const Peer &peer) { @@ -415,6 +452,9 @@ void FSMirror::remove_peer(const Peer &peer) { dout(5) << ": shutting down replayers for peer=" << peer << dendl; shutdown_replayer(replayer.get()); } + if (m_perf_counters) { + m_perf_counters->dec(l_cephfs_mirror_fs_mirror_peers); + } } void FSMirror::mirror_status(Formatter *f) { |