]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: send PGStats to mgr as well as mon
authorJohn Spray <john.spray@redhat.com>
Sun, 31 Jul 2016 17:06:09 +0000 (18:06 +0100)
committerJohn Spray <john.spray@redhat.com>
Thu, 29 Sep 2016 16:27:01 +0000 (17:27 +0100)
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 <john.spray@redhat.com>
src/osd/OSD.cc
src/osd/OSDMap.h

index 1199a362a28059bc59620c8c377545e9a08be07a..ae1174da6780d9549a3c1b18c247ac027af2aa69 100644 (file)
@@ -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);
 
index 88128eaa8ba69749766be051e9e836563118e39e..dfeec1bee0f70917f2aae1e69672260b738458bf 100644 (file)
@@ -255,7 +255,9 @@ private:
   ceph::shared_ptr<CrushWrapper> 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),