From: John Spray Date: Wed, 5 Jul 2017 13:12:46 +0000 (-0400) Subject: common: hook in 'safe' flag to new config options X-Git-Tag: v12.1.2~192^2~34 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f1ac8dc7a4632b786a50da089fb62d547aa92116;p=ceph.git common: hook in 'safe' flag to new config options 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 --- diff --git a/src/common/config.h b/src/common/config.h index 0f8f8b1a0f31..7aa9917982ab 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -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; diff --git a/src/common/options.h b/src/common/options.h index 1a1de1979046..92af1684ecf8 100644 --- a/src/common/options.h +++ b/src/common/options.h @@ -62,8 +62,10 @@ struct Option { value_t min, max; std::list 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