From: Sage Weil Date: Fri, 16 Nov 2018 13:11:15 +0000 (-0600) Subject: Merge PR #25052 into master X-Git-Tag: v14.1.0~902 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9989dddca3d30eac4721e8ae5e357dc055fe4461;p=ceph.git Merge PR #25052 into master * refs/pull/25052/head: mgr: lock pg_map too for osd_pool_stats and notify_osdmap mgr/DaemonServer: use with_osdmap_and_pgmap instead of nested calls mgr/ClusterState: add with_osdmap_and_pgmap Reviewed-by: Kefu Chai --- 9989dddca3d30eac4721e8ae5e357dc055fe4461 diff --cc src/mgr/DaemonServer.cc index cd6c6dd94e26,13ceb8941d04..9d1458f6eab5 --- a/src/mgr/DaemonServer.cc +++ b/src/mgr/DaemonServer.cc @@@ -1298,39 -1290,33 +1290,37 @@@ bool DaemonServer::_handle_command 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()) {