]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/osd: add facilities for reporting pg stats
authorKefu Chai <kchai@redhat.com>
Mon, 4 Mar 2019 09:15:01 +0000 (17:15 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 20 Mar 2019 09:34:38 +0000 (17:34 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/osd/osd.cc
src/crimson/osd/osd.h

index 8899fd90304e56e0506e62402fd3d7b5188540ea..91ccb2010cdb68c92c1987d4c31c7b52f0686b69 100644 (file)
@@ -8,6 +8,8 @@
 #include "messages/MOSDBeacon.h"
 #include "messages/MOSDBoot.h"
 #include "messages/MOSDMap.h"
+#include "messages/MPGStats.h"
+
 #include "crimson/net/Connection.h"
 #include "crimson/net/Messenger.h"
 #include "crimson/os/cyan_collection.h"
@@ -378,6 +380,23 @@ seastar::future<> OSD::ms_handle_remote_reset(ceph::net::ConnectionRef conn)
   return seastar::now();
 }
 
+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
+  auto m = make_message<MPGStats>(monc->get_fsid(), osdmap->get_epoch());
+
+  for (auto [pgid, pg] : pgs) {
+    if (pg->is_primary()) {
+      auto stats = pg->get_stats();
+      // todo: update reported_epoch,reported_seq,last_fresh
+      stats.reported_epoch = osdmap->get_epoch();
+      m->pg_stat.emplace(pgid.pgid, std::move(stats));
+    }
+  }
+  return m;
+}
+
 OSD::cached_map_t OSD::get_map() const
 {
   return osdmap;
index 03fdc583bc51ad980737b45fe9988287880dce87..d06bbc938de6cd6b820d1f2dc906e6cf2aeb54a1 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "crimson/common/simple_lru.h"
 #include "crimson/common/shared_lru.h"
+#include "crimson/mgr/client.h"
 #include "crimson/mon/MonClient.h"
 #include "crimson/net/Dispatcher.h"
 #include "crimson/osd/chained_dispatchers.h"
@@ -38,7 +39,8 @@ namespace ceph::os {
 template<typename T> using Ref = boost::intrusive_ptr<T>;
 
 class OSD : public ceph::net::Dispatcher,
-           private OSDMapService {
+           private OSDMapService,
+           private ceph::mgr::WithStats {
   seastar::gate gate;
   const int whoami;
   const uint32_t nonce;
@@ -79,6 +81,8 @@ class OSD : public ceph::net::Dispatcher,
   seastar::future<> ms_handle_connect(ceph::net::ConnectionRef conn) override;
   seastar::future<> ms_handle_reset(ceph::net::ConnectionRef conn) override;
   seastar::future<> ms_handle_remote_reset(ceph::net::ConnectionRef conn) override;
+  // mgr::WithStats methods
+  MessageRef get_stats() const override;
 
 public:
   OSD(int id, uint32_t nonce,