From 3ccbec71ae1e6e923c9c5ae1243f480aeebb6f77 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 11 Sep 2018 13:36:39 -0500 Subject: [PATCH] mon/PGMap: allow 'pg ls unknown' "unknown" is annoying because it is 0 and needs a special case. Signed-off-by: Sage Weil --- src/mon/PGMap.cc | 8 +++++--- src/osd/osd_types.cc | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index dbe79bddc2958..7dd0d1ac6dcbf 100644 --- a/src/mon/PGMap.cc +++ b/src/mon/PGMap.cc @@ -2056,9 +2056,11 @@ void PGMap::get_filtered_pg_stats(uint64_t state, int64_t poolid, int64_t osdid, continue; if ((osdid >= 0) && !(i->second.is_acting_osd(osdid,primary))) continue; - if (state != (uint64_t)-1 && !(i->second.state & state)) - continue; - pgs.insert(i->first); + if (state == (uint64_t)-1 || // "all" + (i->second.state & state) || // matches a state bit + (state == 0 && i->second.state == 0)) { // matches "unknown" (== 0) + pgs.insert(i->first); + } } } diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 37ed56cd382e4..2d0e86e55bde8 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -968,6 +968,8 @@ boost::optional pg_string_state(const std::string& state) type = PG_STATE_SNAPTRIM_WAIT; else if (state == "snaptrim_error") type = PG_STATE_SNAPTRIM_ERROR; + else if (state == "unknown") + type = 0; else type = boost::none; return type; -- 2.39.5