Skip to content

Commit a954f89

Browse files
authored
Merge pull request #66204 from apataki/73795-cephmon-cleanupmap
ceph-mon: Improve efficiency of upmap cleanup in osdmaps for large clusters Reviewed-by: Radoslaw Zarzynski <rzarzyns@redhat.com> Reviewed-by: Laura Flores <lflores@redhat.com>
2 parents bf2cacd + c9cf2e7 commit a954f89

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

src/osd/OSDMap.cc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2146,20 +2146,19 @@ bool OSDMap::check_pg_upmaps(
21462146
continue;
21472147
}
21482148
// below we check against crush-topology changing..
2149-
map<int, float> weight_map;
2150-
auto it = rule_weight_map.find(crush_rule);
2151-
if (it == rule_weight_map.end()) {
2152-
auto r = crush->get_rule_weight_osd_map(crush_rule, &weight_map);
2149+
auto rule_entry = rule_weight_map.find(crush_rule);
2150+
if (rule_entry == rule_weight_map.end()) {
2151+
rule_entry = rule_weight_map.emplace(crush_rule, map<int, float>()).first;
2152+
auto r = crush->get_rule_weight_osd_map(crush_rule, &rule_entry->second);
21532153
if (r < 0) {
21542154
lderr(cct) << __func__ << " unable to get crush weight_map for "
21552155
<< "crush_rule " << crush_rule
21562156
<< dendl;
2157+
rule_weight_map.erase(rule_entry);
21572158
continue;
21582159
}
2159-
rule_weight_map[crush_rule] = weight_map;
2160-
} else {
2161-
weight_map = it->second;
21622160
}
2161+
const map<int, float> &weight_map = rule_entry->second;
21632162
ldout(cct, 10) << __func__ << " pg " << pg
21642163
<< " weight_map " << weight_map
21652164
<< dendl;

0 commit comments

Comments
 (0)