From: Patrick Donnelly Date: Thu, 30 Jan 2025 22:05:25 +0000 (-0500) Subject: mgr: use std namespace X-Git-Tag: v20.0.0^2~14 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=706b2be416246dd5923478d8a7ee015246f03e95;p=ceph.git 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 --- diff --git a/src/mgr/ActivePyModules.cc b/src/mgr/ActivePyModules.cc index 0d10a275a106..c7b4db2d2946 100644 --- a/src/mgr/ActivePyModules.cc +++ b/src/mgr/ActivePyModules.cc @@ -246,7 +246,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) { @@ -783,7 +783,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; @@ -1119,7 +1119,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); @@ -1278,7 +1278,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 d6ade4849f78..c48a06ce95e4 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 5cd4dd00a385..5820b3f1abd5 100644 --- a/src/mgr/DaemonServer.cc +++ b/src/mgr/DaemonServer.cc @@ -51,6 +51,11 @@ #include +#include +#include +#include +#include + #define dout_context g_ceph_context #define dout_subsys ceph_subsys_mgr #undef dout_prefix @@ -815,14 +820,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) { @@ -856,7 +861,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()) { @@ -1003,7 +1008,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) @@ -1013,7 +1018,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); @@ -1075,7 +1080,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, @@ -1093,9 +1098,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 @@ -1161,7 +1166,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; @@ -1376,7 +1381,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, @@ -1392,10 +1397,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++) @@ -1421,9 +1426,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(); @@ -1469,7 +1474,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"; @@ -1477,8 +1482,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) { @@ -1533,8 +1538,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) { @@ -1686,10 +1691,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); @@ -1711,7 +1716,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) { @@ -1846,9 +1851,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; @@ -1898,11 +1903,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; @@ -1916,10 +1921,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; @@ -1932,7 +1937,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"; @@ -2027,7 +2032,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; @@ -2273,7 +2278,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"); @@ -2372,7 +2377,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"); @@ -2461,7 +2466,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) { @@ -2487,7 +2492,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; @@ -2742,7 +2747,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) { @@ -2783,9 +2788,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) { @@ -2855,7 +2860,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)) { @@ -3147,7 +3152,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; @@ -3283,8 +3288,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 1da225ffb7e9..ee0c26f94dea 100644 --- a/src/mgr/DaemonServer.h +++ b/src/mgr/DaemonServer.h @@ -20,6 +20,7 @@ #include #include #include +#include #include "common/ceph_mutex.h" #include "common/LogClient.h" @@ -52,10 +53,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(); @@ -183,7 +184,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 26f93563517a..9acd58248fbf 100644 --- a/src/mgr/Mgr.cc +++ b/src/mgr/Mgr.cc @@ -115,7 +115,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(); @@ -143,7 +143,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()); } @@ -332,7 +332,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) { @@ -451,7 +451,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()); } @@ -476,7 +476,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(); } @@ -742,7 +742,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 da5bb596c938..5224ab204005 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; /** @@ -70,7 +71,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); } @@ -165,7 +166,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); }