]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/OSDMap: fix potential divided-by-zero error
authorxie xingguo <xie.xingguo@zte.com.cn>
Mon, 10 Jul 2017 10:38:19 +0000 (18:38 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Mon, 10 Jul 2017 18:14:07 +0000 (02:14 +0800)
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/osd/OSDMap.cc

index f6590080258ca2a063dc7a741a6ca28dab45b7c4..421f32d7f8219d1a564d4e1e8ec468b18b464ba5 100644 (file)
@@ -3789,6 +3789,10 @@ int OSDMap::calc_pg_upmaps(
                     << " pgs " << pgs << dendl;
     }
 
+    if (osd_weight_total == 0) {
+      lderr(cct) << __func__ << " abort due to osd_weight_total == 0" << dendl;
+      break;
+    }
     float pgs_per_weight = total_pgs / osd_weight_total;
     ldout(cct, 10) << " osd_weight_total " << osd_weight_total << dendl;
     ldout(cct, 10) << " pgs_per_weight " << pgs_per_weight << dendl;
@@ -3838,6 +3842,7 @@ int OSDMap::calc_pg_upmaps(
       int osd = p->second;
       float deviation = p->first;
       float target = osd_weight[osd] * pgs_per_weight;
+      assert(target > 0);
       if (deviation/target < max_deviation_ratio) {
        ldout(cct, 10) << " osd." << osd
                       << " target " << target