From: Sage Weil Date: Tue, 23 May 2017 20:35:30 +0000 (-0400) Subject: mon/PGMap: count 'unknown' pgs X-Git-Tag: ses5-milestone6~8^2~19^2~24 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=2f881dbf2c81d73e531d64741acf1a0f9b5b19a5;p=ceph.git mon/PGMap: count 'unknown' pgs Also, count "not active" (inactive) pgs instead of active so that we list "bad" things consistently, and so that 'inactive' is a separate bucket of pgs than the 'unknown' ones. Signed-off-by: Sage Weil --- diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index 018a31255df7b..ab3a639033feb 100644 --- a/src/mon/PGMap.cc +++ b/src/mon/PGMap.cc @@ -25,7 +25,7 @@ MEMPOOL_DEFINE_OBJECT_FACTORY(PGMap::Incremental, pgmap_inc, pgmap); void PGMapDigest::encode(bufferlist& bl, uint64_t features) const { // NOTE: see PGMap::encode_digest - ENCODE_START(4, 1, bl); + ENCODE_START(5, 1, bl); ::encode(num_pg, bl); ::encode(num_pg_active, bl); ::encode(num_osd, bl); @@ -41,12 +41,13 @@ void PGMapDigest::encode(bufferlist& bl, uint64_t features) const ::encode(per_pool_sum_deltas_stamps, bl); ::encode(pg_sum_delta, bl, features); ::encode(stamp_delta, bl); + ::encode(num_pg_unknown, bl); ENCODE_FINISH(bl); } void PGMapDigest::decode(bufferlist::iterator& p) { - DECODE_START(4, p); + DECODE_START(5, p); ::decode(num_pg, p); ::decode(num_pg_active, p); ::decode(num_osd, p); @@ -76,6 +77,9 @@ void PGMapDigest::decode(bufferlist::iterator& p) ::decode(pg_sum_delta, p); ::decode(stamp_delta, p); } + if (struct_v >= 5) { + ::decode(num_pg_unknown, p); + } DECODE_FINISH(p); } @@ -83,6 +87,7 @@ void PGMapDigest::dump(Formatter *f) const { f->dump_unsigned("num_pg", num_pg); f->dump_unsigned("num_pg_active", num_pg_active); + f->dump_unsigned("num_pg_unknown", num_pg_unknown); f->dump_unsigned("num_osd", num_osd); f->dump_object("pool_sum", pg_sum); f->dump_object("osd_sum", osd_sum); @@ -187,14 +192,31 @@ void PGMapDigest::print_summary(Formatter *f, ostream *out) const } bool pad = false; - if (num_pg_active < num_pg) { - float p = (float)num_pg_active / (float)num_pg; + + if (num_pg_unknown > 0) { + float p = (float)num_pg_unknown / (float)num_pg; + if (f) { + f->dump_float("unknown_pgs_ratio", p); + } else { + char b[20]; + snprintf(b, sizeof(b), "%.3lf", p * 100.0); + *out << b << "% pgs unknown\n"; + pad = true; + } + } + + int num_pg_inactive = num_pg - num_pg_active - num_pg_unknown; + if (num_pg_inactive > 0) { + float p = (float)num_pg_inactive / (float)num_pg; if (f) { - f->dump_float("active_pgs_ratio", p); + f->dump_float("inactive_pgs_ratio", p); } else { + if (pad) { + *out << " "; + } char b[20]; - snprintf(b, sizeof(b), "%.3f", (1.0 - p) * 100.0); - *out << b << "% pgs inactive\n"; + snprintf(b, sizeof(b), "%.3f", p * 100.0); + *out << b << "% pgs not active\n"; pad = true; } } @@ -1175,6 +1197,7 @@ void PGMap::calc_stats() { num_pg = 0; num_pg_active = 0; + num_pg_unknown = 0; num_osd = 0; pg_pool_sum.clear(); num_pg_by_pool.clear(); @@ -1302,6 +1325,9 @@ void PGMap::stat_pg_add(const pg_t &pgid, const pg_stat_t &s, if (s.state & PG_STATE_ACTIVE) { ++num_pg_active; } + if (s.state == 0) { + ++num_pg_unknown; + } if (sameosds) return; @@ -1360,6 +1386,9 @@ void PGMap::stat_pg_sub(const pg_t &pgid, const pg_stat_t &s, if (s.state & PG_STATE_ACTIVE) { --num_pg_active; } + if (s.state == 0) { + --num_pg_unknown; + } if (sameosds) return; diff --git a/src/mon/PGMap.h b/src/mon/PGMap.h index 01f78062bc59a..a33bfe6bd5351 100644 --- a/src/mon/PGMap.h +++ b/src/mon/PGMap.h @@ -44,6 +44,7 @@ public: // aggregate state, populated by PGMap child int64_t num_pg = 0, num_osd = 0; int64_t num_pg_active = 0; + int64_t num_pg_unknown = 0; mempool::pgmap::unordered_map pg_pool_sum; mempool::pgmap::map num_pg_by_pool; pool_stat_t pg_sum;