summaryrefslogtreecommitdiffstats
path: root/src/tools/cephfs_mirror/Mirror.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-23 16:45:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-23 16:45:13 +0000
commit389020e14594e4894e28d1eb9103c210b142509e (patch)
tree2ba734cdd7a243f46dda7c3d0cc88c2293d9699f /src/tools/cephfs_mirror/Mirror.cc
parentAdding upstream version 18.2.2. (diff)
downloadceph-389020e14594e4894e28d1eb9103c210b142509e.tar.xz
ceph-389020e14594e4894e28d1eb9103c210b142509e.zip
Adding upstream version 18.2.3.upstream/18.2.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/cephfs_mirror/Mirror.cc')
-rw-r--r--src/tools/cephfs_mirror/Mirror.cc46
1 files changed, 45 insertions, 1 deletions
diff --git a/src/tools/cephfs_mirror/Mirror.cc b/src/tools/cephfs_mirror/Mirror.cc
index edf903b92..fa2cf74be 100644
--- a/src/tools/cephfs_mirror/Mirror.cc
+++ b/src/tools/cephfs_mirror/Mirror.cc
@@ -9,6 +9,8 @@
#include "common/errno.h"
#include "common/Timer.h"
#include "common/WorkQueue.h"
+#include "common/perf_counters.h"
+#include "common/perf_counters_key.h"
#include "include/types.h"
#include "mon/MonClient.h"
#include "msg/Messenger.h"
@@ -20,6 +22,14 @@
#undef dout_prefix
#define dout_prefix *_dout << "cephfs::mirror::Mirror " << __func__
+// Performance Counters
+enum {
+ l_cephfs_mirror_first = 4000,
+ l_cephfs_mirror_file_systems_mirrorred,
+ l_cephfs_mirror_file_systems_mirror_enable_failures,
+ l_cephfs_mirror_last,
+};
+
namespace cephfs {
namespace mirror {
@@ -277,6 +287,17 @@ int Mirror::init(std::string &reason) {
return r;
}
+ std::string labels = ceph::perf_counters::key_create("cephfs_mirror");
+ PerfCountersBuilder plb(m_cct, labels, l_cephfs_mirror_first, l_cephfs_mirror_last);
+
+ auto prio = m_cct->_conf.get_val<int64_t>("cephfs_mirror_perf_stats_prio");
+ plb.add_u64(l_cephfs_mirror_file_systems_mirrorred,
+ "mirrored_filesystems", "Filesystems mirrored", "mir", prio);
+ plb.add_u64_counter(l_cephfs_mirror_file_systems_mirror_enable_failures,
+ "mirror_enable_failures", "Mirroring enable failures", "mirf", prio);
+ m_perf_counters = plb.create_perf_counters();
+ m_cct->get_perfcounters_collection()->add(m_perf_counters);
+
return 0;
}
@@ -285,6 +306,13 @@ void Mirror::shutdown() {
m_stopping = true;
m_cluster_watcher->shutdown();
m_cond.notify_all();
+
+ 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;
+ }
}
void Mirror::reopen_logs() {
@@ -328,6 +356,9 @@ void Mirror::handle_enable_mirroring(const Filesystem &filesystem,
m_service_daemon->add_or_update_fs_attribute(filesystem.fscid,
SERVICE_DAEMON_MIRROR_ENABLE_FAILED_KEY,
true);
+ if (m_perf_counters) {
+ m_perf_counters->inc(l_cephfs_mirror_file_systems_mirror_enable_failures);
+ }
return;
}
@@ -336,6 +367,9 @@ void Mirror::handle_enable_mirroring(const Filesystem &filesystem,
}
dout(10) << ": Initialized FSMirror for filesystem=" << filesystem << dendl;
+ if (m_perf_counters) {
+ m_perf_counters->inc(l_cephfs_mirror_file_systems_mirrorred);
+ }
}
void Mirror::handle_enable_mirroring(const Filesystem &filesystem, int r) {
@@ -353,10 +387,16 @@ void Mirror::handle_enable_mirroring(const Filesystem &filesystem, int r) {
m_service_daemon->add_or_update_fs_attribute(filesystem.fscid,
SERVICE_DAEMON_MIRROR_ENABLE_FAILED_KEY,
true);
+ if (m_perf_counters) {
+ m_perf_counters->inc(l_cephfs_mirror_file_systems_mirror_enable_failures);
+ }
return;
}
dout(10) << ": Initialized FSMirror for filesystem=" << filesystem << dendl;
+ if (m_perf_counters) {
+ m_perf_counters->inc(l_cephfs_mirror_file_systems_mirrorred);
+ }
}
void Mirror::enable_mirroring(const Filesystem &filesystem, uint64_t local_pool_id,
@@ -412,6 +452,10 @@ void Mirror::handle_disable_mirroring(const Filesystem &filesystem, int r) {
m_mirror_actions.erase(filesystem);
}
}
+
+ if (m_perf_counters) {
+ m_perf_counters->dec(l_cephfs_mirror_file_systems_mirrorred);
+ }
}
void Mirror::disable_mirroring(const Filesystem &filesystem, Context *on_finish) {
@@ -510,7 +554,7 @@ void Mirror::update_fs_mirrors() {
if (!mirror_action.action_in_progress && !_is_restarting(filesystem)) {
if (failed_restart || blocklisted_restart) {
dout(5) << ": filesystem=" << filesystem << " failed mirroring (failed: "
- << failed_restart << ", blocklisted: " << blocklisted_restart << dendl;
+ << failed_restart << ", blocklisted: " << blocklisted_restart << ")" << dendl;
_set_restarting(filesystem);
auto peers = mirror_action.fs_mirror->get_peers();
auto ctx = new C_RestartMirroring(this, filesystem, mirror_action.pool_id, peers);