Signed-off-by: Xiaoxi Chen <xiaoxi.chen@intel.com>
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);
+ }
}
}
}
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;
}