num_active_clean += p.second;
}
}
- cluster_state.with_osdmap([&](const OSDMap& osdmap) {
- for (auto osd : osds) {
- if (!osdmap.exists(osd)) {
- safe_to_destroy.insert(osd);
- continue; // clearly safe to destroy
- }
- auto q = pg_map.num_pg_by_osd.find(osd);
- if (q != pg_map.num_pg_by_osd.end()) {
- if (q->second.acting > 0 || q->second.up > 0) {
- active_osds.insert(osd);
- affected_pgs += q->second.acting + q->second.up;
- continue;
- }
- }
- if (num_active_clean < pg_map.num_pg) {
- // all pgs aren't active+clean; we need to be careful.
- auto p = pg_map.osd_stat.find(osd);
- if (p == pg_map.osd_stat.end()) {
- missing_stats.insert(osd);
- continue;
- } else if (p->second.num_pgs > 0) {
- stored_pgs.insert(osd);
- continue;
- }
- }
- safe_to_destroy.insert(osd);
+ for (auto osd : osds) {
+ if (!osdmap.exists(osd)) {
+ safe_to_destroy.insert(osd);
+ continue; // clearly safe to destroy
+ }
+ auto q = pg_map.num_pg_by_osd.find(osd);
+ if (q != pg_map.num_pg_by_osd.end()) {
+ if (q->second.acting > 0 || q->second.up > 0) {
+ active_osds.insert(osd);
+ affected_pgs += q->second.acting + q->second.up;
+ continue;
}
- });
+ }
+ if (num_active_clean < pg_map.num_pg) {
+ // all pgs aren't active+clean; we need to be careful.
+ auto p = pg_map.osd_stat.find(osd);
+ if (p == pg_map.osd_stat.end()) {
+ missing_stats.insert(osd);
+ continue;
+ } else if (p->second.num_pgs > 0) {
+ stored_pgs.insert(osd);
+ continue;
+ }
+ }
+ safe_to_destroy.insert(osd);
+ }
});
+ if (r && prefix == "osd safe-to-destroy") {
+ cmdctx->reply(r, ss); // regardless of formatter
+ return true;
+ }
if (!r && (!active_osds.empty() ||
!missing_stats.empty() || !stored_pgs.empty())) {
if (!safe_to_destroy.empty()) {