#include "Replayer.h"
#include "common/debug.h"
#include "common/errno.h"
+#include "common/perf_counters.h"
+#include "common/perf_counters_key.h"
#include "include/stringify.h"
#include "common/Timer.h"
#include "cls/rbd/cls_rbd_client.h"
for (auto snap_info_it = image_ctx->snap_info.rbegin();
snap_info_it != image_ctx->snap_info.rend(); ++snap_info_it) {
const auto& snap_ns = snap_info_it->second.snap_namespace;
- auto mirror_ns = boost::get<
+ auto mirror_ns = std::get_if<
cls::rbd::MirrorSnapshotNamespace>(&snap_ns);
if (mirror_ns == nullptr || !mirror_ns->complete) {
continue;
json_spirit::mObject root_obj;
root_obj["replay_state"] = replay_state;
root_obj["remote_snapshot_timestamp"] = remote_snap_info->timestamp.sec();
+ if (m_perf_counters) {
+ m_perf_counters->tset(l_rbd_mirror_snapshot_remote_timestamp,
+ remote_snap_info->timestamp);
+ }
auto matching_remote_snap_id = util::compute_remote_snap_id(
m_state_builder->local_image_ctx->image_lock,
// synced and not the consistency point in time.
root_obj["local_snapshot_timestamp"] =
matching_remote_snap_it->second.timestamp.sec();
+ if (m_perf_counters) {
+ m_perf_counters->tset(l_rbd_mirror_snapshot_local_timestamp,
+ matching_remote_snap_it->second.timestamp);
+ }
}
matching_remote_snap_it = m_state_builder->remote_image_ctx->snap_info.find(
for (auto snap_info_it = local_image_ctx->snap_info.begin();
snap_info_it != local_image_ctx->snap_info.end(); ++snap_info_it) {
const auto& snap_ns = snap_info_it->second.snap_namespace;
- auto mirror_ns = boost::get<
+ auto mirror_ns = std::get_if<
cls::rbd::MirrorSnapshotNamespace>(&snap_ns);
if (mirror_ns == nullptr) {
continue;
for (auto snap_info_it = remote_image_ctx->snap_info.begin();
snap_info_it != remote_image_ctx->snap_info.end(); ++snap_info_it) {
const auto& snap_ns = snap_info_it->second.snap_namespace;
- auto mirror_ns = boost::get<
+ auto mirror_ns = std::get_if<
cls::rbd::MirrorSnapshotNamespace>(&snap_ns);
if (mirror_ns == nullptr) {
continue;
snap_namespace = snap_info->snap_namespace;
snap_name = snap_info->name;
- ceph_assert(boost::get<cls::rbd::MirrorSnapshotNamespace>(
- &snap_namespace) != nullptr);
+ ceph_assert(std::holds_alternative<cls::rbd::MirrorSnapshotNamespace>(
+ snap_namespace));
}
}
return;
}
- auto mirror_ns = boost::get<cls::rbd::MirrorSnapshotNamespace>(
+ auto mirror_ns = std::get_if<cls::rbd::MirrorSnapshotNamespace>(
&local_snap_info_it->second.snap_namespace);
ceph_assert(mirror_ns != nullptr);
// we can ignore all non-user snapshots since image state only includes
// user snapshots
- if (boost::get<cls::rbd::UserSnapshotNamespace>(
- &remote_snap_info.snap_namespace) == nullptr) {
+ if (!std::holds_alternative<cls::rbd::UserSnapshotNamespace>(
+ remote_snap_info.snap_namespace)) {
continue;
}
m_last_snapshot_sync_seconds = duration.sec();
if (g_snapshot_perf_counters) {
- g_snapshot_perf_counters->inc(l_rbd_mirror_snapshot_replay_bytes,
+ g_snapshot_perf_counters->inc(l_rbd_mirror_snapshot_sync_bytes,
m_snapshot_bytes);
- g_snapshot_perf_counters->inc(l_rbd_mirror_snapshot_replay_snapshots);
- g_snapshot_perf_counters->tinc(
- l_rbd_mirror_snapshot_replay_snapshots_time, duration);
+ g_snapshot_perf_counters->inc(l_rbd_mirror_snapshot_snapshots);
+ g_snapshot_perf_counters->tinc(l_rbd_mirror_snapshot_sync_time,
+ duration);
}
if (m_perf_counters) {
- m_perf_counters->inc(l_rbd_mirror_snapshot_replay_bytes, m_snapshot_bytes);
- m_perf_counters->inc(l_rbd_mirror_snapshot_replay_snapshots);
- m_perf_counters->tinc(l_rbd_mirror_snapshot_replay_snapshots_time, duration);
+ m_perf_counters->inc(l_rbd_mirror_snapshot_sync_bytes, m_snapshot_bytes);
+ m_perf_counters->inc(l_rbd_mirror_snapshot_snapshots);
+ m_perf_counters->tinc(l_rbd_mirror_snapshot_sync_time, duration);
+ m_perf_counters->tset(l_rbd_mirror_snapshot_last_sync_time, duration);
+ m_perf_counters->set(l_rbd_mirror_snapshot_last_sync_bytes,
+ m_snapshot_bytes);
}
}
Replayer<I>, &Replayer<I>::handle_unlink_peer>(this);
auto req = librbd::mirror::snapshot::UnlinkPeerRequest<I>::create(
m_state_builder->remote_image_ctx, remote_snap_id,
- m_remote_mirror_peer_uuid, ctx);
+ m_remote_mirror_peer_uuid, false, ctx);
req->send();
}
auto cct = static_cast<CephContext *>(m_state_builder->local_image_ctx->cct);
auto prio = cct->_conf.get_val<int64_t>("rbd_mirror_image_perf_stats_prio");
- PerfCountersBuilder plb(g_ceph_context,
- "rbd_mirror_snapshot_image_" + m_image_spec,
- l_rbd_mirror_snapshot_first,
+
+ auto local_image_ctx = m_state_builder->local_image_ctx;
+ std::string labels = ceph::perf_counters::key_create(
+ "rbd_mirror_snapshot_image",
+ {{"pool", local_image_ctx->md_ctx.get_pool_name()},
+ {"namespace", local_image_ctx->md_ctx.get_namespace()},
+ {"image", local_image_ctx->name}});
+
+ PerfCountersBuilder plb(g_ceph_context, labels, l_rbd_mirror_snapshot_first,
l_rbd_mirror_snapshot_last);
- plb.add_u64_counter(l_rbd_mirror_snapshot_replay_snapshots,
- "snapshots", "Snapshots", "r", prio);
- plb.add_time_avg(l_rbd_mirror_snapshot_replay_snapshots_time,
- "snapshots_time", "Snapshots time", "rl", prio);
- plb.add_u64_counter(l_rbd_mirror_snapshot_replay_bytes, "replay_bytes",
- "Replayed data", "rb", prio, unit_t(UNIT_BYTES));
+ plb.add_u64_counter(l_rbd_mirror_snapshot_snapshots, "snapshots",
+ "Number of snapshots synced", nullptr, prio);
+ plb.add_time_avg(l_rbd_mirror_snapshot_sync_time, "sync_time",
+ "Average sync time", nullptr, prio);
+ plb.add_u64_counter(l_rbd_mirror_snapshot_sync_bytes, "sync_bytes",
+ "Total bytes synced", nullptr, prio, unit_t(UNIT_BYTES));
+ plb.add_time(l_rbd_mirror_snapshot_remote_timestamp, "remote_timestamp",
+ "Timestamp of the remote snapshot", nullptr, prio);
+ plb.add_time(l_rbd_mirror_snapshot_local_timestamp, "local_timestamp",
+ "Timestamp of the local snapshot", nullptr, prio);
+ plb.add_time(l_rbd_mirror_snapshot_last_sync_time, "last_sync_time",
+ "Time taken to sync the last snapshot", nullptr, prio);
+ plb.add_u64(l_rbd_mirror_snapshot_last_sync_bytes, "last_sync_bytes",
+ "Bytes synced for the last snapshot", nullptr, prio,
+ unit_t(UNIT_BYTES));
+
m_perf_counters = plb.create_perf_counters();
g_ceph_context->get_perfcounters_collection()->add(m_perf_counters);
}