From: David Zafman Date: Thu, 18 Apr 2019 00:11:02 +0000 (-0700) Subject: mon, mgr: Improve PG count by changing up to up_no_acting in pg_count X-Git-Tag: v14.2.2~192^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3945264337d039b20a3e2fd60437ab521414b925;p=ceph.git mon, mgr: Improve PG count by changing up to up_no_acting in pg_count By not adding a field to pg_count, we don't have to worry about versioning or backwards compatibility. A mixed cluster won't be any worse than before. Signed-off-by: David Zafman (cherry picked from commit 69eaaaadd00f190f3013abbf8c713b47c0b3e7bc) --- diff --git a/src/mgr/DaemonServer.cc b/src/mgr/DaemonServer.cc index e9a868f0abc4..4b9ee4b301ff 100644 --- a/src/mgr/DaemonServer.cc +++ b/src/mgr/DaemonServer.cc @@ -1383,9 +1383,10 @@ bool DaemonServer::_handle_command( } auto q = pg_map.num_pg_by_osd.find(osd); if (q != pg_map.num_pg_by_osd.end()) { - if (q->second.acting > 0 || q->second.up > 0) { + if (q->second.acting > 0 || q->second.up_not_acting > 0) { active_osds.insert(osd); - affected_pgs += q->second.acting + q->second.up; + // XXX: For overlapping PGs, this counts them again + affected_pgs += q->second.acting + q->second.up_not_acting; continue; } } @@ -1437,7 +1438,6 @@ bool DaemonServer::_handle_command( if (!r) { ss << "OSD(s) " << osds << " are safe to destroy without reducing data" << " durability."; - safe_to_destroy.swap(osds); } if (f) { f->open_object_section("osd_status"); diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index 78731fd70791..b970eac9ef6b 100644 --- a/src/mon/PGMap.cc +++ b/src/mon/PGMap.cc @@ -159,7 +159,7 @@ void PGMapDigest::dump(Formatter *f) const f->dump_unsigned("osd", p.first); f->dump_unsigned("num_primary_pg", p.second.primary); f->dump_unsigned("num_acting_pg", p.second.acting); - f->dump_unsigned("num_up_pg", p.second.up); + f->dump_unsigned("num_up_not_acting_pg", p.second.up_not_acting); f->close_section(); } f->close_section(); @@ -1296,8 +1296,11 @@ void PGMap::stat_pg_add(const pg_t &pgid, const pg_stat_t &s, num_pg_by_osd[*p].acting++; } for (auto p = s.up.begin(); p != s.up.end(); ++p) { - pg_by_osd[*p].insert(pgid); - num_pg_by_osd[*p].up++; + auto& t = pg_by_osd[*p]; + if (t.find(pgid) == t.end()) { + t.insert(pgid); + num_pg_by_osd[*p].up_not_acting++; + } } if (s.up_primary >= 0) { @@ -1357,7 +1360,9 @@ bool PGMap::stat_pg_sub(const pg_t &pgid, const pg_stat_t &s, blocked_by_sum.erase(q); } + set actingset; for (auto p = s.acting.begin(); p != s.acting.end(); ++p) { + actingset.insert(*p); auto& oset = pg_by_osd[*p]; oset.erase(pgid); if (oset.empty()) @@ -1371,9 +1376,11 @@ bool PGMap::stat_pg_sub(const pg_t &pgid, const pg_stat_t &s, oset.erase(pgid); if (oset.empty()) pg_by_osd.erase(*p); + if (actingset.count(*p)) + continue; auto it = num_pg_by_osd.find(*p); - if (it != num_pg_by_osd.end() && it->second.up > 0) - it->second.up--; + if (it != num_pg_by_osd.end() && it->second.up_not_acting > 0) + it->second.up_not_acting--; } if (s.up_primary >= 0) { diff --git a/src/mon/PGMap.h b/src/mon/PGMap.h index fdc7cb87f656..550560064eac 100644 --- a/src/mon/PGMap.h +++ b/src/mon/PGMap.h @@ -52,18 +52,18 @@ public: mempool::pgmap::unordered_map num_pg_by_state; struct pg_count { int32_t acting = 0; - int32_t up = 0; + int32_t up_not_acting = 0; int32_t primary = 0; void encode(bufferlist& bl) const { using ceph::encode; encode(acting, bl); - encode(up, bl); + encode(up_not_acting, bl); encode(primary, bl); } void decode(bufferlist::const_iterator& p) { using ceph::decode; decode(acting, p); - decode(up, p); + decode(up_not_acting, p); decode(primary, p); } };