::encode((float).85, bl); // nearfull_ratio
::encode(pg_remove, bl);
::encode(stamp, bl);
- ::encode(osd_epochs, bl);
+ {
+ map<int32_t,epoch_t> osd_epochs;
+ ::encode(osd_epochs, bl);
+ }
ENCODE_FINISH(bl);
}
if (struct_v >= 6)
::decode(stamp, bl);
if (struct_v >= 7) {
+ map<int32_t,epoch_t> osd_epochs;
::decode(osd_epochs, bl);
- } else {
- for (auto i = osd_stat_updates.begin();
- i != osd_stat_updates.end();
- ++i) {
- // This isn't accurate, but will cause trimming to behave like
- // previously.
- osd_epochs.insert(make_pair(i->first, osdmap_epoch));
- }
}
DECODE_FINISH(bl);
}
o.back()->version = 2;
o.back()->pg_stat_updates[pg_t(1,2,3)] = pg_stat_t();
o.back()->osd_stat_updates[5] = osd_stat_t();
- o.back()->osd_epochs[5] = 12;
o.push_back(new Incremental);
o.back()->version = 3;
o.back()->osdmap_epoch = 1;
o.back()->pg_scan = 2;
o.back()->pg_stat_updates[pg_t(4,5,6)] = pg_stat_t();
o.back()->osd_stat_updates[6] = osd_stat_t();
- o.back()->osd_epochs[6] = 12;
o.back()->pg_remove.insert(pg_t(1,2,3));
o.back()->osd_stat_rm.insert(5);
}
}
stat_pg_add(update_pg, update_stat);
}
- assert(osd_stat.size() == osd_epochs.size());
for (auto p = inc.get_osd_stat_updates().begin();
p != inc.get_osd_stat_updates().end();
++p) {
stat_osd_sub(t->first, t->second);
t->second = new_stats;
}
- auto i = osd_epochs.find(osd);
- auto j = inc.get_osd_epochs().find(osd);
- assert(j != inc.get_osd_epochs().end());
-
- if (i == osd_epochs.end())
- osd_epochs.insert(*j);
- else
- i->second = j->second;
-
stat_osd_add(osd, new_stats);
}
set<int64_t> deleted_pools;
if (t != osd_stat.end()) {
stat_osd_sub(t->first, t->second);
osd_stat.erase(t);
- osd_epochs.erase(*p);
}
}
{
bufferlist::iterator p = bl.begin();
auto o = osd_stat.find(osd);
- epoch_t old_lec = 0;
if (o != osd_stat.end()) {
- auto i = osd_epochs.find(osd);
- if (i != osd_epochs.end())
- old_lec = i->second;
stat_osd_sub(osd, o->second);
}
osd_stat_t& r = osd_stat[osd];
::decode(r, p);
stat_osd_add(osd, r);
-
- // epoch?
- epoch_t e;
- ::decode(e, p);
}
void PGMap::remove_osd(int osd)
::encode((float).95, bl);
::encode((float).85, bl);
::encode(stamp, bl);
- ::encode(osd_epochs, bl);
+ {
+ map<int32_t,epoch_t> osd_epochs;
+ ::encode(osd_epochs, bl);
+ }
ENCODE_FINISH(bl);
}
if (struct_v >= 5)
::decode(stamp, bl);
if (struct_v >= 6) {
+ map<int32_t,epoch_t> osd_epochs;
::decode(osd_epochs, bl);
- } else {
- for (auto i = osd_stat.begin();
- i != osd_stat.end();
- ++i) {
- // This isn't accurate, but will cause trimming to behave like
- // previously.
- osd_epochs.insert(make_pair(i->first, last_osdmap_epoch));
- }
}
DECODE_FINISH(bl);
calc_stats();
}
-void PGMap::dirty_all(Incremental& inc)
-{
- inc.osdmap_epoch = last_osdmap_epoch;
- inc.pg_scan = last_pg_scan;
-
- for (auto p = pg_stat.begin(); p != pg_stat.end(); ++p) {
- inc.pg_stat_updates[p->first] = p->second;
- }
- for (auto p = osd_stat.begin(); p != osd_stat.end(); ++p) {
- assert(osd_epochs.count(p->first));
- inc.update_stat(p->first,
- inc.get_osd_epochs().find(p->first)->second,
- p->second);
- }
-}
-
void PGMap::dump(Formatter *f) const
{
dump_basic(f);
osd_sum.dump(f);
f->close_section();
- f->open_array_section("osd_epochs");
- for (auto p = osd_epochs.begin(); p != osd_epochs.end(); ++p) {
- f->open_object_section("osd");
- f->dump_unsigned("osd", p->first);
- f->dump_unsigned("epoch", p->second);
- f->close_section();
- }
- f->close_section();
-
dump_delta(f);
}
for (const auto &p : osd_inc.new_weight) {
if (p.second == CEPH_OSD_OUT) {
dout(10) << __func__ << " osd." << p.first << " went OUT" << dendl;
- auto j = pg_map->osd_epochs.find(p.first);
- if (j != pg_map->osd_epochs.end())
- pending_inc->stat_osd_out(p.first, j->second);
+ pending_inc->stat_osd_out(p.first);
}
}
// clear out osd_stat slow request histogram
dout(20) << __func__ << " clearing osd." << p.first
<< " request histogram" << dendl;
- pending_inc->stat_osd_down_up(p.first, osd_inc.epoch, *pg_map);
+ pending_inc->stat_osd_down_up(p.first, *pg_map);
}
if (p.second & CEPH_OSD_EXISTS) {
} else if (osdmap.is_out(p.first)) {
// zero osd_stat
if (p.second.kb != 0) {
- auto j = pgmap.osd_epochs.find(p.first);
- if (j != pgmap.osd_epochs.end()) {
- pending_inc->stat_osd_out(p.first, j->second);
- }
+ pending_inc->stat_osd_out(p.first);
}
} else if (!osdmap.is_up(p.first)) {
// zero the op_queue_age_hist
if (!p.second.op_queue_age_hist.empty()) {
- pending_inc->stat_osd_down_up(p.first, osdmap.get_epoch(), pgmap);
+ pending_inc->stat_osd_down_up(p.first, pgmap);
}
}
}
mempool::pgmap::unordered_map<int32_t,osd_stat_t> osd_stat;
mempool::pgmap::unordered_map<pg_t,pg_stat_t> pg_stat;
- // mapping of osd to most recently reported osdmap epoch
- mempool::pgmap::unordered_map<int32_t,epoch_t> osd_epochs;
-
class Incremental {
public:
MEMPOOL_CLASS_HELPERS();
private:
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.
- // 1:1 with osd_stat_updates.
- mempool::pgmap::map<int32_t,epoch_t> osd_epochs;
public:
const mempool::pgmap::map<int32_t, osd_stat_t> &get_osd_stat_updates() const {
const mempool::pgmap::set<int32_t> &get_osd_stat_rm() const {
return osd_stat_rm;
}
- const mempool::pgmap::map<int32_t, epoch_t> &get_osd_epochs() const {
- return osd_epochs;
- }
-
template<typename OsdStat>
- void update_stat(int32_t osd, epoch_t epoch, OsdStat&& stat) {
+ void update_stat(int32_t osd, OsdStat&& stat) {
osd_stat_updates[osd] = std::forward<OsdStat>(stat);
- osd_epochs[osd] = epoch;
- assert(osd_epochs.size() == osd_stat_updates.size());
}
- void stat_osd_out(int32_t osd, epoch_t epoch) {
- // 0 the stats for the osd
+ void stat_osd_out(int32_t osd) {
osd_stat_updates[osd] = osd_stat_t();
- // only fill in the epoch if the osd didn't already report htis
- // epoch. that way we zero the stat but still preserve a reported
- // new epoch...
- if (!osd_epochs.count(osd))
- osd_epochs[osd] = epoch;
- // ...and maintain our invariant.
- assert(osd_epochs.size() == osd_stat_updates.size());
}
- void stat_osd_down_up(int32_t osd, epoch_t epoch, const PGMap& pg_map) {
+ void stat_osd_down_up(int32_t osd, const PGMap& pg_map) {
// 0 the op_queue_age_hist for this osd
auto p = osd_stat_updates.find(osd);
if (p != osd_stat_updates.end()) {
if (q != pg_map.osd_stat.end()) {
osd_stat_t& t = osd_stat_updates[osd] = q->second;
t.op_queue_age_hist.clear();
- osd_epochs[osd] = epoch;
}
}
void rm_stat(int32_t osd) {
osd_stat_rm.insert(osd);
- osd_epochs.erase(osd);
osd_stat_updates.erase(osd);
}
void encode(bufferlist &bl, uint64_t features=-1) const;
void encode_digest(const OSDMap& osdmap,
bufferlist& bl, uint64_t features) const;
- void dirty_all(Incremental& inc);
-
int64_t get_rule_avail(const OSDMap& osdmap, int ruleno) const;
void get_rules_avail(const OSDMap& osdmap,
std::map<int,int64_t> *avail_map) const;