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
}
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;
}
#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
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) {
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();
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;
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();
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();
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);
* @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
* @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],
* @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) {
// 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();
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);
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;
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;
#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
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;
::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;
* 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;
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;
}
// 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) {
}
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,
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);
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;
}
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;
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()) {
}
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; }
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);
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();
}
}
}
-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();
}
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;