From: John Spray Date: Sun, 31 Jul 2016 17:06:09 +0000 (+0100) Subject: osd: send PGStats to mgr as well as mon X-Git-Tag: v11.0.1~60^2~32 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=30dec8e2811ef9f59860da105231a5ae54cdce61;p=ceph.git osd: send PGStats to mgr as well as mon This is a rough implementation that sends all the stats, without the efficiency of the queue+acks that we use when talking to the mon. Signed-off-by: John Spray --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 1199a362a280..ae1174da6780 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -2181,6 +2181,40 @@ int OSD::init() if (r < 0) goto out; + /** + * FIXME: this is a placeholder implementation that unconditionally + * sends every is_primary PG's stats every time we're called, unlike + * the existing mon PGStats mechanism that uses pg_stat_queue and acks. + * This has equivalent cost to the existing worst case where all + * PGs are busy and their stats are always enqueued for sending. + */ + mgrc.set_pgstats_cb([this](){ + RWLock::RLocker l(map_lock); + + utime_t had_for = ceph_clock_now(cct) - had_map_since; + osd_stat_t cur_stat = service.get_osd_stat(); + cur_stat.fs_perf_stat = store->get_cur_stats(); + + MPGStats *m = new MPGStats(monc->get_fsid(), osdmap->get_epoch(), had_for); + m->osd_stat = cur_stat; + + RWLock::RLocker lpg(pg_map_lock); + for (const auto &i : pg_map) { + PG *pg = i.second; + if (!pg->is_primary()) { + continue; + } + + pg->pg_stats_publish_lock.Lock(); + if (pg->pg_stats_publish_valid) { + m->pg_stat[pg->info.pgid.pgid] = pg->pg_stats_publish; + } + pg->pg_stats_publish_lock.Unlock(); + } + + return m; + }); + mgrc.init(); client_messenger->add_dispatcher_head(&mgrc); diff --git a/src/osd/OSDMap.h b/src/osd/OSDMap.h index 88128eaa8ba6..dfeec1bee0f7 100644 --- a/src/osd/OSDMap.h +++ b/src/osd/OSDMap.h @@ -255,7 +255,9 @@ private: ceph::shared_ptr crush; // hierarchical map friend class OSDMonitor; + // FIXME: the elements required for PGMap updates should be exposed properly friend class PGMonitor; + friend class ClusterState; public: OSDMap() : epoch(0),