]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/options: is_safe() -> can_update_at_runtime()
authorSage Weil <sage@redhat.com>
Thu, 11 Jan 2018 15:21:54 +0000 (09:21 -0600)
committerSage Weil <sage@redhat.com>
Tue, 6 Mar 2018 20:44:49 +0000 (14:44 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
src/common/config.cc
src/common/options.cc
src/common/options.h
src/mon/ConfigMonitor.cc

index 3c22efd7a005c883049a01f87a01f34788842386..bd46466cf91286081cab6e38970e48ea2a8c7eed 100644 (file)
@@ -1296,7 +1296,7 @@ int md_config_t::_set_val(
   }
 
   // unsafe runtime change?
-  if (!opt.is_safe() &&
+  if (!opt.can_update_at_runtime() &&
       safe_to_start_threads &&
       observers.count(opt.name) == 0) {
     // accept value if it is not actually a change
index 7834865dbd1154c47da9ac99a354e5670c6814cc..2e53596481473d97141c2e9dc7b59ecb266b8466 100644 (file)
@@ -200,7 +200,7 @@ void Option::dump(Formatter *f) const
   dump_value("min", min, f);
   dump_value("max", max, f);
 
-  f->dump_bool("can_update_at_runtime", is_safe());
+  f->dump_bool("can_update_at_runtime", can_update_at_runtime());
 }
 
 ostream& operator<<(ostream& out, const Option::value_t& v)
@@ -255,7 +255,8 @@ void Option::print(ostream *out) const
     *out << "  Minimum: " << stringify(min) << "\n"
         << "  Maximum: " << stringify(max) << "\n";
   }
-  *out << "  Can update at runtime: " << (is_safe() ? "true" : "false") << "\n";
+  *out << "  Can update at runtime: "
+       << (can_update_at_runtime() ? "true" : "false") << "\n";
   if (!services.empty()) {
     *out << "  Services: " << services << "\n";
   }
@@ -6206,7 +6207,7 @@ static std::vector<Option> get_rbd_options() {
                           "setting of 'auto' will use the v2 format if the "
                           "cluster is configured to require mimic or later "
                           "clients.")
-    .set_safe(),
+    .set_flag(Option::FLAG_RUNTIME),
 
     Option("rbd_journal_order", Option::TYPE_UINT, Option::LEVEL_ADVANCED)
     .set_min(12)
index e6037cf6d959c8c7e11b5c96d8a80f11f135ec80..3f41af2b1d156850729934e72ed185332f53ee2b 100644 (file)
@@ -56,8 +56,12 @@ struct Option {
   }
 
   enum flag_t {
-    FLAG_SAFE = 1,
-    FLAG_NO_MON_UPDATE = 2,
+    FLAG_SAFE = 0x1,            ///< option is observed and can update at runtime
+    FLAG_RUNTIME = 0x1,         ///< option can change changed at runtime
+    FLAG_NO_MON_UPDATE = 0x2,   ///< option cannot be changed via mon config
+    FLAG_STARTUP = 0x4,         ///< option can only take effect at startup
+    FLAG_CLUSTER_CREATE = 0x8,  ///< option only has effect at cluster creation
+    FLAG_DAEMON_CREATE = 0x10,  ///< option only has effect at daemon creation
   };
 
   using value_t = boost::variant<
@@ -259,6 +263,10 @@ struct Option {
     flags |= f;
     return *this;
   }
+  Option &set_flags(flag_t f) {
+    flags |= f;
+    return *this;
+  }
 
   Option &set_safe() {
     flags |= FLAG_SAFE;
@@ -288,7 +296,7 @@ struct Option {
    * modified safely at runtime -- should be replaced
    * with proper locking!
    */
-  bool is_safe() const
+  bool can_update_at_runtime() const
   {
     return has_flag(FLAG_SAFE)
       || type == TYPE_BOOL || type == TYPE_INT
index db8bff51c8cadbaa15250604200172e3d2cedcc5..0af47a55cab6ac6371916bbd096c9687c723bdfa 100644 (file)
@@ -160,7 +160,7 @@ bool ConfigMonitor::preprocess_command(MonOpRequestRef op)
          tbl << Option::level_to_str(i.second.opt->level);
           tbl << i.first;
          tbl << i.second.raw_value;
-         tbl << (i.second.opt->is_safe() ? "*" : "");
+         tbl << (i.second.opt->can_update_at_runtime() ? "*" : "");
          tbl << TextTable::endrow;
        } else {
          f->open_object_section("option");
@@ -254,7 +254,7 @@ bool ConfigMonitor::preprocess_command(MonOpRequestRef op)
          tbl << Option::level_to_str(q->second.second->opt->level);
          tbl << p->first;
          tbl << p->second;
-         tbl << (q->second.second->opt->is_safe() ? "*" : "");
+         tbl << (q->second.second->opt->can_update_at_runtime() ? "*" : "");
          tbl << TextTable::endrow;
        } else {
          f->open_object_section(p->first.c_str());
@@ -262,7 +262,7 @@ bool ConfigMonitor::preprocess_command(MonOpRequestRef op)
          f->dump_string("section", q->second.first);
          f->dump_object("mask", q->second.second->mask);
          f->dump_bool("can_update_at_runtime",
-                      q->second.second->opt->is_safe());
+                      q->second.second->opt->can_update_at_runtime());
          f->close_section();
        }
       }