]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/config: move unsafe runtime change into _set_val
authorSage Weil <sage@redhat.com>
Wed, 10 Jan 2018 18:38:50 +0000 (12:38 -0600)
committerSage Weil <sage@redhat.com>
Tue, 6 Mar 2018 20:44:49 +0000 (14:44 -0600)
We want this to apply to other callers, set_mon_vals() in particular.

Signed-off-by: Sage Weil <sage@redhat.com>
src/common/config.cc

index 1dbc383e2000546cdff45bef5ceedeba02ecaed6..0c7a3ac5e85d5002539c7d6b5223a2f5dab1927a 100644 (file)
@@ -672,11 +672,6 @@ int md_config_t::parse_option(std::vector<const char*>& 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()) {