]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/PGMonitor: MAX AVAIL is 0 if some OSDs' weight is 0 6660/head
authorChengyuan Li <chengyli@ebay.com>
Fri, 20 Nov 2015 05:29:39 +0000 (22:29 -0700)
committerChengyuan Li <chengyli@ebay.com>
Fri, 20 Nov 2015 09:26:58 +0000 (02:26 -0700)
In get_rule_avail(), even p->second is 0, it's possible to be used
as divisor and quotient is infinity, then is converted to an integer
which is negative value.
So we should check p->second value before calculation.

It fixes BUG #13840.

Signed-off-by: Chengyuan Li <chengyli@ebay.com>
src/mon/PGMonitor.cc

index 77a5af150fb14911389528f1dba821d1fc7bfa1b..84688b176cdec77a3358f3184e052e2200b9f0a6 100644 (file)
@@ -1301,9 +1301,12 @@ int64_t PGMonitor::get_rule_avail(OSDMap& osdmap, int ruleno) const
   for (map<int,float>::iterator p = wm.begin(); p != wm.end(); ++p) {
     ceph::unordered_map<int32_t,osd_stat_t>::const_iterator osd_info = pg_map.osd_stat.find(p->first);
     if (osd_info != pg_map.osd_stat.end()) {
-      if (osd_info->second.kb == 0) {
+      if (osd_info->second.kb == 0 || p->second == 0) {
         // osd must be out, hence its stats have been zeroed
         // (unless we somehow managed to have a disk with size 0...)
+        //
+        // (p->second == 0), if osd weight is 0, no need to
+        // calculate proj below.
         continue;
       }
       int64_t proj = (float)((osd_info->second).kb_avail * 1024ull) /