]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: PGMonitor: available size 0 if no osds on pool's ruleset
authorJoao Eduardo Luis <joao@redhat.com>
Fri, 16 Jan 2015 18:13:05 +0000 (18:13 +0000)
committerLoic Dachary <ldachary@redhat.com>
Fri, 27 Feb 2015 17:28:59 +0000 (18:28 +0100)
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 <joao@redhat.com>
(cherry picked from commit 8be6a6ab2aa5a000a39c73a98b11a0ab32fffa1c)

src/mon/PGMonitor.cc

index 159fd9b4e590e35d98af5ed9cd06e4f95287a175..9a4aee36ae20c16d80acdaa94c63d4fb90f52600 100644 (file)
@@ -1302,9 +1302,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];