]> 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>
Tue, 17 Mar 2015 09:55:40 +0000 (10:55 +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 d8d64c54814ae866cf051e5312e1f76f1df4e6db..34883e1f47a2a47c6eab5a28562b5aaa86a98b4c 100644 (file)
@@ -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];