]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: hook in 'safe' flag to new config options
authorJohn Spray <john.spray@redhat.com>
Wed, 5 Jul 2017 13:12:46 +0000 (09:12 -0400)
committerJohn Spray <john.spray@redhat.com>
Fri, 21 Jul 2017 10:27:24 +0000 (06:27 -0400)
It's a poor substitute for real a concurrency solution
but for the moment carry it forward so that the options
structure can replace the list of config_option
in md_config_t.

Signed-off-by: John Spray <john.spray@redhat.com>
src/common/config.h
src/common/options.h
src/convert.cc

index 0f8f8b1a0f31271917d9370ff1822bc06524a1cb..7aa9917982ab7dfdfc5f93d8b65a2cb9f9a815d2 100644 (file)
@@ -301,6 +301,11 @@ public:
   /// cluster name
   string cluster;
 
+// This macro block defines C members of the md_config_t struct
+// corresponding to the definitions in legacy_config_opts.h.
+// These C members are consumed by code that was written before
+// the new options.cc infrastructure: all newer code should
+// be consume options via explicit get() rather than C members.
 #define OPTION_OPT_INT(name) const int name;
 #define OPTION_OPT_LONGLONG(name) const long long name;
 #define OPTION_OPT_STR(name) const std::string name;
index 1a1de1979046ff5a15ebdb1ffb57a585e47805ef..92af1684ecf87af40fb46905c51895b90c94149e 100644 (file)
@@ -62,8 +62,10 @@ struct Option {
   value_t min, max;
   std::list<std::string> enum_allowed;
 
+  bool safe;
+
   Option(const char* name, type_t t, level_t l)
-    : name(name), type(t), level(l)
+    : name(name), type(t), level(l), safe(false)
   {}
 
   // bool is an integer, but we don't think so. teach it the hard way.
@@ -117,6 +119,21 @@ struct Option {
     max = ma;
     return *this;
   }
+
+  Option &set_safe() {
+    safe = true;
+    return *this;
+  }
+
+  /**
+   * A crude indicator of whether the value may be
+   * modified safely at runtime -- should be replaced
+   * with proper locking!
+   */
+  bool is_safe() const
+  {
+    return type == TYPE_INT || type == TYPE_FLOAT;
+  }
 };
 
 extern const std::vector<Option> ceph_options;
index 3d716e8c9a6b105e8cffae0071a6cac3ed4cee7a..48f149190c138079a5ebc702a212bcdea65667ab 100644 (file)
@@ -41,7 +41,13 @@ string convert_type(string t) {
   << "  .set_description(\"\"),\n\n";
   
 #define OPTION_VALIDATOR(name)
-#define SAFE_OPTION(name, type, def_val) OPTION(name, type, def_val)
+#define SAFE_OPTION(name, type, def_val)            \
+  cout << "  Option(\"" << STRINGIFY(name) << "\", Option::" << convert_type(STRINGIFY(type)) \
+  << ", Option::LEVEL_ADVANCED)\n"                                     \
+  << "  .set_default(" << STRINGIFY(def_val) << ")\n"                  \
+  << "  .set_description(\"\")\n";                  \
+  << "  .set_safe(),\n\n";
+  
 #define SUBSYS(name, log, gather)
 #define DEFAULT_SUBSYS(log, gather)