common/options: is_safe() -> can_update_at_runtime()

Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2018-01-11 09:21:54 -06:00
parent 285ec18baf
commit ac88f05825
4 changed files with 19 additions and 10 deletions

View 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

View 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)

View 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

View 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();
}
}