From 95ec68505ce4a26ea707716791cfb1e46a75ed25 Mon Sep 17 00:00:00 2001 From: Joao Eduardo Luis Date: Fri, 16 Jan 2015 18:13:05 +0000 Subject: [PATCH] mon: PGMonitor: available size 0 if no osds on pool's ruleset get_rule_avail() may return < 0, which we were using blindly assuming it would always return an unsigned value. We would end up with weird values if the ruleset had no osds. Signed-off-by: Joao Eduardo Luis (cherry picked from commit 8be6a6ab2aa5a000a39c73a98b11a0ab32fffa1c) --- src/mon/PGMonitor.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mon/PGMonitor.cc b/src/mon/PGMonitor.cc index d8d64c54814ae..34883e1f47a2a 100644 --- a/src/mon/PGMonitor.cc +++ b/src/mon/PGMonitor.cc @@ -1321,9 +1321,11 @@ void PGMonitor::dump_pool_stats(stringstream &ss, Formatter *f, bool verbose) int ruleno = osdmap.crush->find_rule(pool->get_crush_ruleset(), pool->get_type(), pool->get_size()); - uint64_t avail; + int64_t avail; if (avail_by_rule.count(ruleno) == 0) { avail = get_rule_avail(osdmap, ruleno); + if (avail < 0) + avail = 0; avail_by_rule[ruleno] = avail; } else { avail = avail_by_rule[ruleno]; -- 2.39.5