From: Kefu Chai Date: Fri, 3 Jul 2020 07:59:11 +0000 (+0800) Subject: crimson/{mgr,osd}: add WithStats::update_stats() X-Git-Tag: v16.1.0~1848^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d5e1d104ffcfd8d29454042bc73b96b690cdae9b;p=ceph.git crimson/{mgr,osd}: add WithStats::update_stats() because we need to implement a tell command which forces osd to send the latest pg stats to mgr, and the command returns the user with the sequence id of the report, and `mgr::Client::report()` does not return a future, so we have to update the seq id before sending the report. the solution is to update the seq id in a separated method, so in this change: * add `const` to `WithStats::get_stats() * add a dedicated method of `WithStats::update_stats()` to update the stats to be collected by mgr::Client. Signed-off-by: Kefu Chai --- diff --git a/src/crimson/mgr/client.cc b/src/crimson/mgr/client.cc index 74403fc4e955..dd86ac88a0e6 100644 --- a/src/crimson/mgr/client.cc +++ b/src/crimson/mgr/client.cc @@ -142,6 +142,7 @@ seastar::future<> Client::handle_mgr_conf(crimson::net::Connection* conn, void Client::report() { + with_stats.update_stats(); gate.dispatch_in_background(__func__, *this, [this] { assert(conn); auto pg_stats = with_stats.get_stats(); diff --git a/src/crimson/mgr/client.h b/src/crimson/mgr/client.h index 51130b06bc53..919fdeb60803 100644 --- a/src/crimson/mgr/client.h +++ b/src/crimson/mgr/client.h @@ -24,9 +24,8 @@ namespace crimson::mgr // implement WithStats if you want to report stats to mgr periodically class WithStats { public: - // the method is not const, because the class sending stats might need to - // update a seq number every time it collects the stats - virtual MessageRef get_stats() = 0; + virtual void update_stats() = 0; + virtual MessageRef get_stats() const = 0; virtual ~WithStats() {} }; diff --git a/src/crimson/osd/osd.cc b/src/crimson/osd/osd.cc index 527da83c705a..0744d98d5ea5 100644 --- a/src/crimson/osd/osd.cc +++ b/src/crimson/osd/osd.cc @@ -684,7 +684,14 @@ void OSD::handle_authentication(const EntityName& name, // todo } -MessageRef OSD::get_stats() +void OSD::update_stats() +{ + osd_stat_seq++; + osd_stat.up_from = get_up_epoch(); + osd_stat.seq = (static_cast(get_up_epoch()) << 32) | osd_stat_seq; +} + +MessageRef OSD::get_stats() const { // todo: m-to-n: collect stats using map-reduce // MPGStats::had_map_for is not used since PGMonitor was removed diff --git a/src/crimson/osd/osd.h b/src/crimson/osd/osd.h index 18197aa8cd7f..0e8723ab8dd5 100644 --- a/src/crimson/osd/osd.h +++ b/src/crimson/osd/osd.h @@ -102,7 +102,11 @@ class OSD final : public crimson::net::Dispatcher, void ms_handle_remote_reset(crimson::net::ConnectionRef conn) final; // mgr::WithStats methods - MessageRef get_stats() final; + // pg statistics including osd ones + osd_stat_t osd_stat; + uint32_t osd_stat_seq = 0; + void update_stats() final; + MessageRef get_stats() const final; // AuthHandler methods void handle_authentication(const EntityName& name,