From: Sage Weil Date: Wed, 10 Jan 2018 18:38:50 +0000 (-0600) Subject: common/config: move unsafe runtime change into _set_val X-Git-Tag: v13.0.2~78^2~66 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=b0c25cc59bd4c346d767b71c86db5c7aa314a919;p=ceph.git common/config: move unsafe runtime change into _set_val We want this to apply to other callers, set_mon_vals() in particular. Signed-off-by: Sage Weil --- diff --git a/src/common/config.cc b/src/common/config.cc index 1dbc383e20005..0c7a3ac5e85d5 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -672,11 +672,6 @@ int md_config_t::parse_option(std::vector& args, ret = -EINVAL; break; } - if (oss && ((!opt.is_safe()) && - (observers.find(opt.name) == observers.end()))) { - *oss << "You cannot change " << opt.name << " using injectargs.\n"; - return -ENOSYS; - } ret = _set_val(val, opt, level, &error_message); break; } @@ -871,17 +866,6 @@ int md_config_t::set_val(const std::string &key, const char *val, const auto &opt_iter = schema.find(k); if (opt_iter != schema.end()) { const Option &opt = opt_iter->second; - if ((!opt.is_safe()) && safe_to_start_threads) { - // If threads have been started and the option is not thread safe - if (observers.find(opt.name) == observers.end()) { - // And there is no observer to safely change it... - // You lose. - if (err_ss) *err_ss << "Configuration option '" << key << "' may " - "not be modified at runtime"; - return -ENOSYS; - } - } - std::string error_message; int r = _set_val(v, opt, CONF_OVERRIDE, &error_message); if (r >= 0) { @@ -1286,6 +1270,18 @@ int md_config_t::_set_val( return r; } + // unsafe runtime change? + if (!opt.is_safe() && + safe_to_start_threads && + observers.count(opt.name) == 0) { + // accept value if it is not actually a change + if (new_value != _get_val(opt)) { + *error_message = string("Configuration option '") + opt.name + + "' may not be modified at runtime"; + return -ENOSYS; + } + } + // Apply the value to its entry in the `values` map auto p = values.find(opt.name); if (p != values.end()) {