if (r < 0)
goto out;
- // This implementation unconditionally sends every is_primary PG's
- // stats every time we're called. This has equivalent cost to the
- // previous implementation's 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() - had_map_since;
- osd_stat_t cur_stat = service.get_osd_stat();
- cur_stat.os_perf_stat = store->get_cur_stats();
-
- MPGStats *m = new MPGStats(monc->get_fsid(), osdmap->get_epoch(), had_for);
- m->osd_stat = cur_stat;
-
- Mutex::Locker lec{min_last_epoch_clean_lock};
- min_last_epoch_clean = osdmap->get_epoch();
- min_last_epoch_clean_pgs.clear();
- RWLock::RLocker lpg(pg_map_lock);
- for (const auto &i : pg_map) {
- PG *pg = i.second;
- if (!pg->is_primary()) {
- continue;
- }
-
- pg->get_pg_stats([&](const pg_stat_t& s, epoch_t lec) {
- m->pg_stat[pg->pg_id.pgid] = s;
- min_last_epoch_clean = min(min_last_epoch_clean, lec);
- min_last_epoch_clean_pgs.push_back(pg->pg_id.pgid);
- });
- }
-
- return m;
- });
-
+ mgrc.set_pgstats_cb([this](){ return collect_pg_stats(); });
mgrc.init();
client_messenger->add_dispatcher_head(&mgrc);
dout(20) << "sched_scrub done" << dendl;
}
+MPGStats* OSD::collect_pg_stats()
+{
+ // This implementation unconditionally sends every is_primary PG's
+ // stats every time we're called. This has equivalent cost to the
+ // previous implementation's worst case where all PGs are busy and
+ // their stats are always enqueued for sending.
+ RWLock::RLocker l(map_lock);
+
+ utime_t had_for = ceph_clock_now() - had_map_since;
+ osd_stat_t cur_stat = service.get_osd_stat();
+ cur_stat.os_perf_stat = store->get_cur_stats();
+
+ auto m = new MPGStats(monc->get_fsid(), osdmap->get_epoch(), had_for);
+ m->osd_stat = cur_stat;
+
+ Mutex::Locker lec{min_last_epoch_clean_lock};
+ min_last_epoch_clean = osdmap->get_epoch();
+ min_last_epoch_clean_pgs.clear();
+ RWLock::RLocker lpg(pg_map_lock);
+ for (const auto &i : pg_map) {
+ PG *pg = i.second;
+ if (!pg->is_primary()) {
+ continue;
+ }
+ pg->get_pg_stats([&](const pg_stat_t& s, epoch_t lec) {
+ m->pg_stat[pg->pg_id.pgid] = s;
+ min_last_epoch_clean = min(min_last_epoch_clean, lec);
+ min_last_epoch_clean_pgs.push_back(pg->pg_id.pgid);
+ });
+ }
+
+ return m;
+}
// =====================================================
// MAP