]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/OSDMap: potential access violation fix
authorxie xingguo <xie.xingguo@zte.com.cn>
Sat, 12 Jan 2019 07:01:54 +0000 (15:01 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Fri, 25 Jan 2019 03:14:56 +0000 (11:14 +0800)
Seems we'll continue to access the iterator after it is invalidated
by the __erase__ method.
Also this is more efficient considering there could be some extreme
ec-pool (e.g., 8 + 2) consumers..

Fixes: http://tracker.ceph.com/issues/37881
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
(cherry picked from commit df2e01f496dbc2b38800b1792082c540094d7b02)

src/osd/OSDMap.cc

index 37740efc658a8cdf87f62904d5c99a835453758e..63f830ae2825cf3e80d486e93e12df917d8d37d5 100644 (file)
@@ -4178,17 +4178,17 @@ int OSDMap::calc_pg_upmaps(
 
     map<int,float> pmap;
     int ruleno = tmp.crush->find_rule(i.second.get_crush_rule(),
-                                       i.second.get_type(),
-                                       i.second.get_size());
+                                     i.second.get_type(),
+                                     i.second.get_size());
     tmp.crush->get_rule_weight_osd_map(ruleno, &pmap);
     ldout(cct,30) << __func__ << " pool " << i.first << " ruleno " << ruleno << dendl;
     for (auto p : pmap) {
-       auto adjusted_weight = tmp.get_weightf(p.first) * p.second;
+      auto adjusted_weight = tmp.get_weightf(p.first) * p.second;
       if (adjusted_weight == 0) {
         continue;
       }
-       osd_weight[p.first] += adjusted_weight;
-       osd_weight_total += adjusted_weight;
+      osd_weight[p.first] += adjusted_weight;
+      osd_weight_total += adjusted_weight;
     }
   }
   for (auto& i : osd_weight) {
@@ -4289,6 +4289,7 @@ int OSDMap::calc_pg_upmaps(
              pending_inc->old_pg_upmap_items.insert(pg);
              ++num_changed;
              restart = true;
+              break;
            }
          }
        }