From: Kefu Chai Date: Sun, 15 Jul 2018 09:50:12 +0000 (+0800) Subject: common/config: move _apply_changes() calls up into ConfigProxy X-Git-Tag: v14.0.1~777^2~14 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9bfc03672063e86b0a1391b35a33e31193575214;p=ceph.git common/config: move _apply_changes() calls up into ConfigProxy see also the previous the commit, to reuse injectargs() and set_mon_vals() in seastar's ConfigProxy, we need to move apply_changes() call out of them, as this call is implemented differently in seastar's ConfigProxy. finalize_reexpand_meta() is not used by OSD at this moment, so we leave it as it is for now. * move _apply_changes() calls up into ConfigProxy * move update_legacy_vals() out of _apply_changes() into the callers of the latter. as it changes "values", in seastar's ConfigProxy, it belongs to the first step of changing a config value Signed-off-by: Kefu Chai --- diff --git a/src/common/config.cc b/src/common/config.cc index 2c5bafbe0304..4cb5c8d5fb31 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -270,7 +270,6 @@ void md_config_impl::set_val_default(ConfigValues& values, template int md_config_impl::set_mon_vals(CephContext *cct, ConfigValues& values, - const ConfigProxy& proxy, const map& kv, config_callback config_cb) { @@ -326,7 +325,7 @@ int md_config_impl::set_mon_vals(CephContext *cct, values.rm_val(name, CONF_MON); }); values_bl.clear(); - _apply_changes(values, proxy, nullptr); + update_legacy_vals(values); return 0; } @@ -771,8 +770,11 @@ void md_config_impl::apply_changes(ConfigValues& values, /* * apply changes until the cluster name is assigned */ - if (values.cluster.size()) + if (values.cluster.size()) { + // meta expands could have modified anything. Copy it all out again. + update_legacy_vals(values); _apply_changes(values, proxy, oss); + } } template @@ -784,9 +786,6 @@ void md_config_impl::_apply_changes(ConfigValues& values, * have changed. */ typedef std::map < md_config_obs_t*, std::set > rev_obs_map_t; - // meta expands could have modified anything. Copy it all out again. - update_legacy_vals(values); - // create the reverse observer mapping, mapping observers to the set of // changed keys that they'll get. rev_obs_map_t robs; @@ -857,7 +856,6 @@ void md_config_impl::_clear_safe_to_start_threads() template int md_config_impl::injectargs(ConfigValues& values, - const ConfigProxy& proxy, const std::string& s, std::ostream *oss) { int ret; @@ -885,7 +883,7 @@ int md_config_impl::injectargs(ConfigValues& values, *oss << "\n"; ret = -EINVAL; } - _apply_changes(values, proxy, oss); + update_legacy_vals(values); return ret; } @@ -1131,8 +1129,11 @@ void md_config_impl::finalize_reexpand_meta(ConfigValues& values, set_val(values, i.first, i.second); } - if (may_reexpand_meta.size()) + if (may_reexpand_meta.size()) { + // meta expands could have modified anything. Copy it all out again. + update_legacy_vals(values); _apply_changes(values, proxy, NULL); + } } template diff --git a/src/common/config.h b/src/common/config.h index 938fae210850..747f0985957f 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -184,13 +184,13 @@ public: /// Set a values from mon int set_mon_vals(CephContext *cct, ConfigValues& values, - const ConfigProxy& proxy, const map& kv, config_callback config_cb); // Called by the Ceph daemons to make configuration changes at runtime - int injectargs(ConfigValues& values, const ConfigProxy& proxy, - const std::string &s, std::ostream *oss); + int injectargs(ConfigValues& values, + const std::string &s, + std::ostream *oss); // Set a configuration value, or crash // Metavariables will be expanded. diff --git a/src/common/config_proxy.h b/src/common/config_proxy.h index 2b34b9a2711f..057cf4d17633 100644 --- a/src/common/config_proxy.h +++ b/src/common/config_proxy.h @@ -93,35 +93,16 @@ public: } // change `values` in-place void finalize_reexpand_meta() { -<<<<<<< HEAD - Mutex::Locker l(lock); - config.finalize_reexpand_meta(values, *this); - } - void add_observer(md_config_obs_t* obs) { - Mutex::Locker l(lock); - config.add_observer(obs); - } - void remove_observer(md_config_obs_t* obs) { - Mutex::Locker l(lock); - config.remove_observer(obs); - } - void call_all_observers() { - Mutex::Locker l(lock); - config.call_all_observers(*this); -======= Mutex::Locker l{lock}; - if (config.finalize_reexpand_meta(values, obs_mgr)) { - obs_mgr.apply_changes(values.changed, *this, nullptr); - values.changed.clear(); - } + config.finalize_reexpand_meta(values, *this); } void add_observer(md_config_obs_t* obs) { Mutex::Locker l{lock}; - obs_mgr.add_observer(obs); + config.add_observer(obs); } void remove_observer(md_config_obs_t* obs) { Mutex::Locker l{lock}; - obs_mgr.remove_observer(obs); + config.remove_observer(obs); } void call_all_observers() { Mutex::Locker l{lock}; @@ -133,8 +114,7 @@ public: // An alternative might be to pass a std::unique_lock to // handle_conf_change and have a version of get_var that can take it // by reference and lock as appropriate. - obs_mgr.call_all_observers(*this); ->>>>>>> 9a2bc3c2eb... wip + config.call_all_observers(*this); } void set_safe_to_start_threads() { config.set_safe_to_start_threads(); @@ -179,11 +159,17 @@ public: const map& kv, md_config_t::config_callback config_cb) { Mutex::Locker l{lock}; - config.set_mon_vals(cct, values, *this, kv, config_cb); + int ret = config.set_mon_vals(cct, values, kv, config_cb); + config._apply_changes(values, *this, nullptr); + values.changed.clear(); + return ret; } int injectargs(const std::string &s, std::ostream *oss) { Mutex::Locker l{lock}; - config.injectargs(values, *this, s, oss); + int ret = config.injectargs(values, s, oss); + config._apply_changes(values, *this, oss); + values.changed.clear(); + return ret; } void parse_env(const char *env_var = "CEPH_ARGS") { Mutex::Locker l{lock};