From 996c9261c5748ec7d54a172053c4303c2149f13d Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Thu, 30 Jan 2025 17:05:25 -0500 Subject: [PATCH] mgr: use std namespace This C++ code was relying on the Client.h header to bring in these names from the std:: namespace. A subsequent commit plans to remove that header so add namespace qualifier now. Signed-off-by: Patrick Donnelly (cherry picked from commit 706b2be416246dd5923478d8a7ee015246f03e95) Conflicts: src/mgr/DaemonServer.h: no header cleanup --- src/mgr/ActivePyModules.cc | 8 ++-- src/mgr/ActivePyModules.h | 6 ++- src/mgr/DaemonServer.cc | 89 ++++++++++++++++++++------------------ src/mgr/DaemonServer.h | 12 ++--- src/mgr/Mgr.cc | 12 ++--- src/mgr/PyModuleRegistry.h | 15 ++++--- 6 files changed, 77 insertions(+), 65 deletions(-) diff --git a/src/mgr/ActivePyModules.cc b/src/mgr/ActivePyModules.cc index 17bb3951142ab..c7a8e8054834b 100644 --- a/src/mgr/ActivePyModules.cc +++ b/src/mgr/ActivePyModules.cc @@ -245,7 +245,7 @@ PyObject *ActivePyModules::get_python(const std::string &what) } else if (what == "modified_config_options") { without_gil_t no_gil; auto all_daemons = daemon_state.get_all(); - set names; + std::set names; for (auto& [key, daemon] : all_daemons) { std::lock_guard l(daemon->lock); for (auto& [name, valmap] : daemon->config) { @@ -782,7 +782,7 @@ std::map ActivePyModules::get_services() const void ActivePyModules::update_kv_data( const std::string prefix, bool incremental, - const map, std::less<>>& data) + const std::map, std::less<>>& data) { std::lock_guard l(lock); bool do_config = false; @@ -1118,7 +1118,7 @@ PyObject *ActivePyModules::get_foreign_config( std::map> config; cluster_state.with_osdmap([&](const OSDMap &osdmap) { - map crush_location; + std::map crush_location; string device_class; if (entity.is_osd()) { osdmap.crush->get_full_location(who, &crush_location); @@ -1277,7 +1277,7 @@ void ActivePyModules::set_device_wear_level(const std::string& devid, float wear_level) { // update mgr state - map meta; + std::map meta; daemon_state.with_device( devid, [wear_level, &meta] (DeviceState& dev) { diff --git a/src/mgr/ActivePyModules.h b/src/mgr/ActivePyModules.h index d6ade4849f78a..c48a06ce95e4d 100644 --- a/src/mgr/ActivePyModules.h +++ b/src/mgr/ActivePyModules.h @@ -33,6 +33,10 @@ #include "ClusterState.h" #include "OSDPerfMetricTypes.h" +#include +#include +#include + class health_check_map_t; class DaemonServer; class MgrSession; @@ -179,7 +183,7 @@ public: void update_kv_data( const std::string prefix, bool incremental, - const map, std::less<>>& data); + const std::map, std::less<>>& data); void _refresh_config_map(); // Public so that MonCommandCompletion can use it diff --git a/src/mgr/DaemonServer.cc b/src/mgr/DaemonServer.cc index cb0a2e36deb37..60c0637d551a0 100644 --- a/src/mgr/DaemonServer.cc +++ b/src/mgr/DaemonServer.cc @@ -42,6 +42,11 @@ #include "common/errno.h" #include "common/pick_address.h" +#include +#include +#include +#include + #define dout_context g_ceph_context #define dout_subsys ceph_subsys_mgr #undef dout_prefix @@ -806,14 +811,14 @@ bool DaemonServer::handle_report(const ref_t& m) void DaemonServer::_generate_command_map( cmdmap_t& cmdmap, - map ¶m_str_map) + std::map ¶m_str_map) { for (auto p = cmdmap.begin(); p != cmdmap.end(); ++p) { if (p->first == "prefix") continue; if (p->first == "caps") { - vector cv; + std::vector cv; if (cmd_getval(cmdmap, "caps", cv) && cv.size() % 2 == 0) { for (unsigned i = 0; i < cv.size(); i += 2) { @@ -847,7 +852,7 @@ bool DaemonServer::_allowed_command( const string &module, const string &prefix, const cmdmap_t& cmdmap, - const map& param_str_map, + const std::map& param_str_map, const MonCommand *this_cmd) { if (s->entity_name.is_mon()) { @@ -994,7 +999,7 @@ void DaemonServer::log_access_denied( } void DaemonServer::_check_offlines_pgs( - const set& osds, + const std::set& osds, const OSDMap& osdmap, const PGMap& pgmap, offline_pg_report *report) @@ -1004,7 +1009,7 @@ void DaemonServer::_check_offlines_pgs( report->osds = osds; for (const auto& q : pgmap.pg_stat) { - set pg_acting; // net acting sets (with no missing if degraded) + std::set pg_acting; // net acting sets (with no missing if degraded) bool found = false; if (q.second.state == 0) { report->unknown.insert(q.first); @@ -1066,7 +1071,7 @@ void DaemonServer::_check_offlines_pgs( } void DaemonServer::_maximize_ok_to_stop_set( - const set& orig_osds, + const std::set& orig_osds, unsigned max, const OSDMap& osdmap, const PGMap& pgmap, @@ -1084,9 +1089,9 @@ void DaemonServer::_maximize_ok_to_stop_set( // semi-arbitrarily start with the first osd in the set offline_pg_report report; - set osds = orig_osds; + std::set osds = orig_osds; int parent = *osds.begin(); - set children; + std::set children; while (true) { // identify the next parent @@ -1152,7 +1157,7 @@ bool DaemonServer::_handle_command( session->inst.name = m->get_source(); } - map param_str_map; + std::map param_str_map; std::stringstream ss; int r = 0; @@ -1367,7 +1372,7 @@ bool DaemonServer::_handle_command( } for (auto& con : p->second) { assert(HAVE_FEATURE(con->get_features(), SERVER_OCTOPUS)); - vector pgs = { spgid }; + std::vector pgs = { spgid }; con->send_message(new MOSDScrub2(monc->get_fsid(), epoch, pgs, @@ -1383,10 +1388,10 @@ bool DaemonServer::_handle_command( prefix == "osd repair") { string whostr; cmd_getval(cmdctx->cmdmap, "who", whostr); - vector pvec; + std::vector pvec; get_str_vec(prefix, pvec); - set osds; + std::set osds; if (whostr == "*" || whostr == "all" || whostr == "any") { cluster_state.with_osdmap([&](const OSDMap& osdmap) { for (int i = 0; i < osdmap.get_max_osd(); i++) @@ -1412,9 +1417,9 @@ bool DaemonServer::_handle_command( return true; } } - set sent_osds, failed_osds; + std::set sent_osds, failed_osds; for (auto osd : osds) { - vector spgs; + std::vector spgs; epoch_t epoch; cluster_state.with_osdmap_and_pgmap([&](const OSDMap& osdmap, const PGMap& pgmap) { epoch = osdmap.get_epoch(); @@ -1460,7 +1465,7 @@ bool DaemonServer::_handle_command( } else if (prefix == "osd pool scrub" || prefix == "osd pool deep-scrub" || prefix == "osd pool repair") { - vector pool_names; + std::vector pool_names; cmd_getval(cmdctx->cmdmap, "who", pool_names); if (pool_names.empty()) { ss << "must specify one or more pool names"; @@ -1468,8 +1473,8 @@ bool DaemonServer::_handle_command( return true; } epoch_t epoch; - map> pgs_by_primary; // legacy - map> spgs_by_primary; + std::map> pgs_by_primary; // legacy + std::map> spgs_by_primary; cluster_state.with_osdmap([&](const OSDMap& osdmap) { epoch = osdmap.get_epoch(); for (auto& pool_name : pool_names) { @@ -1524,8 +1529,8 @@ bool DaemonServer::_handle_command( prefix == "osd test-reweight-by-pg" || prefix == "osd test-reweight-by-utilization"; int64_t oload = cmd_getval_or(cmdctx->cmdmap, "oload", 120); - set pools; - vector poolnames; + std::set pools; + std::vector poolnames; cmd_getval(cmdctx->cmdmap, "pools", poolnames); cluster_state.with_osdmap([&](const OSDMap& osdmap) { for (const auto& poolname : poolnames) { @@ -1677,10 +1682,10 @@ bool DaemonServer::_handle_command( } else if (prefix == "osd safe-to-destroy" || prefix == "osd destroy" || prefix == "osd purge") { - set osds; + std::set osds; int r = 0; if (prefix == "osd safe-to-destroy") { - vector ids; + std::vector ids; cmd_getval(cmdctx->cmdmap, "ids", ids); cluster_state.with_osdmap([&](const OSDMap& osdmap) { r = osdmap.parse_osd_id_list(ids, &osds, &ss); @@ -1702,7 +1707,7 @@ bool DaemonServer::_handle_command( cmdctx->reply(r, ss); return true; } - set active_osds, missing_stats, stored_pgs, safe_to_destroy; + std::set active_osds, missing_stats, stored_pgs, safe_to_destroy; int affected_pgs = 0; cluster_state.with_osdmap_and_pgmap([&](const OSDMap& osdmap, const PGMap& pg_map) { if (pg_map.num_pg_unknown > 0) { @@ -1837,9 +1842,9 @@ bool DaemonServer::_handle_command( monc->start_mon_command({cmd}, {}, nullptr, &on_finish->outs, on_finish); return true; } else if (prefix == "osd ok-to-stop") { - vector ids; + std::vector ids; cmd_getval(cmdctx->cmdmap, "ids", ids); - set osds; + std::set osds; int64_t max = 1; cmd_getval(cmdctx->cmdmap, "max", max); int r; @@ -1889,11 +1894,11 @@ bool DaemonServer::_handle_command( prefix == "osd pool force-backfill" || prefix == "osd pool cancel-force-recovery" || prefix == "osd pool cancel-force-backfill") { - vector vs; + std::vector vs; get_str_vec(prefix, vs); auto& granularity = vs.front(); auto& forceop = vs.back(); - vector pgs; + std::vector pgs; // figure out actual op just once int actual_op = 0; @@ -1907,10 +1912,10 @@ bool DaemonServer::_handle_command( actual_op = OFR_RECOVERY | OFR_CANCEL; } - set candidates; // deduped + std::set candidates; // deduped if (granularity == "pg") { // covnert pg names to pgs, discard any invalid ones while at it - vector pgids; + std::vector pgids; cmd_getval(cmdctx->cmdmap, "pgid", pgids); for (auto& i : pgids) { pg_t pgid; @@ -1923,7 +1928,7 @@ bool DaemonServer::_handle_command( } } else { // per pool - vector pool_names; + std::vector pool_names; cmd_getval(cmdctx->cmdmap, "who", pool_names); if (pool_names.empty()) { ss << "must specify one or more pool names"; @@ -2018,7 +2023,7 @@ bool DaemonServer::_handle_command( // message per distinct OSD cluster_state.with_osdmap([&](const OSDMap& osdmap) { // group pgs to process by osd - map> osdpgs; + std::map> osdpgs; for (auto& pgid : pgs) { int primary; spg_t spg; @@ -2264,7 +2269,7 @@ bool DaemonServer::_handle_command( cmdctx->reply(r, ss); return true; } else if (prefix == "device ls") { - set devids; + std::set devids; TextTable tbl; if (f) { f->open_array_section("devices"); @@ -2363,7 +2368,7 @@ bool DaemonServer::_handle_command( } else if (prefix == "device ls-by-host") { string host; cmd_getval(cmdctx->cmdmap, "host", host); - set devids; + std::set devids; daemon_state.list_devids_by_server(host, &devids); if (f) { f->open_array_section("devices"); @@ -2452,7 +2457,7 @@ bool DaemonServer::_handle_command( r = -EINVAL; cmdctx->reply(r, ss); } else { - map meta; + std::map meta; daemon_state.with_device_create( devid, [from, to, &meta] (DeviceState& dev) { @@ -2478,7 +2483,7 @@ bool DaemonServer::_handle_command( } else if (prefix == "device rm-life-expectancy") { string devid; cmd_getval(cmdctx->cmdmap, "devid", devid); - map meta; + std::map meta; if (daemon_state.with_device_write(devid, [&meta] (DeviceState& dev) { dev.rm_life_expectancy(); meta = dev.metadata; @@ -2733,7 +2738,7 @@ void DaemonServer::send_report() }); }); - map> accumulated; + std::map> accumulated; for (auto service : {"osd", "mon"} ) { auto daemons = daemon_state.get_by_service(service); for (const auto& [key,state] : daemons) { @@ -2772,9 +2777,9 @@ void DaemonServer::adjust_pgs() double max_misplaced = g_conf().get_val("target_max_misplaced_ratio"); bool aggro = g_conf().get_val("mgr_debug_aggressive_pg_num_changes"); - map pg_num_to_set; - map pgp_num_to_set; - set upmaps_to_clear; + std::map pg_num_to_set; + std::map pgp_num_to_set; + std::set upmaps_to_clear; cluster_state.with_osdmap_and_pgmap([&](const OSDMap& osdmap, const PGMap& pg_map) { unsigned creating_or_unknown = 0; for (auto& i : pg_map.num_pg_by_state) { @@ -2844,7 +2849,7 @@ void DaemonServer::adjust_pgs() << dendl; ok = false; } - vector source_acting; + std::vector source_acting; for (auto &merge_participant : {merge_source, merge_target}) { bool is_merge_source = merge_participant == merge_source; if (osdmap.have_pg_upmaps(merge_participant)) { @@ -3136,7 +3141,7 @@ void DaemonServer::got_service_map() void DaemonServer::got_mgr_map() { std::lock_guard l(lock); - set have; + std::set have; cluster_state.with_mgrmap([&](const MgrMap& mgrmap) { auto md_update = [&] (DaemonKey key) { std::ostringstream oss; @@ -3272,8 +3277,8 @@ bool DaemonServer::asok_command( even those get stuck. Please enable \"mgr_enable_op_tracker\", and the tracker \ will start to track new ops received afterwards."; - set filters; - vector filter_str; + std::set filters; + std::vector filter_str; if (cmd_getval(cmdmap, "filterstr", filter_str)) { copy(filter_str.begin(), filter_str.end(), inserter(filters, filters.end())); diff --git a/src/mgr/DaemonServer.h b/src/mgr/DaemonServer.h index 1193805def572..c1c92883f3d5b 100644 --- a/src/mgr/DaemonServer.h +++ b/src/mgr/DaemonServer.h @@ -19,6 +19,8 @@ #include #include #include +#include +#include #include "common/ceph_mutex.h" #include "common/LogClient.h" @@ -49,10 +51,10 @@ struct MDSPerfMetricQuery; struct offline_pg_report { - set osds; - set ok, not_ok, unknown; - set ok_become_degraded, ok_become_more_degraded; // ok - set bad_no_pool, bad_already_inactive, bad_become_inactive; // not ok + std::set osds; + std::set ok, not_ok, unknown; + std::set ok_become_degraded, ok_become_more_degraded; // ok + std::set bad_no_pool, bad_already_inactive, bad_become_inactive; // not ok bool ok_to_stop() const { return not_ok.empty() && unknown.empty(); @@ -180,7 +182,7 @@ private: const PGMap& pgmap, offline_pg_report *report); void _maximize_ok_to_stop_set( - const set& orig_osds, + const std::set& orig_osds, unsigned max, const OSDMap& osdmap, const PGMap& pgmap, diff --git a/src/mgr/Mgr.cc b/src/mgr/Mgr.cc index b320ea484be67..0154a04e0ef5d 100644 --- a/src/mgr/Mgr.cc +++ b/src/mgr/Mgr.cc @@ -113,7 +113,7 @@ void MetadataUpdate::finish(int r) if (daemon_state.exists(key)) { DaemonStatePtr state = daemon_state.get(key); - map m; + std::map m; { std::lock_guard l(state->lock); state->hostname = daemon_meta.at("hostname").get_str(); @@ -141,7 +141,7 @@ void MetadataUpdate::finish(int r) } daemon_meta.erase("hostname"); - map m; + std::map m; for (const auto &[key, val] : daemon_meta) { m.emplace(key, val.get_str()); } @@ -330,7 +330,7 @@ void Mgr::init() ++p) { string devid = p->first.substr(7); dout(10) << " updating " << devid << dendl; - map meta; + std::map meta; ostringstream ss; int r = get_json_str_map(p->second, ss, &meta, false); if (r < 0) { @@ -449,7 +449,7 @@ void Mgr::load_all_metadata() daemon_meta.erase("name"); daemon_meta.erase("hostname"); - map m; + std::map m; for (const auto &[key, val] : daemon_meta) { m.emplace(key, val.get_str()); } @@ -474,7 +474,7 @@ void Mgr::load_all_metadata() osd_metadata.erase("id"); osd_metadata.erase("hostname"); - map m; + std::map m; for (const auto &i : osd_metadata) { m[i.first] = i.second.get_str(); } @@ -733,7 +733,7 @@ bool Mgr::got_mgr_map(const MgrMap& m) std::lock_guard l(lock); dout(10) << m << dendl; - set old_modules; + std::set old_modules; cluster_state.with_mgrmap([&](const MgrMap& m) { old_modules = m.modules; }); diff --git a/src/mgr/PyModuleRegistry.h b/src/mgr/PyModuleRegistry.h index 9d6d9c2cdd021..294fc7a8277f0 100644 --- a/src/mgr/PyModuleRegistry.h +++ b/src/mgr/PyModuleRegistry.h @@ -17,16 +17,17 @@ // First because it includes Python.h #include "PyModule.h" -#include -#include -#include -#include - #include "common/LogClient.h" #include "ActivePyModules.h" #include "StandbyPyModules.h" +#include +#include +#include +#include +#include + class MgrSession; /** @@ -69,7 +70,7 @@ public: void update_kv_data( const std::string prefix, bool incremental, - const map, std::less<>>& data) { + const std::map, std::less<>>& data) { ceph_assert(active_modules); active_modules->update_kv_data(prefix, incremental, data); } @@ -164,7 +165,7 @@ public: */ void get_health_checks(health_check_map_t *checks); - void get_progress_events(map *events) { + void get_progress_events(std::map *events) { if (active_modules) { active_modules->get_progress_events(events); } -- 2.39.5