From a2bba6491a3cb8d505a37db469d59d469ad57af6 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 26 Apr 2017 12:38:51 -0400 Subject: [PATCH 1/3] mon/PGMap: inline init for a few fields Signed-off-by: Sage Weil --- src/mon/PGMap.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/mon/PGMap.h b/src/mon/PGMap.h index 506f86d9300c3..c09a5f72dedba 100644 --- a/src/mon/PGMap.h +++ b/src/mon/PGMap.h @@ -117,11 +117,11 @@ class PGMap { // aggregate stats (soft state), generated by calc_stats() ceph::unordered_map num_pg_by_state; - int64_t num_pg, num_osd; + int64_t num_pg = 0, num_osd = 0; ceph::unordered_map pg_pool_sum; pool_stat_t pg_sum; osd_stat_t osd_sum; - mutable epoch_t min_last_epoch_clean; + mutable epoch_t min_last_epoch_clean = 0; ceph::unordered_map blocked_by_sum; ceph::unordered_map > pg_by_osd; @@ -198,10 +198,7 @@ class PGMap { PGMap() : version(0), last_osdmap_epoch(0), last_pg_scan(0), - full_ratio(0), nearfull_ratio(0), - num_pg(0), - num_osd(0), - min_last_epoch_clean(0) + full_ratio(0), nearfull_ratio(0) {} void set_full_ratios(float full, float nearfull) { From 614a8c9ba8f61d05556340803de9654b2287ae84 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 26 Apr 2017 12:43:43 -0400 Subject: [PATCH 2/3] mon/PGMap: track active pgs Signed-off-by: Sage Weil --- src/mon/PGMap.cc | 9 +++++++++ src/mon/PGMap.h | 1 + 2 files changed, 10 insertions(+) diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index 57d95805a5144..015a6ae4c0277 100644 --- a/src/mon/PGMap.cc +++ b/src/mon/PGMap.cc @@ -337,6 +337,7 @@ void PGMap::calc_stats() { num_pg_by_state.clear(); num_pg = 0; + num_pg_active = 0; num_osd = 0; pg_pool_sum.clear(); pg_sum = pool_stat_t(); @@ -457,6 +458,10 @@ void PGMap::stat_pg_add(const pg_t &pgid, const pg_stat_t &s, } } + if (s.state & PG_STATE_ACTIVE) { + ++num_pg_active; + } + if (sameosds) return; @@ -500,6 +505,10 @@ void PGMap::stat_pg_sub(const pg_t &pgid, const pg_stat_t &s, } } + if (s.state & PG_STATE_ACTIVE) { + --num_pg_active; + } + if (sameosds) return; diff --git a/src/mon/PGMap.h b/src/mon/PGMap.h index c09a5f72dedba..5a0479824f71d 100644 --- a/src/mon/PGMap.h +++ b/src/mon/PGMap.h @@ -118,6 +118,7 @@ class PGMap { // aggregate stats (soft state), generated by calc_stats() ceph::unordered_map num_pg_by_state; int64_t num_pg = 0, num_osd = 0; + int64_t num_pg_active = 0; ceph::unordered_map pg_pool_sum; pool_stat_t pg_sum; osd_stat_t osd_sum; From ae2241fb96ca51c84793192835353f2ffb2eb6aa Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 28 Apr 2017 09:35:11 -0400 Subject: [PATCH 3/3] mon/PGMap: include pgs inactive % in summary Signed-off-by: Sage Weil --- src/mon/PGMap.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index 015a6ae4c0277..a135e4a9dd1ab 100644 --- a/src/mon/PGMap.cc +++ b/src/mon/PGMap.cc @@ -1659,6 +1659,18 @@ void PGMap::print_summary(Formatter *f, ostream *out) const << kb_t(osd_sum.kb) << " avail\n"; } + + if (num_pg_active < num_pg) { + float p = (float)num_pg_active / (float)num_pg; + if (f) { + f->dump_float("active_pgs_ratio", p); + } else { + char b[20]; + snprintf(b, sizeof(b), "%.3lf", (1.0 - p) * 100.0); + *out << " " << b << "% pgs inactive\n"; + } + } + list sl; overall_recovery_summary(f, &sl); if (!f && !sl.empty()) {