mon/PGMap: allow 'pg ls unknown'

"unknown" is annoying because it is 0 and needs a special case.

Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2018-09-11 13:36:39 -05:00
parent 64a046a078
commit 3ccbec71ae
2 changed files with 7 additions and 3 deletions

View File

@ -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);
}
}
}

View File

@ -968,6 +968,8 @@ boost::optional<uint64_t> 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;