]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/ConfigMap: some improvements
authorSage Weil <sage@redhat.com>
Thu, 4 Jan 2018 23:14:09 +0000 (17:14 -0600)
committerSage Weil <sage@redhat.com>
Tue, 6 Mar 2018 20:44:48 +0000 (14:44 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/ConfigMap.cc
src/mon/ConfigMap.h

index 35d433e64d8915d29b135b564fce819d113650be..8b6f5e090705972c5965154cdad2417588be9c1e 100644 (file)
@@ -24,17 +24,22 @@ int MaskedOption::get_precision(const CrushWrapper *crush)
   return num_types + 1;
 }
 
+void OptionMask::dump(Formatter *f) const
+{
+  if (location_type.size()) {
+    f->dump_string("location_type", location_type);
+    f->dump_string("location_value", location_value);
+  }
+  if (device_class.size()) {
+    f->dump_string("device_class", device_class);
+  }
+}
+
 void MaskedOption::dump(Formatter *f) const
 {
   f->dump_string("name", opt.name);
   f->dump_string("value", raw_value);
-  if (mask.location_type.size()) {
-    f->dump_string("location_type", mask.location_type);
-    f->dump_string("location_value", mask.location_value);
-  }
-  if (mask.device_class.size()) {
-    f->dump_string("device_class", mask.device_class);
-  }
+  mask.dump(f);
 }
 
 ostream& operator<<(ostream& out, const MaskedOption& o)
@@ -80,21 +85,22 @@ void ConfigMap::generate_entity_map(
   const map<std::string,std::string>& crush_location,
   const CrushWrapper *crush,
   const std::string& device_class,
-  std::map<std::string,std::string> *out)
+  std::map<std::string,std::string> *out,
+  std::map<std::string,pair<std::string,OptionMask>> *src)
 {
   // global, then by type, then by full name.
-  vector<Section*> sections = { &global };
+  vector<pair<string,Section*>> sections = { make_pair("global", &global) };
   auto p = by_type.find(name.get_type_name());
   if (p != by_type.end()) {
-    sections.push_back(&p->second);
+    sections.push_back(make_pair(name.get_type_name(), &p->second));
   }
   auto q = by_id.find(name.to_str());
   if (q != by_id.end()) {
-    sections.push_back(&q->second);
+    sections.push_back(make_pair(name.to_str(), &q->second));
   }
   MaskedOption *prev = nullptr;
   for (auto s : sections) {
-    for (auto& i : s->options) {
+    for (auto& i : s.second->options) {
       auto& o = i.second;
       // match against crush location, class
       if (o.mask.device_class.size() &&
@@ -116,6 +122,9 @@ void ConfigMap::generate_entity_map(
        continue;
       }
       (*out)[i.first] = o.raw_value;
+      if (src) {
+       (*src)[i.first] = make_pair(s.first, o.mask);
+      }
       prev = &o;
     }
   }
index 38b9296d391b5c0a5ca160647989f7b538acaa55..86c258419623afaf0f05352e75c0d7dd205644b9 100644 (file)
@@ -47,6 +47,7 @@ struct OptionMask {
     }
     return r;
   }
+  void dump(Formatter *f) const;
 };
 
 struct MaskedOption {
@@ -89,7 +90,8 @@ struct ConfigMap {
     const map<std::string,std::string>& crush_location,
     const CrushWrapper *crush,
     const std::string& device_class,
-    std::map<std::string,std::string> *out);
+    std::map<std::string,std::string> *out,
+    std::map<std::string,pair<std::string,OptionMask>> *src=0);
 
   static bool parse_mask(
     const std::string& in,