From: Xiaoxi Chen Date: Mon, 28 Jul 2014 16:42:10 +0000 (+0800) Subject: Fix some style and checking issue X-Git-Tag: v0.84~52^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9b037522039fe32355ae49dd2aa2460d17e103cb;p=ceph.git Fix some style and checking issue Signed-off-by: Xiaoxi Chen --- diff --git a/src/crush/CrushWrapper.cc b/src/crush/CrushWrapper.cc index 2e33598569c..ca7a47e7f13 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 9757af5f386..05a0f17dcee 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; }