From: Sage Weil Date: Tue, 16 May 2017 22:21:19 +0000 (-0400) Subject: mon/PGMap: add to mempool X-Git-Tag: v12.1.0~288^2~82 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=a2fdede8fffea3ea9d3485146c796620796f6ebf;p=ceph-ci.git mon/PGMap: add to mempool Signed-off-by: Sage Weil --- diff --git a/src/include/mempool.h b/src/include/mempool.h index 0e0badfdc68..6ae5740c2ca 100644 --- a/src/include/mempool.h +++ b/src/include/mempool.h @@ -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 diff --git a/src/mon/MgrStatMonitor.cc b/src/mon/MgrStatMonitor.cc index 4b09907871d..00ac773e620 100644 --- a/src/mon/MgrStatMonitor.cc +++ b/src/mon/MgrStatMonitor.cc @@ -34,7 +34,7 @@ public: } return &i->second; } - const ceph::unordered_map &get_osd_stat() const override { + const mempool::pgmap::unordered_map &get_osd_stat() const override { return digest.osd_stat; } diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index 9b4654f52bb..53334bce326 100644 --- a/src/mon/PGMap.cc +++ b/src/mon/PGMap.cc @@ -14,6 +14,11 @@ #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 pg_pool_sum_old; + mempool::pgmap::unordered_map 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 >::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_stats, - bool brief) const +void PGMap::dump_pg_stats_plain( + ostream& ss, + const mempool::pgmap::unordered_map& 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& stuck_pgs) const +void PGMap::get_stuck_stats( + int types, const utime_t cutoff, + mempool::pgmap::unordered_map& 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& note) const void PGMap::dump_stuck(Formatter *f, int types, utime_t cutoff) const { - ceph::unordered_map stuck_pg_stats; + mempool::pgmap::unordered_map 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 stuck_pg_stats; + mempool::pgmap::unordered_map 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 > *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 > *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& 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& pg_pool_sum_old) +void PGMap::update_pool_deltas( + CephContext *cct, const utime_t ts, + const mempool::pgmap::unordered_map& 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& pgs) const // Only called with a single bit set in "what" -static void note_stuck_detail(int what, - ceph::unordered_map& stuck_pgs, - list > *detail) +static void note_stuck_detail( + int what, + mempool::pgmap::unordered_map& stuck_pgs, + list > *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 &pg_entry, - list > *detail, - scrubbed_or_deepscrubbed_t how_scrubbed) { - + void print_unscrubbed_detailed( + const std::pair &pg_entry, + list > *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; - using pg_stat_map_t = const ceph::unordered_map; - - void print_unscrubbed_pgs(pg_stat_map_t& pg_stats, - list > &summary, - list > *detail, - const CephContext* cct) { + void print_unscrubbed_pgs( + pg_stat_map_t& pg_stats, + list > &summary, + list > *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 stuck_pgs; + mempool::pgmap::unordered_map 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; diff --git a/src/mon/PGMap.h b/src/mon/PGMap.h index 8578f7f2b79..e70ffe50c44 100644 --- a/src/mon/PGMap.h +++ b/src/mon/PGMap.h @@ -24,6 +24,7 @@ #include "common/debug.h" #include "common/TextTable.h" #include "osd/osd_types.h" +#include "include/mempool.h" #include // 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 osd_stat; + mempool::pgmap::unordered_map 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 pg_pool_sum; + mempool::pgmap::unordered_map pg_pool_sum; pool_stat_t pg_sum; osd_stat_t osd_sum; - ceph::unordered_map num_pg_by_state; + mempool::pgmap::unordered_map num_pg_by_state; struct pg_count { int acting = 0; int up = 0; @@ -60,7 +62,7 @@ public: ::decode(primary, p); } }; - ceph::unordered_map num_pg_by_osd; + mempool::pgmap::unordered_map 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 > > per_pool_sum_deltas; + mempool::pgmap::unordered_map > > per_pool_sum_deltas; /** * keep track of per-pool timestamp deltas, according to last update on * each pool. */ - ceph::unordered_map per_pool_sum_deltas_stamps; + mempool::pgmap::unordered_map 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 > per_pool_sum_delta; + mempool::pgmap::unordered_map > per_pool_sum_delta; - list< pair > pg_sum_deltas; + mempool::pgmap::list< pair > 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_stat; - set full_osds; // for pre-luminous only - set nearfull_osds; // for pre-luminous only + mempool::pgmap::unordered_map pg_stat; + mempool::pgmap::set full_osds; // for pre-luminous only + mempool::pgmap::set nearfull_osds; // for pre-luminous only float full_ratio; float nearfull_ratio; // mapping of osd to most recently reported osdmap epoch - ceph::unordered_map osd_epochs; + mempool::pgmap::unordered_map osd_epochs; class Incremental { public: + MEMPOOL_CLASS_HELPERS(); version_t version; - map pg_stat_updates; + mempool::pgmap::map pg_stat_updates; epoch_t osdmap_epoch; epoch_t pg_scan; // osdmap epoch - set pg_remove; + mempool::pgmap::set pg_remove; float full_ratio; float nearfull_ratio; utime_t stamp; private: - map osd_stat_updates; - set osd_stat_rm; + mempool::pgmap::map osd_stat_updates; + mempool::pgmap::set osd_stat_rm; // mapping of osd to most recently reported osdmap epoch - map osd_epochs; + mempool::pgmap::map osd_epochs; public: - const map &get_osd_stat_updates() const { + const mempool::pgmap::map &get_osd_stat_updates() const { return osd_stat_updates; } - const set &get_osd_stat_rm() const { + const mempool::pgmap::set &get_osd_stat_rm() const { return osd_stat_rm; } - const map &get_osd_epochs() const { + const mempool::pgmap::map &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 > pg_by_osd; - ceph::unordered_map blocked_by_sum; + mempool::pgmap::unordered_map > pg_by_osd; + mempool::pgmap::unordered_map 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& 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& 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 > *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 > *delta_avg_list); void update_one_pool_delta(CephContext *cct, const utime_t ts, @@ -300,8 +308,8 @@ public: public: - set creating_pgs; - map > > creating_pgs_by_osd_epoch; + mempool::pgmap::set creating_pgs; + mempool::pgmap::map > > 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& pgs) const; - void dump_pg_stats_plain(ostream& ss, - const ceph::unordered_map& pg_stats, - bool brief) const; - void get_stuck_stats(int types, const utime_t cutoff, - ceph::unordered_map& stuck_pgs) const; + void dump_pg_stats_plain( + ostream& ss, + const mempool::pgmap::unordered_map& pg_stats, + bool brief) const; + void get_stuck_stats( + int types, const utime_t cutoff, + mempool::pgmap::unordered_map& stuck_pgs) const; bool get_stuck_counts(const utime_t cutoff, map& 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; diff --git a/src/mon/PGMonitor.cc b/src/mon/PGMonitor.cc index 6522361656e..a9ad27e73f2 100644 --- a/src/mon/PGMonitor.cc +++ b/src/mon/PGMonitor.cc @@ -353,7 +353,7 @@ void PGMonitor::apply_pgmap_delta(bufferlist& bl) } pool_stat_t pg_sum_old = pg_map.pg_sum; - ceph::unordered_map pg_pool_sum_old; + mempool::pgmap::unordered_map pg_pool_sum_old; // pgs set deleted_pools; @@ -1143,7 +1143,7 @@ void PGMonitor::get_health(list >& summary, void PGMonitor::check_full_osd_health(list >& summary, list > *detail, - const set& s, const char *desc, + const mempool::pgmap::set& s, const char *desc, health_status_t sev) const { if (!s.empty()) { @@ -1225,7 +1225,7 @@ public: } return &i->second; } - const ceph::unordered_map& get_osd_stat() const override { + const mempool::pgmap::unordered_map& get_osd_stat() const override { return pgmap.osd_stat; } float get_full_ratio() const override { return pgmap.full_ratio; } diff --git a/src/mon/PGMonitor.h b/src/mon/PGMonitor.h index 111d04fd634..347fc8f4a61 100644 --- a/src/mon/PGMonitor.h +++ b/src/mon/PGMonitor.h @@ -124,9 +124,11 @@ public: void get_health(list >& summary, list > *detail, CephContext *cct) const override; - void check_full_osd_health(list >& summary, - list > *detail, - const set& s, const char *desc, health_status_t sev) const; + void check_full_osd_health( + list >& summary, + list > *detail, + const mempool::pgmap::set& s, + const char *desc, health_status_t sev) const; void check_subs(); bool check_sub(Subscription *sub); diff --git a/src/mon/PGStatService.h b/src/mon/PGStatService.h index cc6c00f43a7..9f7900795b1 100644 --- a/src/mon/PGStatService.h +++ b/src/mon/PGStatService.h @@ -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& get_osd_stat() const = 0; + virtual const mempool::pgmap::unordered_map& get_osd_stat() const = 0; virtual float get_full_ratio() const { ceph_abort(); } diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index f2de5406f47..0f1c6f5df87 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -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 &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 &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 &osd_stat, - map *full, map *backfill, map *nearfull) const +void OSDMap::get_full_osd_util( + const mempool::pgmap::unordered_map &osd_stat, + map *full, map *backfill, map *nearfull) const { full->clear(); backfill->clear(); diff --git a/src/osd/OSDMap.h b/src/osd/OSDMap.h index b7dfd9bd3c2..904f3c0af6d 100644 --- a/src/osd/OSDMap.h +++ b/src/osd/OSDMap.h @@ -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 &osd_stat, + const mempool::pgmap::unordered_map &osd_stat, map *full, map *backfill, map *nearfull) const;