]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Fix some style and checking issue 2152/head
authorXiaoxi Chen <xiaoxi.chen@intel.com>
Mon, 28 Jul 2014 16:42:10 +0000 (00:42 +0800)
committerXiaoxi Chen <xiaoxi.chen@intel.com>
Mon, 28 Jul 2014 16:42:10 +0000 (00:42 +0800)
Signed-off-by: Xiaoxi Chen <xiaoxi.chen@intel.com>
src/crush/CrushWrapper.cc
src/mon/PGMonitor.cc

index 2e33598569ca4f5edb592be9a0203124d6794d2a..ca7a47e7f139aeb5aad5c58efc60d58deb9ba3d4 100644 (file)
@@ -849,14 +849,13 @@ int CrushWrapper::get_rule_weight_osd_map(unsigned ruleno, map<int,float> *pmap)
          assert(b);
          for (unsigned j=0; j<b->size; ++j) {
            int item_id = b->items[j];
-           if (item_id >= 0) //it's an OSD
-           {
+           if (item_id >= 0) { //it's an OSD
              float w = crush_get_bucket_item_weight(b, j);
              m[item_id] = w;
              sum += w;
-           }
-           else //not an OSD, expand the child later
+           } else { //not an OSD, expand the child later
              q.push_back(item_id);
+           }
          }
        }
       }
index 9757af5f386aee9eb0db12fd7210d222623ce74e..05a0f17dceecd2d6deb518c4f473e0ae43b5e4e9 100644 (file)
@@ -1259,10 +1259,15 @@ int64_t PGMonitor::get_rule_avail(OSDMap& osdmap, int ruleno)
     return 0;
   int64_t min = -1;
   for (map<int,float>::iterator p = wm.begin(); p != wm.end(); ++p) {
-    int64_t proj = (float)(pg_map.osd_stat[p->first].kb_avail * 1024ull) /
-      (double)p->second;
-    if (min < 0 || proj < min)
-      min = proj;
+    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()) {
+      int64_t proj = (float)((osd_info->second).kb_avail * 1024ull) /
+        (double)p->second;
+      if (min < 0 || proj < min)
+        min = proj;
+    } else {
+      dout(0) << "Cannot get stat of OSD " << p->first << dendl;
+    }
   }
   return min;
 }