From 9b037522039fe32355ae49dd2aa2460d17e103cb Mon Sep 17 00:00:00 2001 From: Xiaoxi Chen Date: Tue, 29 Jul 2014 00:42:10 +0800 Subject: [PATCH] Fix some style and checking issue Signed-off-by: Xiaoxi Chen --- src/crush/CrushWrapper.cc | 7 +++---- src/mon/PGMonitor.cc | 13 +++++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/crush/CrushWrapper.cc b/src/crush/CrushWrapper.cc index 2e33598569ca4..ca7a47e7f139a 100644 --- a/src/crush/CrushWrapper.cc +++ b/src/crush/CrushWrapper.cc @@ -849,14 +849,13 @@ int CrushWrapper::get_rule_weight_osd_map(unsigned ruleno, map *pmap) assert(b); for (unsigned j=0; jsize; ++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); + } } } } diff --git a/src/mon/PGMonitor.cc b/src/mon/PGMonitor.cc index 9757af5f386ae..05a0f17dceecd 100644 --- a/src/mon/PGMonitor.cc +++ b/src/mon/PGMonitor.cc @@ -1259,10 +1259,15 @@ int64_t PGMonitor::get_rule_avail(OSDMap& osdmap, int ruleno) return 0; int64_t min = -1; for (map::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::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; } -- 2.39.5