]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mon/PGMap: add to mempool
authorSage Weil <sage@redhat.com>
Tue, 16 May 2017 22:21:19 +0000 (18:21 -0400)
committerSage Weil <sage@redhat.com>
Fri, 2 Jun 2017 17:02:42 +0000 (13:02 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
src/include/mempool.h
src/mon/MgrStatMonitor.cc
src/mon/PGMap.cc
src/mon/PGMap.h
src/mon/PGMonitor.cc
src/mon/PGMonitor.h
src/mon/PGStatService.h
src/osd/OSDMap.cc
src/osd/OSDMap.h

index 0e0badfdc685b9d8b08432c67ccc527f94fa78e5..6ae5740c2caf24f603a88388fec4a9fc1b6f2d26 100644 (file)
@@ -151,7 +151,10 @@ namespace mempool {
   f(osd)                             \
   f(osd_mapbl)                       \
   f(osdmap)                          \
-  f(osdmap_mapping)
+  f(osdmap_mapping)                  \
+  f(pgmap)                           \
+  f(unittest_1)                              \
+  f(unittest_2)
 
 
 // give them integer ids
index 4b09907871d9879ca0a8258e25cbb5ac2b83b7cd..00ac773e620db07981a6096c2a90c30997197ca3 100644 (file)
@@ -34,7 +34,7 @@ public:
     }
     return &i->second;
   }
-  const ceph::unordered_map<int32_t,osd_stat_t> &get_osd_stat() const override {
+  const mempool::pgmap::unordered_map<int32_t,osd_stat_t> &get_osd_stat() const override {
     return digest.osd_stat;
   }
 
index 9b4654f52bb584a2e7ff6b527972664f5cb8a900..53334bce326ade995270fe45f2ce8ea4e7c377c9 100644 (file)
 
 #define dout_context g_ceph_context
 
+MEMPOOL_DEFINE_OBJECT_FACTORY(PGMapDigest, pgmap_digest, pgmap);
+MEMPOOL_DEFINE_OBJECT_FACTORY(PGMap, pgmap, pgmap);
+MEMPOOL_DEFINE_OBJECT_FACTORY(PGMap::Incremental, pgmap_inc, pgmap);
+
+
 // ---------------------
 // PGMapDigest
 
@@ -990,7 +995,7 @@ void PGMap::apply_incremental(CephContext *cct, const Incremental& inc)
   stamp = inc.stamp;
 
   pool_stat_t pg_sum_old = pg_sum;
-  ceph::unordered_map<uint64_t, pool_stat_t> pg_pool_sum_old;
+  mempool::pgmap::unordered_map<uint64_t, pool_stat_t> pg_pool_sum_old;
 
   bool ratios_changed = false;
   if (inc.full_ratio != full_ratio && inc.full_ratio != -1) {
@@ -1091,7 +1096,7 @@ void PGMap::apply_incremental(CephContext *cct, const Incremental& inc)
   stamp_delta += delta_t;
 
   pg_sum_delta.stats.add(d.stats);
-  if (pg_sum_deltas.size() > (std::list< pair<pool_stat_t, utime_t> >::size_type)MAX(1, cct ? cct->_conf->mon_stat_smooth_intervals : 1)) {
+  if (pg_sum_deltas.size() > (unsigned)MAX(1, cct ? cct->_conf->mon_stat_smooth_intervals : 1)) {
     pg_sum_delta.stats.sub(pg_sum_deltas.front().first.stats);
     stamp_delta -= pg_sum_deltas.front().second;
     pg_sum_deltas.pop_front();
@@ -1603,9 +1608,10 @@ void PGMap::dump_osd_stats(Formatter *f) const
   f->close_section();
 }
 
-void PGMap::dump_pg_stats_plain(ostream& ss,
-                                const ceph::unordered_map<pg_t, pg_stat_t>& pg_stats,
-                                bool brief) const
+void PGMap::dump_pg_stats_plain(
+  ostream& ss,
+  const mempool::pgmap::unordered_map<pg_t, pg_stat_t>& pg_stats,
+  bool brief) const
 {
   TextTable tab;
 
@@ -1844,8 +1850,9 @@ void PGMap::dump_osd_sum_stats(ostream& ss) const
   ss << tab;
 }
 
-void PGMap::get_stuck_stats(int types, const utime_t cutoff,
-                            ceph::unordered_map<pg_t, pg_stat_t>& stuck_pgs) const
+void PGMap::get_stuck_stats(
+  int types, const utime_t cutoff,
+  mempool::pgmap::unordered_map<pg_t, pg_stat_t>& stuck_pgs) const
 {
   assert(types != 0);
   for (auto i = pg_stat.begin();
@@ -1938,7 +1945,7 @@ bool PGMap::get_stuck_counts(const utime_t cutoff, map<string, int>& note) const
 
 void PGMap::dump_stuck(Formatter *f, int types, utime_t cutoff) const
 {
-  ceph::unordered_map<pg_t, pg_stat_t> stuck_pg_stats;
+  mempool::pgmap::unordered_map<pg_t, pg_stat_t> stuck_pg_stats;
   get_stuck_stats(types, cutoff, stuck_pg_stats);
   f->open_array_section("stuck_pg_stats");
   for (auto i = stuck_pg_stats.begin();
@@ -1954,7 +1961,7 @@ void PGMap::dump_stuck(Formatter *f, int types, utime_t cutoff) const
 
 void PGMap::dump_stuck_plain(ostream& ss, int types, utime_t cutoff) const
 {
-  ceph::unordered_map<pg_t, pg_stat_t> stuck_pg_stats;
+  mempool::pgmap::unordered_map<pg_t, pg_stat_t> stuck_pg_stats;
   get_stuck_stats(types, cutoff, stuck_pg_stats);
   if (!stuck_pg_stats.empty())
     dump_pg_stats_plain(ss, stuck_pg_stats, true);
@@ -2073,14 +2080,15 @@ void PGMap::print_osd_blocked_by_stats(std::ostream *ss) const
  * @param result_ts_delta   Resulting timestamp delta
  * @param delta_avg_list    List of last N computed deltas, used to average
  */
-void PGMap::update_delta(CephContext *cct,
-                         const utime_t ts,
-                         const pool_stat_t& old_pool_sum,
-                         utime_t *last_ts,
-                         const pool_stat_t& current_pool_sum,
-                         pool_stat_t *result_pool_delta,
-                         utime_t *result_ts_delta,
-                         list<pair<pool_stat_t,utime_t> > *delta_avg_list)
+void PGMap::update_delta(
+  CephContext *cct,
+  const utime_t ts,
+  const pool_stat_t& old_pool_sum,
+  utime_t *last_ts,
+  const pool_stat_t& current_pool_sum,
+  pool_stat_t *result_pool_delta,
+  utime_t *result_ts_delta,
+  mempool::pgmap::list<pair<pool_stat_t,utime_t> > *delta_avg_list)
 {
   /* @p ts is the timestamp we want to associate with the data
    * in @p old_pool_sum, and on which we will base ourselves to
@@ -2140,17 +2148,18 @@ void PGMap::update_global_delta(CephContext *cct,
  * @param pool          Pool's id
  * @param old_pool_sum  Previous stats sum
  */
-void PGMap::update_one_pool_delta(CephContext *cct,
-                                  const utime_t ts,
-                                  const uint64_t pool,
-                                  const pool_stat_t& old_pool_sum)
+void PGMap::update_one_pool_delta(
+  CephContext *cct,
+  const utime_t ts,
+  const uint64_t pool,
+  const pool_stat_t& old_pool_sum)
 {
   if (per_pool_sum_deltas.count(pool) == 0) {
     assert(per_pool_sum_deltas_stamps.count(pool) == 0);
     assert(per_pool_sum_delta.count(pool) == 0);
   }
 
-  pair<pool_stat_t,utime_t>& sum_delta = per_pool_sum_delta[pool];
+  auto& sum_delta = per_pool_sum_delta[pool];
 
   update_delta(cct, ts, old_pool_sum, &sum_delta.second, pg_pool_sum[pool],
                &sum_delta.first, &per_pool_sum_deltas_stamps[pool],
@@ -2164,8 +2173,9 @@ void PGMap::update_one_pool_delta(CephContext *cct,
  * @param ts                Timestamp for the stats being delta'ed
  * @param pg_pool_sum_old   Map of pool stats for delta calcs.
  */
-void PGMap::update_pool_deltas(CephContext *cct, const utime_t ts,
-                               const ceph::unordered_map<uint64_t,pool_stat_t>& pg_pool_sum_old)
+void PGMap::update_pool_deltas(
+  CephContext *cct, const utime_t ts,
+  const mempool::pgmap::unordered_map<uint64_t,pool_stat_t>& pg_pool_sum_old)
 {
   for (auto it = pg_pool_sum_old.begin();
        it != pg_pool_sum_old.end(); ++it) {
@@ -2288,9 +2298,10 @@ void PGMap::dump_filtered_pg_stats(ostream& ss, set<pg_t>& pgs) const
 
 
 // Only called with a single bit set in "what"
-static void note_stuck_detail(int what,
-                              ceph::unordered_map<pg_t,pg_stat_t>& stuck_pgs,
-                              list<pair<health_status_t,string> > *detail)
+static void note_stuck_detail(
+  int what,
+  mempool::pgmap::unordered_map<pg_t,pg_stat_t>& stuck_pgs,
+  list<pair<health_status_t,string> > *detail)
 {
   for (auto p = stuck_pgs.begin();
        p != stuck_pgs.end();
@@ -2364,10 +2375,11 @@ static int _warn_slow_request_histogram(
 namespace {
   enum class scrubbed_or_deepscrubbed_t { SCRUBBED, DEEPSCRUBBED };
 
-  void print_unscrubbed_detailed(const std::pair<const pg_t,pg_stat_t> &pg_entry,
-                                list<pair<health_status_t,string> > *detail,
-                                scrubbed_or_deepscrubbed_t how_scrubbed) {
-
+  void print_unscrubbed_detailed(
+    const std::pair<const pg_t,pg_stat_t> &pg_entry,
+    list<pair<health_status_t,string> > *detail,
+    scrubbed_or_deepscrubbed_t how_scrubbed)
+  {
     std::stringstream ss;
     const auto& pg_stat(pg_entry.second);
 
@@ -2383,13 +2395,14 @@ namespace {
     detail->push_back(make_pair(HEALTH_WARN, ss.str()));
   }
 
+  using pg_stat_map_t = const mempool::pgmap::unordered_map<pg_t,pg_stat_t>;
 
-  using pg_stat_map_t = const ceph::unordered_map<pg_t,pg_stat_t>;
-
-  void print_unscrubbed_pgs(pg_stat_map_t& pg_stats,
-                           list<pair<health_status_t,string> > &summary,
-                           list<pair<health_status_t,string> > *detail,
-                           const CephContext* cct) {
+  void print_unscrubbed_pgs(
+    pg_stat_map_t& pg_stats,
+    list<pair<health_status_t,string> > &summary,
+    list<pair<health_status_t,string> > *detail,
+    const CephContext* cct)
+  {
     if (cct->_conf->mon_warn_not_scrubbed == 0 &&
       cct->_conf->mon_warn_not_deep_scrubbed == 0)
       return;
@@ -2479,7 +2492,7 @@ void PGMap::get_health(
       note["recovery_toofull"] += p->second;
   }
 
-  ceph::unordered_map<pg_t, pg_stat_t> stuck_pgs;
+  mempool::pgmap::unordered_map<pg_t, pg_stat_t> stuck_pgs;
   utime_t now(ceph_clock_now());
   utime_t cutoff = now - utime_t(cct->_conf->mon_pg_stuck_threshold, 0);
   uint64_t num_inactive_pgs = 0;
index 8578f7f2b7990df287cf2858c165b045425e7a45..e70ffe50c44aa4fcd21f691b03d50f6f81428710 100644 (file)
@@ -24,6 +24,7 @@
 #include "common/debug.h"
 #include "common/TextTable.h"
 #include "osd/osd_types.h"
+#include "include/mempool.h"
 #include <sstream>
 
 // FIXME: don't like including this here to get OSDMap::Incremental, maybe
@@ -34,17 +35,18 @@ namespace ceph { class Formatter; }
 
 class PGMapDigest {
 public:
+  MEMPOOL_CLASS_HELPERS();
   virtual ~PGMapDigest() {}
 
-  ceph::unordered_map<int32_t,osd_stat_t> osd_stat;
+  mempool::pgmap::unordered_map<int32_t,osd_stat_t> osd_stat;
 
   // aggregate state, populated by PGMap child
   int64_t num_pg = 0, num_osd = 0;
   int64_t num_pg_active = 0;
-  ceph::unordered_map<int,pool_stat_t> pg_pool_sum;
+  mempool::pgmap::unordered_map<int,pool_stat_t> pg_pool_sum;
   pool_stat_t pg_sum;
   osd_stat_t osd_sum;
-  ceph::unordered_map<int,int> num_pg_by_state;
+  mempool::pgmap::unordered_map<int,int> num_pg_by_state;
   struct pg_count {
     int acting = 0;
     int up = 0;
@@ -60,7 +62,7 @@ public:
       ::decode(primary, p);
     }
   };
-  ceph::unordered_map<int,pg_count> num_pg_by_osd;
+  mempool::pgmap::unordered_map<int,pg_count> num_pg_by_osd;
 
   void print_summary(Formatter *f, ostream *out) const;
   void print_oneline_summary(Formatter *f, ostream *out) const;
@@ -70,21 +72,21 @@ public:
    * keep track of last deltas for each pool, calculated using
    * @p pg_pool_sum as baseline.
    */
-  ceph::unordered_map<uint64_t, list< pair<pool_stat_t, utime_t> > > per_pool_sum_deltas;
+  mempool::pgmap::unordered_map<uint64_t, mempool::pgmap::list< pair<pool_stat_t, utime_t> > > per_pool_sum_deltas;
   /**
    * keep track of per-pool timestamp deltas, according to last update on
    * each pool.
    */
-  ceph::unordered_map<uint64_t, utime_t> per_pool_sum_deltas_stamps;
+  mempool::pgmap::unordered_map<uint64_t, utime_t> per_pool_sum_deltas_stamps;
   /**
    * keep track of sum deltas, per-pool, taking into account any previous
    * deltas existing in @p per_pool_sum_deltas.  The utime_t as second member
    * of the pair is the timestamp refering to the last update (i.e., the first
    * member of the pair) for a given pool.
    */
-  ceph::unordered_map<uint64_t, pair<pool_stat_t,utime_t> > per_pool_sum_delta;
+  mempool::pgmap::unordered_map<uint64_t, pair<pool_stat_t,utime_t> > per_pool_sum_delta;
 
-  list< pair<pool_stat_t, utime_t> > pg_sum_deltas;
+  mempool::pgmap::list< pair<pool_stat_t, utime_t> > pg_sum_deltas;
   pool_stat_t pg_sum_delta;
   utime_t stamp_delta;
 
@@ -180,45 +182,48 @@ WRITE_CLASS_ENCODER_FEATURES(PGMapDigest);
 
 class PGMap : public PGMapDigest {
 public:
+  MEMPOOL_CLASS_HELPERS();
+
   // the map
   version_t version;
   epoch_t last_osdmap_epoch;   // last osdmap epoch i applied to the pgmap
   epoch_t last_pg_scan;  // osdmap epoch
-  ceph::unordered_map<pg_t,pg_stat_t> pg_stat;
-  set<int32_t> full_osds;     // for pre-luminous only
-  set<int32_t> nearfull_osds; // for pre-luminous only
+  mempool::pgmap::unordered_map<pg_t,pg_stat_t> pg_stat;
+  mempool::pgmap::set<int32_t> full_osds;     // for pre-luminous only
+  mempool::pgmap::set<int32_t> nearfull_osds; // for pre-luminous only
   float full_ratio;
   float nearfull_ratio;
 
   // mapping of osd to most recently reported osdmap epoch
-  ceph::unordered_map<int32_t,epoch_t> osd_epochs;
+  mempool::pgmap::unordered_map<int32_t,epoch_t> osd_epochs;
 
   class Incremental {
   public:
+    MEMPOOL_CLASS_HELPERS();
     version_t version;
-    map<pg_t,pg_stat_t> pg_stat_updates;
+    mempool::pgmap::map<pg_t,pg_stat_t> pg_stat_updates;
     epoch_t osdmap_epoch;
     epoch_t pg_scan;  // osdmap epoch
-    set<pg_t> pg_remove;
+    mempool::pgmap::set<pg_t> pg_remove;
     float full_ratio;
     float nearfull_ratio;
     utime_t stamp;
 
   private:
-    map<int32_t,osd_stat_t> osd_stat_updates;
-    set<int32_t> osd_stat_rm;
+    mempool::pgmap::map<int32_t,osd_stat_t> osd_stat_updates;
+    mempool::pgmap::set<int32_t> osd_stat_rm;
 
     // mapping of osd to most recently reported osdmap epoch
-    map<int32_t,epoch_t> osd_epochs;
+    mempool::pgmap::map<int32_t,epoch_t> osd_epochs;
   public:
 
-    const map<int32_t, osd_stat_t> &get_osd_stat_updates() const {
+    const mempool::pgmap::map<int32_t, osd_stat_t> &get_osd_stat_updates() const {
       return osd_stat_updates;
     }
-    const set<int32_t> &get_osd_stat_rm() const {
+    const mempool::pgmap::set<int32_t> &get_osd_stat_rm() const {
       return osd_stat_rm;
     }
-    const map<int32_t, epoch_t> &get_osd_epochs() const {
+    const mempool::pgmap::map<int32_t, epoch_t> &get_osd_epochs() const {
       return osd_epochs;
     }
 
@@ -262,16 +267,18 @@ public:
 
   // aggregate stats (soft state), generated by calc_stats()
   mutable epoch_t min_last_epoch_clean = 0;
-  ceph::unordered_map<int,set<pg_t> > pg_by_osd;
-  ceph::unordered_map<int,int> blocked_by_sum;
+  mempool::pgmap::unordered_map<int,set<pg_t> > pg_by_osd;
+  mempool::pgmap::unordered_map<int,int> blocked_by_sum;
 
   utime_t stamp;
 
-  void update_global_delta(CephContext *cct,
-                           const utime_t ts, const pool_stat_t& pg_sum_old);
-  void update_pool_deltas(CephContext *cct,
-                          const utime_t ts,
-                          const ceph::unordered_map<uint64_t, pool_stat_t>& pg_pool_sum_old);
+  void update_global_delta(
+    CephContext *cct,
+    const utime_t ts, const pool_stat_t& pg_sum_old);
+  void update_pool_deltas(
+    CephContext *cct,
+    const utime_t ts,
+    const mempool::pgmap::unordered_map<uint64_t, pool_stat_t>& pg_pool_sum_old);
   void clear_delta();
 
   void deleted_pool(int64_t pool) {
@@ -282,14 +289,15 @@ public:
   }
 
  private:
-  void update_delta(CephContext *cct,
-                    const utime_t ts,
-                    const pool_stat_t& old_pool_sum,
-                    utime_t *last_ts,
-                    const pool_stat_t& current_pool_sum,
-                    pool_stat_t *result_pool_delta,
-                    utime_t *result_ts_delta,
-                    list<pair<pool_stat_t,utime_t> > *delta_avg_list);
+  void update_delta(
+    CephContext *cct,
+    const utime_t ts,
+    const pool_stat_t& old_pool_sum,
+    utime_t *last_ts,
+    const pool_stat_t& current_pool_sum,
+    pool_stat_t *result_pool_delta,
+    utime_t *result_ts_delta,
+    mempool::pgmap::list<pair<pool_stat_t,utime_t> > *delta_avg_list);
 
   void update_one_pool_delta(CephContext *cct,
                              const utime_t ts,
@@ -300,8 +308,8 @@ public:
 
  public:
 
-  set<pg_t> creating_pgs;
-  map<int,map<epoch_t,set<pg_t> > > creating_pgs_by_osd_epoch;
+  mempool::pgmap::set<pg_t> creating_pgs;
+  mempool::pgmap::map<int,map<epoch_t,set<pg_t> > > creating_pgs_by_osd_epoch;
 
   // Bits that use to be enum StuckPG
   static const int STUCK_INACTIVE = (1<<0);
@@ -390,11 +398,13 @@ public:
   void dump_delta(Formatter *f) const;
   void dump_filtered_pg_stats(Formatter *f, set<pg_t>& pgs) const;
 
-  void dump_pg_stats_plain(ostream& ss,
-                          const ceph::unordered_map<pg_t, pg_stat_t>& pg_stats,
-                          bool brief) const;
-  void get_stuck_stats(int types, const utime_t cutoff,
-                      ceph::unordered_map<pg_t, pg_stat_t>& stuck_pgs) const;
+  void dump_pg_stats_plain(
+    ostream& ss,
+    const mempool::pgmap::unordered_map<pg_t, pg_stat_t>& pg_stats,
+    bool brief) const;
+  void get_stuck_stats(
+    int types, const utime_t cutoff,
+    mempool::pgmap::unordered_map<pg_t, pg_stat_t>& stuck_pgs) const;
   bool get_stuck_counts(const utime_t cutoff, map<string, int>& note) const;
   void dump_stuck(Formatter *f, int types, utime_t cutoff) const;
   void dump_stuck_plain(ostream& ss, int types, utime_t cutoff) const;
index 6522361656e9b175a57e0a50faf7c008eb298fd9..a9ad27e73f25c9cc68bb5bfa1feff4f5b2a7f821 100644 (file)
@@ -353,7 +353,7 @@ void PGMonitor::apply_pgmap_delta(bufferlist& bl)
   }
 
   pool_stat_t pg_sum_old = pg_map.pg_sum;
-  ceph::unordered_map<uint64_t, pool_stat_t> pg_pool_sum_old;
+  mempool::pgmap::unordered_map<uint64_t, pool_stat_t> pg_pool_sum_old;
 
   // pgs
   set<int64_t> deleted_pools;
@@ -1143,7 +1143,7 @@ void PGMonitor::get_health(list<pair<health_status_t,string> >& summary,
 
 void PGMonitor::check_full_osd_health(list<pair<health_status_t,string> >& summary,
                                       list<pair<health_status_t,string> > *detail,
-                                      const set<int>& s, const char *desc,
+                                      const mempool::pgmap::set<int>& s, const char *desc,
                                       health_status_t sev) const
 {
   if (!s.empty()) {
@@ -1225,7 +1225,7 @@ public:
     }
     return &i->second;
   }
-  const ceph::unordered_map<int32_t,osd_stat_t>& get_osd_stat() const override {
+  const mempool::pgmap::unordered_map<int32_t,osd_stat_t>& get_osd_stat() const override {
     return pgmap.osd_stat;
   }
   float get_full_ratio() const override { return pgmap.full_ratio; }
index 111d04fd634cc0e0d4781c92a0fd4bf6a4ae142e..347fc8f4a61a19625a4a53c757511051423c3054 100644 (file)
@@ -124,9 +124,11 @@ public:
   void get_health(list<pair<health_status_t,string> >& summary,
                  list<pair<health_status_t,string> > *detail,
                  CephContext *cct) const override;
-  void check_full_osd_health(list<pair<health_status_t,string> >& summary,
-                            list<pair<health_status_t,string> > *detail,
-                            const set<int>& s, const char *desc, health_status_t sev) const;
+  void check_full_osd_health(
+    list<pair<health_status_t,string> >& summary,
+    list<pair<health_status_t,string> > *detail,
+    const mempool::pgmap::set<int>& s,
+    const char *desc, health_status_t sev) const;
 
   void check_subs();
   bool check_sub(Subscription *sub);
index cc6c00f43a7924db80ab9c3b6da1f1d82f0d2b0e..9f7900795b10fa2d97f71fcf204270e74ad26a02 100644 (file)
@@ -42,7 +42,7 @@ public:
   virtual const osd_stat_t& get_osd_sum() const = 0;
 
   virtual const osd_stat_t *get_osd_stat(int osd) const = 0;
-  virtual const ceph::unordered_map<int32_t,osd_stat_t>& get_osd_stat() const = 0;
+  virtual const mempool::pgmap::unordered_map<int32_t,osd_stat_t>& get_osd_stat() const = 0;
   virtual float get_full_ratio() const {
     ceph_abort();
   }
index f2de5406f47c35c163bdc271fd854e51fb9529bb..0f1c6f5df87c2071a78a4d8d2adf926b57e2a2ec 100644 (file)
@@ -1111,19 +1111,22 @@ void OSDMap::count_full_nearfull_osds(int *full, int *backfill, int *nearfull) c
   }
 }
 
-static bool get_osd_utilization(const ceph::unordered_map<int32_t,osd_stat_t> &osd_stat,
-   int id, int64_t* kb, int64_t* kb_used, int64_t* kb_avail) {
-    auto p = osd_stat.find(id);
-    if (p == osd_stat.end())
-      return false;
-    *kb = p->second.kb;
-    *kb_used = p->second.kb_used;
-    *kb_avail = p->second.kb_avail;
-    return *kb > 0;
+static bool get_osd_utilization(
+  const mempool::pgmap::unordered_map<int32_t,osd_stat_t> &osd_stat,
+  int id, int64_t* kb, int64_t* kb_used, int64_t* kb_avail)
+{
+  auto p = osd_stat.find(id);
+  if (p == osd_stat.end())
+    return false;
+  *kb = p->second.kb;
+  *kb_used = p->second.kb_used;
+  *kb_avail = p->second.kb_avail;
+  return *kb > 0;
 }
 
-void OSDMap::get_full_osd_util(const ceph::unordered_map<int32_t,osd_stat_t> &osd_stat,
-     map<int, float> *full, map<int, float> *backfill, map<int, float> *nearfull) const
+void OSDMap::get_full_osd_util(
+  const mempool::pgmap::unordered_map<int32_t,osd_stat_t> &osd_stat,
+  map<int, float> *full, map<int, float> *backfill, map<int, float> *nearfull) const
 {
   full->clear();
   backfill->clear();
index b7dfd9bd3c2da3381d50af1c78433fc0befb185a..904f3c0af6dcfd1237d43f1d9a9b35fc1c93b33b 100644 (file)
@@ -606,7 +606,7 @@ public:
   }
   void count_full_nearfull_osds(int *full, int *backfill, int *nearfull) const;
   void get_full_osd_util(
-    const ceph::unordered_map<int32_t,osd_stat_t> &osd_stat,
+    const mempool::pgmap::unordered_map<int32_t,osd_stat_t> &osd_stat,
     map<int, float> *full,
     map<int, float> *backfill,
     map<int, float> *nearfull) const;