ceph_assert(!(to_unmap.size() || to_upmap.size()));
ldout(cct, 10) << " failed to find any changes for overfull osds"
<< dendl;
- for (auto& [deviation, osd] : deviation_osd) {
- if (std::find(underfull.begin(), underfull.end(), osd) ==
- underfull.end())
- break;
- float target = osd_weight[osd] * pgs_per_weight;
- ceph_assert(target > 0);
- if (fabsf(deviation) < max_deviation) {
- // respect max_deviation too
- ldout(cct, 10) << " osd." << osd
- << " target " << target
- << " deviation " << deviation
- << " -> absolute " << fabsf(deviation)
- << " < max " << max_deviation
- << dendl;
- break;
- }
- // look for remaps we can un-remap
- candidates_t candidates = build_candidates(cct, tmp_osd_map, to_skip,
- only_pools, aggressive, p_seed);
- if (try_drop_remap_underfull(cct, candidates, osd, temp_pgs_by_osd,
- to_unmap, to_upmap)) {
- goto test_change;
+ {
+ const auto candidates_by_osd = build_candidates_by_osd(
+ cct, tmp_osd_map, to_skip, only_pools, aggressive, p_seed);
+ for (auto& [deviation, osd] : deviation_osd) {
+ if (std::find(underfull.begin(), underfull.end(), osd) ==
+ underfull.end())
+ break;
+ float target = osd_weight[osd] * pgs_per_weight;
+ ceph_assert(target > 0);
+ if (fabsf(deviation) < max_deviation) {
+ // respect max_deviation too
+ ldout(cct, 10) << " osd." << osd
+ << " target " << target
+ << " deviation " << deviation
+ << " -> absolute " << fabsf(deviation)
+ << " < max " << max_deviation
+ << dendl;
+ break;
+ }
+ // look for remaps we can un-remap
+ auto candidates = candidates_by_osd.find(osd);
+ if (candidates != candidates_by_osd.end() &&
+ try_drop_remap_underfull(cct, candidates->second, osd,
+ temp_pgs_by_osd, to_unmap, to_upmap)) {
+ goto test_change;
+ }
}
}
return best_pos;
}
-OSDMap::candidates_t OSDMap::build_candidates(
+OSDMap::candidates_by_osd_t OSDMap::build_candidates_by_osd(
CephContext *cct,
const OSDMap& tmp_osd_map,
const set<pg_t> to_skip,
// shuffle candidates so they all get equal (in)attention
std::shuffle(candidates.begin(), candidates.end(), get_random_engine(cct, p_seed));
}
- return candidates;
+ candidates_by_osd_t candidates_by_osd;
+ for (auto& candidate : candidates) {
+ for (auto& mapping : candidate.second) {
+ candidates_by_osd[mapping.first].push_back(candidate);
+ }
+ }
+ return candidates_by_osd;
}
// return -1 if all PGs are OK, else the first PG which includes only zero PA OSDs