From: Sage Weil Date: Tue, 16 Nov 2021 21:04:01 +0000 (-0500) Subject: mon/ConfigMap: use ValueSource type for generate_entity_map() X-Git-Tag: v19.0.0~103^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e65f676cd17836b2144fca82408412fe9e21fdaf;p=ceph-ci.git mon/ConfigMap: use ValueSource type for generate_entity_map() Changes from original commit: - switch to unordered map - use nullptr instead of 0 Signed-off-by: Sage Weil Signed-off-by: Matan Breizman (cherry picked from commit e36da92118eac4d2af11d8a8a1795e7b08d08874) --- diff --git a/src/mgr/ActivePyModules.cc b/src/mgr/ActivePyModules.cc index 45038e734af..701b41bef8e 100644 --- a/src/mgr/ActivePyModules.cc +++ b/src/mgr/ActivePyModules.cc @@ -1198,13 +1198,11 @@ PyObject *ActivePyModules::get_foreign_config( << " class " << device_class << dendl; } - std::map> src; config = config_map.generate_entity_map( entity, crush_location, osdmap.crush.get(), - device_class, - &src); + device_class); }); // get a single value diff --git a/src/mon/ConfigMap.cc b/src/mon/ConfigMap.cc index 7a639947bde..dff1a94c1e6 100644 --- a/src/mon/ConfigMap.cc +++ b/src/mon/ConfigMap.cc @@ -136,7 +136,7 @@ ConfigMap::generate_entity_map( const map& crush_location, const CrushWrapper *crush, const std::string& device_class, - std::map> *src) + std::unordered_map *src) { // global, then by type, then by name prefix component(s), then name. // name prefix components are .-separated, @@ -185,7 +185,7 @@ ConfigMap::generate_entity_map( } out[i.first] = o.raw_value; if (src) { - (*src)[i.first] = make_pair(s.first, &o); + (*src).emplace(i.first, ConfigMap::ValueSource(s.first, &o)); } prev = &o; } diff --git a/src/mon/ConfigMap.h b/src/mon/ConfigMap.h index 34af942a61e..bf2bd97c0ba 100644 --- a/src/mon/ConfigMap.h +++ b/src/mon/ConfigMap.h @@ -99,6 +99,14 @@ struct Section { }; struct ConfigMap { + struct ValueSource { + std::string section; + const MaskedOption *option = nullptr; + ValueSource() {} + ValueSource(const std::string& s, const MaskedOption *o) + : section(s), option(o) {} + }; + Section global; std::map> by_type; std::map> by_id; @@ -125,12 +133,13 @@ struct ConfigMap { stray_options.clear(); } void dump(ceph::Formatter *f) const; + std::map> generate_entity_map( const EntityName& name, const std::map& crush_location, const CrushWrapper *crush, const std::string& device_class, - std::map> *src=0); + std::unordered_map *src = nullptr); void parse_key( const std::string& key, diff --git a/src/mon/ConfigMonitor.cc b/src/mon/ConfigMonitor.cc index 7f52b9d7ef7..a5f61cbea52 100644 --- a/src/mon/ConfigMonitor.cc +++ b/src/mon/ConfigMonitor.cc @@ -314,7 +314,7 @@ bool ConfigMonitor::preprocess_command(MonOpRequestRef op) << " class " << device_class << dendl; } - std::map> src; + std::unordered_map src; auto config = config_map.generate_entity_map( entity, crush_location, @@ -378,20 +378,20 @@ bool ConfigMonitor::preprocess_command(MonOpRequestRef op) continue; } if (!f) { - tbl << q->second.first; - tbl << q->second.second->mask.to_str(); - tbl << Option::level_to_str(q->second.second->opt->level); + tbl << q->second.section; + tbl << q->second.option->mask.to_str(); + tbl << Option::level_to_str(q->second.option->opt->level); tbl << p->first; tbl << p->second; - tbl << (q->second.second->opt->can_update_at_runtime() ? "" : "*"); + tbl << (q->second.option->opt->can_update_at_runtime() ? "" : "*"); tbl << TextTable::endrow; } else { f->open_object_section(p->first.c_str()); f->dump_string("value", p->second); - f->dump_string("section", q->second.first); - f->dump_object("mask", q->second.second->mask); + f->dump_string("section", q->second.section); + f->dump_object("mask", q->second.option->mask); f->dump_bool("can_update_at_runtime", - q->second.second->opt->can_update_at_runtime()); + q->second.option->opt->can_update_at_runtime()); f->close_section(); } }