diff options
author | Samuel Just <sam.just@inktank.com> | 2013-08-09 17:57:09 -0700 |
---|---|---|
committer | Samuel Just <sam.just@inktank.com> | 2013-10-01 12:35:29 -0700 |
commit | 9bb0ec8d207db6966b080eaf02e56702223f0ec3 (patch) | |
tree | 4a37985527186dc027886fb6e499d853c65af3e6 | |
parent | 399f1d53f7f441992f48aa72139cd628c4ad4f29 (diff) | |
download | ceph-9bb0ec8d207db6966b080eaf02e56702223f0ec3.tar.gz |
PGMap,PGMonitor: osd_stat will be empty for out osd
When an osd is marked out, rather than remove it from osd_stat,
we instead 0 out the structure.
This patch also makes osd_stat_updates and osd_stat_rm private.
This should make it simpler to enforce invariants on these
mappings.
Signed-off-by: Samuel Just <sam.just@inktank.com>
-rw-r--r-- | src/mon/PGMap.cc | 15 | ||||
-rw-r--r-- | src/mon/PGMap.h | 24 | ||||
-rw-r--r-- | src/mon/PGMonitor.cc | 24 |
3 files changed, 46 insertions, 17 deletions
diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index e9a35c6b8ab..9865fe5f2d7 100644 --- a/src/mon/PGMap.cc +++ b/src/mon/PGMap.cc @@ -195,8 +195,10 @@ void PGMap::apply_incremental(CephContext *cct, const Incremental& inc) } stat_pg_add(update_pg, update_stat); } - for (map<int32_t,osd_stat_t>::const_iterator p = inc.osd_stat_updates.begin(); - p != inc.osd_stat_updates.end(); + assert(osd_stat.size() == osd_epochs.size()); + for (map<int32_t,osd_stat_t>::const_iterator p = + inc.get_osd_stat_updates().begin(); + p != inc.get_osd_stat_updates().end(); ++p) { int osd = p->first; const osd_stat_t &new_stats(p->second); @@ -226,8 +228,8 @@ void PGMap::apply_incremental(CephContext *cct, const Incremental& inc) } } - for (set<int>::iterator p = inc.osd_stat_rm.begin(); - p != inc.osd_stat_rm.end(); + for (set<int>::iterator p = inc.get_osd_stat_rm().begin(); + p != inc.get_osd_stat_rm().end(); ++p) { hash_map<int32_t,osd_stat_t>::iterator t = osd_stat.find(*p); if (t != osd_stat.end()) { @@ -488,7 +490,10 @@ void PGMap::dirty_all(Incremental& inc) inc.pg_stat_updates[p->first] = p->second; } for (hash_map<int32_t, osd_stat_t>::const_iterator p = osd_stat.begin(); p != osd_stat.end(); ++p) { - inc.osd_stat_updates[p->first] = p->second; + assert(inc.get_osd_epochs().count(p->first)); + inc.add_stat(p->first, + inc.get_osd_epochs().find(p->first)->second, + p->second); } } diff --git a/src/mon/PGMap.h b/src/mon/PGMap.h index 84d89f87517..99e46d13453 100644 --- a/src/mon/PGMap.h +++ b/src/mon/PGMap.h @@ -47,8 +47,6 @@ public: public: version_t version; map<pg_t,pg_stat_t> pg_stat_updates; - map<int32_t,osd_stat_t> osd_stat_updates; - set<int32_t> osd_stat_rm; epoch_t osdmap_epoch; epoch_t pg_scan; // osdmap epoch set<pg_t> pg_remove; @@ -56,6 +54,28 @@ public: float nearfull_ratio; utime_t stamp; + private: + map<int32_t,osd_stat_t> osd_stat_updates; + set<int32_t> osd_stat_rm; + public: + const map<int32_t, osd_stat_t> &get_osd_stat_updates() const { + return osd_stat_updates; + } + const set<int32_t> &get_osd_stat_rm() const { + return osd_stat_rm; + } + void add_stat(int32_t osd, epoch_t epoch, const osd_stat_t &stat) { + assert(osd_stat_rm.find(osd) == osd_stat_rm.end()); + osd_stat_updates.insert(make_pair(osd, stat)); + void stat_osd_out(int32_t osd) { + // 0 the stats for the osd + osd_stat_updates.erase(osd); + osd_stat_updates[osd]; + } + void rm_stat(int32_t osd) { + osd_stat_rm.insert(osd); + osd_stat_updates.erase(osd); + } void encode(bufferlist &bl, uint64_t features=-1) const; void decode(bufferlist::iterator &bl); void dump(Formatter *f) const; diff --git a/src/mon/PGMonitor.cc b/src/mon/PGMonitor.cc index 0f495052747..ac3974d9b18 100644 --- a/src/mon/PGMonitor.cc +++ b/src/mon/PGMonitor.cc @@ -494,15 +494,19 @@ void PGMonitor::encode_pending(MonitorDBStore::Transaction *t) { bufferlist dirty; string prefix = pgmap_osd_prefix; - for (map<int32_t,osd_stat_t>::const_iterator p = pending_inc.osd_stat_updates.begin(); - p != pending_inc.osd_stat_updates.end(); + for (map<int32_t,osd_stat_t>::const_iterator p = + pending_inc.get_osd_stat_updates().begin(); + p != pending_inc.get_osd_stat_updates().end(); ++p) { ::encode(p->first, dirty); bufferlist bl; ::encode(p->second, bl, features); t->put(prefix, stringify(p->first), bl); } - for (set<int32_t>::const_iterator p = pending_inc.osd_stat_rm.begin(); p != pending_inc.osd_stat_rm.end(); ++p) { + for (set<int32_t>::const_iterator p = + pending_inc.get_osd_stat_rm().begin(); + p != pending_inc.get_osd_stat_rm().end(); + ++p) { ::encode(*p, dirty); t->erase(prefix, stringify(*p)); } @@ -725,7 +729,11 @@ bool PGMonitor::prepare_pg_stats(MPGStats *stats) } // osd stat - pending_inc.osd_stat_updates[from] = stats->osd_stat; + if (mon->osdmon()->osdmap.is_in(from)) { + pending_inc.add_stat(from, stats->epoch, stats->osd_stat); + } else { + pending_inc.add_stat(from, stats->epoch, osd_stat_t()); + } if (pg_map.osd_stat.count(from)) dout(10) << " got osd." << from << " " << stats->osd_stat << " (was " << pg_map.osd_stat[from] << ")" << dendl; @@ -842,11 +850,7 @@ void PGMonitor::check_osd_map(epoch_t epoch) ++p) if (p->second == CEPH_OSD_OUT) { dout(10) << "check_osd_map osd." << p->first << " went OUT" << dendl; - pending_inc.osd_stat_rm.insert(p->first); - } else { - dout(10) << "check_osd_map osd." << p->first << " is IN" << dendl; - pending_inc.osd_stat_rm.erase(p->first); - pending_inc.osd_stat_updates[p->first]; + pending_inc.stat_osd_out(p->first); } // this is conservative: we want to know if any osds (maybe) got marked down. @@ -867,7 +871,7 @@ void PGMonitor::check_osd_map(epoch_t epoch) // whether it was created *or* destroyed, we can safely drop // it's osd_stat_t record. dout(10) << "check_osd_map osd." << p->first << " created or destroyed" << dendl; - pending_inc.osd_stat_rm.insert(p->first); + pending_inc.rm_stat(p->first); // and adjust full, nearfull set pg_map.nearfull_osds.erase(p->first); |