diff options
author | Kefu Chai <kchai@redhat.com> | 2018-07-06 17:08:00 +0200 |
---|---|---|
committer | Kefu Chai <kchai@redhat.com> | 2018-07-10 17:42:59 +0200 |
commit | f528475d92524328ef3e12dfec036461395338c0 (patch) | |
tree | fde1820cfa95bbb1227b83157e0a6cb745589d10 /src | |
parent | common,rbd,rgw,osd: extract config values into ConfigValues (diff) | |
download | ceph-f528475d92524328ef3e12dfec036461395338c0.tar.xz ceph-f528475d92524328ef3e12dfec036461395338c0.zip |
common: move ConfigValues out of md_config_t
by moving ConfigValues out of md_config_t, we are able to point
md_config_t to a new ConfigValues instance at runtime, without
destroying the old one.
also remove ConfigReader, because all md_config_obs_t will be updated
with ConfigProxy now. as md_config_t is not able to offer the *data*
anymore.
Signed-off-by: Kefu Chai <kchai@redhat.com>
Diffstat (limited to 'src')
142 files changed, 1031 insertions, 989 deletions
diff --git a/src/ceph_fuse.cc b/src/ceph_fuse.cc index ca7f31ca3b4..b959db3cebf 100644 --- a/src/ceph_fuse.cc +++ b/src/ceph_fuse.cc @@ -130,7 +130,7 @@ int main(int argc, const char **argv, const char *envp[]) { #endif Preforker forker; - auto daemonize = g_conf->get_val<bool>("daemonize"); + auto daemonize = g_conf().get_val<bool>("daemonize"); if (daemonize) { global_init_prefork(g_ceph_context); int r; @@ -156,7 +156,7 @@ int main(int argc, const char **argv, const char *envp[]) { } { - g_ceph_context->_conf->finalize_reexpand_meta(); + g_ceph_context->_conf.finalize_reexpand_meta(); common_init_finish(g_ceph_context); init_async_signal_handler(); @@ -177,12 +177,12 @@ int main(int argc, const char **argv, const char *envp[]) { #if defined(__linux__) int ver = get_linux_version(); assert(ver != 0); - bool client_try_dentry_invalidate = g_conf->get_val<bool>( + bool client_try_dentry_invalidate = g_conf().get_val<bool>( "client_try_dentry_invalidate"); bool can_invalidate_dentries = client_try_dentry_invalidate && ver < KERNEL_VERSION(3, 18, 0); int tr = client->test_dentry_handling(can_invalidate_dentries); - bool client_die_on_failed_dentry_invalidate = g_conf->get_val<bool>( + bool client_die_on_failed_dentry_invalidate = g_conf().get_val<bool>( "client_die_on_failed_dentry_invalidate"); if (tr != 0 && client_die_on_failed_dentry_invalidate) { cerr << "ceph-fuse[" << getpid() @@ -270,10 +270,10 @@ int main(int argc, const char **argv, const char *envp[]) { { // start up fuse // use my argc, argv (make sure you pass a mount point!) - auto client_mountpoint = g_conf->get_val<std::string>( + auto client_mountpoint = g_conf().get_val<std::string>( "client_mountpoint"); auto mountpoint = client_mountpoint.c_str(); - auto fuse_require_active_mds = g_conf->get_val<bool>( + auto fuse_require_active_mds = g_conf().get_val<bool>( "fuse_require_active_mds"); r = client->mount(mountpoint, perms, fuse_require_active_mds); if (r < 0) { diff --git a/src/ceph_mds.cc b/src/ceph_mds.cc index c5d0a01d005..9e5d4996054 100644 --- a/src/ceph_mds.cc +++ b/src/ceph_mds.cc @@ -119,9 +119,9 @@ int main(int argc, const char **argv) dout(0) << "requesting standby_replay for mds." << r << dendl; char rb[32]; snprintf(rb, sizeof(rb), "%d", r); - g_conf->set_val("mds_standby_for_rank", rb); - g_conf->set_val("mds_standby_replay", "true"); - g_conf->apply_changes(NULL); + g_conf().set_val("mds_standby_for_rank", rb); + g_conf().set_val("mds_standby_replay", "true"); + g_conf().apply_changes(nullptr); } else { derr << "Error: can't understand argument: " << *i << "\n" << dendl; @@ -135,14 +135,14 @@ int main(int argc, const char **argv) pick_addresses(g_ceph_context, CEPH_PICK_ADDRESS_PUBLIC, &addrs); // Normal startup - if (g_conf->name.has_default_id()) { + if (g_conf()->name.has_default_id()) { derr << "must specify '-i name' with the ceph-mds instance name" << dendl; exit(1); } - if (g_conf->name.get_id().empty() || - (g_conf->name.get_id()[0] >= '0' && g_conf->name.get_id()[0] <= '9')) { - derr << "MDS id '" << g_conf->name << "' is invalid. " + if (g_conf()->name.get_id().empty() || + (g_conf()->name.get_id()[0] >= '0' && g_conf()->name.get_id()[0] <= '9')) { + derr << "MDS id '" << g_conf()->name << "' is invalid. " "MDS names may not start with a numeric digit." << dendl; exit(1); } @@ -167,7 +167,7 @@ int main(int argc, const char **argv) auto nonce = ceph::util::generate_random_number<uint64_t>(); - std::string public_msgr_type = g_conf->ms_public_type.empty() ? g_conf->get_val<std::string>("ms_type") : g_conf->ms_public_type; + std::string public_msgr_type = g_conf()->ms_public_type.empty() ? g_conf().get_val<std::string>("ms_type") : g_conf()->ms_public_type; Messenger *msgr = Messenger::create(g_ceph_context, public_msgr_type, entity_name_t::MDS(-1), "mds", nonce, Messenger::HAS_MANY_CONNECTIONS); @@ -175,7 +175,7 @@ int main(int argc, const char **argv) forker.exit(1); msgr->set_cluster_protocol(CEPH_MDS_PROTOCOL); - cout << "starting " << g_conf->name << " at " << msgr->get_myaddrs() + cout << "starting " << g_conf()->name << " at " << msgr->get_myaddrs() << std::endl; uint64_t required = CEPH_FEATURE_OSDREPLYMUX; @@ -206,13 +206,13 @@ int main(int argc, const char **argv) msgr->start(); // start mds - mds = new MDSDaemon(g_conf->name.get_id().c_str(), msgr, &mc); + mds = new MDSDaemon(g_conf()->name.get_id().c_str(), msgr, &mc); // in case we have to respawn... mds->orig_argc = argc; mds->orig_argv = argv; - if (g_conf->daemonize) { + if (g_conf()->daemonize) { global_init_postfork_finish(g_ceph_context); forker.daemonize(); } @@ -226,7 +226,7 @@ int main(int argc, const char **argv) register_async_signal_handler_oneshot(SIGINT, handle_mds_signal); register_async_signal_handler_oneshot(SIGTERM, handle_mds_signal); - if (g_conf->inject_early_sigterm) + if (g_conf()->inject_early_sigterm) kill(getpid(), SIGTERM); msgr->wait(); diff --git a/src/ceph_mon.cc b/src/ceph_mon.cc index efbdf3b6d24..adff949480f 100644 --- a/src/ceph_mon.cc +++ b/src/ceph_mon.cc @@ -118,9 +118,9 @@ int check_mon_data_exists() /** Check whether **mon data** is empty. * * Being empty means mkfs has not been run and there's no monitor setup - * at **g_conf->mon_data**. + * at **g_conf()->mon_data**. * - * If the directory g_conf->mon_data is not empty we will return -ENOTEMPTY. + * If the directory g_conf()->mon_data is not empty we will return -ENOTEMPTY. * Otherwise we will return 0. Any other negative returns will represent * a failure to be handled by the caller. * diff --git a/src/client/Client.cc b/src/client/Client.cc index 1e351daaab8..25dee63efeb 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -5963,7 +5963,7 @@ void Client::tick() if (cct->_conf->client_debug_inject_tick_delay > 0) { sleep(cct->_conf->client_debug_inject_tick_delay); assert(0 == cct->_conf.set_val("client_debug_inject_tick_delay", "0")); - cct->_conf.apply_changes(NULL); + cct->_conf.apply_changes(nullptr); } ldout(cct, 21) << "tick" << dendl; @@ -13949,7 +13949,7 @@ const char** Client::get_tracked_conf_keys() const return keys; } -void Client::handle_conf_change(const md_config_t *conf, +void Client::handle_conf_change(const ConfigProxy& conf, const std::set <std::string> &changed) { Mutex::Locker lock(client_lock); diff --git a/src/client/Client.h b/src/client/Client.h index df61d07bbe2..21f94af95c8 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -1250,7 +1250,7 @@ public: int test_dentry_handling(bool can_invalidate); const char** get_tracked_conf_keys() const override; - void handle_conf_change(const md_config_t *conf, + void handle_conf_change(const ConfigProxy& conf, const std::set <std::string> &changed) override; uint32_t get_deleg_timeout() { return deleg_timeout; } int set_deleg_timeout(uint32_t timeout); diff --git a/src/client/fuse_ll.cc b/src/client/fuse_ll.cc index 86f91d31b23..cc8c964330c 100644 --- a/src/client/fuse_ll.cc +++ b/src/client/fuse_ll.cc @@ -131,7 +131,7 @@ static int getgroups(fuse_req_t req, gid_t **sgids) static void get_fuse_groups(UserPerm& perms, fuse_req_t req) { - if (g_conf->get_val<bool>("fuse_set_user_groups")) { + if (g_conf().get_val<bool>("fuse_set_user_groups")) { gid_t *gids = NULL; int count = getgroups(req, &gids); @@ -411,9 +411,9 @@ static void fuse_ll_mkdir(fuse_req_t req, fuse_ino_t parent, const char *name, UserPerm perm(ctx->uid, ctx->gid); get_fuse_groups(perm, req); #ifdef HAVE_SYS_SYNCFS - auto fuse_multithreaded = cfuse->client->cct->_conf->get_val<bool>( + auto fuse_multithreaded = cfuse->client->cct->_conf.get_val<bool>( "fuse_multithreaded"); - auto fuse_syncfs_on_mksnap = cfuse->client->cct->_conf->get_val<bool>( + auto fuse_syncfs_on_mksnap = cfuse->client->cct->_conf.get_val<bool>( "fuse_syncfs_on_mksnap"); if (cfuse->fino_snap(parent) == CEPH_SNAPDIR && fuse_multithreaded && fuse_syncfs_on_mksnap) { @@ -576,9 +576,9 @@ static void fuse_ll_open(fuse_req_t req, fuse_ino_t ino, if (r == 0) { fi->fh = (uint64_t)fh; #if FUSE_VERSION >= FUSE_MAKE_VERSION(2, 8) - auto fuse_disable_pagecache = cfuse->client->cct->_conf->get_val<bool>( + auto fuse_disable_pagecache = cfuse->client->cct->_conf.get_val<bool>( "fuse_disable_pagecache"); - auto fuse_use_invalidate_cb = cfuse->client->cct->_conf->get_val<bool>( + auto fuse_use_invalidate_cb = cfuse->client->cct->_conf.get_val<bool>( "fuse_use_invalidate_cb"); if (fuse_disable_pagecache) fi->direct_io = 1; @@ -797,9 +797,9 @@ static void fuse_ll_create(fuse_req_t req, fuse_ino_t parent, const char *name, fi->fh = (uint64_t)fh; fe.ino = cfuse->make_fake_ino(fe.attr.st_ino, fe.attr.st_dev); #if FUSE_VERSION >= FUSE_MAKE_VERSION(2, 8) - auto fuse_disable_pagecache = cfuse->client->cct->_conf->get_val<bool>( + auto fuse_disable_pagecache = cfuse->client->cct->_conf.get_val<bool>( "fuse_disable_pagecache"); - auto fuse_use_invalidate_cb = cfuse->client->cct->_conf->get_val<bool>( + auto fuse_use_invalidate_cb = cfuse->client->cct->_conf.get_val<bool>( "fuse_use_invalidate_cb"); if (fuse_disable_pagecache) fi->direct_io = 1; @@ -852,7 +852,7 @@ static void fuse_ll_setlk(fuse_req_t req, fuse_ino_t ino, Fh *fh = reinterpret_cast<Fh*>(fi->fh); // must use multithread if operation may block - auto fuse_multithreaded = cfuse->client->cct->_conf->get_val<bool>( + auto fuse_multithreaded = cfuse->client->cct->_conf.get_val<bool>( "fuse_multithreaded"); if (!fuse_multithreaded && sleep && lock->l_type != F_UNLCK) { fuse_reply_err(req, EDEADLK); @@ -888,7 +888,7 @@ static void fuse_ll_flock(fuse_req_t req, fuse_ino_t ino, Fh *fh = (Fh*)fi->fh; // must use multithread if operation may block - auto fuse_multithreaded = cfuse->client->cct->_conf->get_val<bool>( + auto fuse_multithreaded = cfuse->client->cct->_conf.get_val<bool>( "fuse_multithreaded"); if (!fuse_multithreaded && !(cmd & (LOCK_NB | LOCK_UN))) { fuse_reply_err(req, EDEADLK); @@ -956,7 +956,7 @@ static void do_init(void *data, fuse_conn_info *conn) Client *client = cfuse->client; #if !defined(__APPLE__) - auto fuse_default_permissions = client->cct->_conf->get_val<bool>( + auto fuse_default_permissions = client->cct->_conf.get_val<bool>( "fuse_default_permissions"); if (!fuse_default_permissions && client->ll_handle_umask()) { // apply umask in userspace if posix acl is enabled @@ -1093,17 +1093,17 @@ int CephFuse::Handle::init(int argc, const char *argv[]) newargv[newargc++] = argv[0]; newargv[newargc++] = "-f"; // stay in foreground - auto fuse_allow_other = client->cct->_conf->get_val<bool>( + auto fuse_allow_other = client->cct->_conf.get_val<bool>( "fuse_allow_other"); - auto fuse_default_permissions = client->cct->_conf->get_val<bool>( + auto fuse_default_permissions = client->cct->_conf.get_val<bool>( "fuse_default_permissions"); - auto fuse_big_writes = client->cct->_conf->get_val<bool>( + auto fuse_big_writes = client->cct->_conf.get_val<bool>( "fuse_big_writes"); - auto fuse_atomic_o_trunc = client->cct->_conf->get_val<bool>( + auto fuse_atomic_o_trunc = client->cct->_conf.get_val<bool>( "fuse_atomic_o_trunc"); - auto fuse_debug = client->cct->_conf->get_val<bool>( + auto fuse_debug = client->cct->_conf.get_val<bool>( "fuse_debug"); - auto fuse_max_write = client->cct->_conf->get_val<uint64_t>( + auto fuse_max_write = client->cct->_conf.get_val<uint64_t>( "fuse_max_write"); if (fuse_allow_other) { @@ -1179,7 +1179,7 @@ int CephFuse::Handle::start() struct client_callback_args args = { handle: this, - ino_cb: client->cct->_conf->get_val<bool>("fuse_use_invalidate_cb") ? + ino_cb: client->cct->_conf.get_val<bool>("fuse_use_invalidate_cb") ? ino_invalidate_cb : NULL, dentry_cb: dentry_invalidate_cb, switch_intr_cb: switch_interrupt_cb, @@ -1197,7 +1197,7 @@ int CephFuse::Handle::start() int CephFuse::Handle::loop() { - auto fuse_multithreaded = client->cct->_conf->get_val<bool>( + auto fuse_multithreaded = client->cct->_conf.get_val<bool>( "fuse_multithreaded"); if (fuse_multithreaded) { return fuse_session_loop_mt(se); diff --git a/src/common/TracepointProvider.cc b/src/common/TracepointProvider.cc index fbc7b22a471..be982b0bc2a 100644 --- a/src/common/TracepointProvider.cc +++ b/src/common/TracepointProvider.cc @@ -20,9 +20,9 @@ TracepointProvider::~TracepointProvider() { } void TracepointProvider::handle_conf_change( - const md_config_t *conf, const std::set<std::string> &changed) { + const ConfigProxy& conf, const std::set<std::string> &changed) { if (changed.count(m_config_keys[0])) { - verify_config(ConfigProxy{conf}); + verify_config(conf); } } diff --git a/src/common/TracepointProvider.h b/src/common/TracepointProvider.h index d0ff8c94971..644a05b540c 100644 --- a/src/common/TracepointProvider.h +++ b/src/common/TracepointProvider.h @@ -65,8 +65,8 @@ protected: const char** get_tracked_conf_keys() const override { return m_config_keys; } - void handle_conf_change(const md_config_t *conf, - const std::set <std::string> &changed) override; + void handle_conf_change(const ConfigProxy& conf, + const std::set <std::string> &changed) override; private: CephContext *m_cct; diff --git a/src/common/WorkQueue.cc b/src/common/WorkQueue.cc index 24cb697b83e..d4154c3afef 100644 --- a/src/common/WorkQueue.cc +++ b/src/common/WorkQueue.cc @@ -62,12 +62,12 @@ ThreadPool::~ThreadPool() delete[] _conf_keys; } -void ThreadPool::handle_conf_change(const md_config_t *conf, +void ThreadPool::handle_conf_change(const ConfigProxy& conf, const std::set <std::string> &changed) { if (changed.count(_thread_num_option)) { char *buf; - int r = conf->get_val(_thread_num_option.c_str(), &buf, -1); + int r = conf.get_val(_thread_num_option.c_str(), &buf, -1); assert(r >= 0); int v = atoi(buf); free(buf); diff --git a/src/common/WorkQueue.h b/src/common/WorkQueue.h index 61f5f481c10..9fbb9507275 100644 --- a/src/common/WorkQueue.h +++ b/src/common/WorkQueue.h @@ -90,7 +90,7 @@ private: const char **get_tracked_conf_keys() const override { return _conf_keys; } - void handle_conf_change(const md_config_t *conf, + void handle_conf_change(const ConfigProxy& conf, const std::set <std::string> &changed) override; public: diff --git a/src/common/ceph_context.cc b/src/common/ceph_context.cc index 5461e54991c..513d92ee011 100644 --- a/src/common/ceph_context.cc +++ b/src/common/ceph_context.cc @@ -61,12 +61,12 @@ public: return KEYS; } - void handle_conf_change(const md_config_t *conf, + void handle_conf_change(const ConfigProxy& conf, const std::set <std::string> &changed) override { - if (conf->values.lockdep && !m_registered) { + if (conf->lockdep && !m_registered) { lockdep_register_ceph_context(m_cct); m_registered = true; - } else if (!conf->values.lockdep && m_registered) { + } else if (!conf->lockdep && m_registered) { lockdep_unregister_ceph_context(m_cct); m_registered = false; } @@ -104,7 +104,7 @@ public: return KEYS; } - void handle_conf_change(const md_config_t *conf, + void handle_conf_change(const ConfigProxy& conf, const std::set <std::string> &changed) override { if (changed.count("mempool_debug")) { mempool::set_debug_mode(cct->_conf->mempool_debug); @@ -224,9 +224,8 @@ public: return KEYS; } - void handle_conf_change(const md_config_t *mconf, + void handle_conf_change(const ConfigProxy& conf, const std::set <std::string> &changed) override { - ConfigReader conf{mconf}; // stderr if (changed.count("log_to_stderr") || changed.count("err_to_stderr")) { int l = conf->log_to_stderr ? 99 : (conf->err_to_stderr ? -1 : -2); @@ -306,11 +305,10 @@ public: return KEYS; } - void handle_conf_change(const md_config_t *mconf, + void handle_conf_change(const ConfigProxy& conf, const std::set <std::string> &changed) override { if (changed.count( "enable_experimental_unrecoverable_data_corrupting_features")) { - ConfigReader conf{mconf}; std::lock_guard<ceph::spinlock> lg(cct->_feature_lock); get_str_set( conf->enable_experimental_unrecoverable_data_corrupting_features, diff --git a/src/common/common_init.h b/src/common/common_init.h index bd004b0e60e..1a4207b0ec7 100644 --- a/src/common/common_init.h +++ b/src/common/common_init.h @@ -54,8 +54,8 @@ enum common_init_flags_t { * the user asked for. * * This is usually done by something like this: - * cct->_conf->parse_env(); - * cct->_conf->apply_changes(); + * cct->_conf.parse_env(); + * cct->_conf.apply_changes(); * * Your library may also supply functions to read a configuration file. */ diff --git a/src/common/config.cc b/src/common/config.cc index ec0690682f4..1c8d47592ba 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -100,7 +100,8 @@ static int conf_stringify(const Option::value_t& v, string *out) namespace ceph::internal { template<LockPolicy lp> -md_config_impl<lp>::md_config_impl(bool is_daemon) +md_config_impl<lp>::md_config_impl(ConfigValues& values, + bool is_daemon) : is_daemon(is_daemon), lock("md_config_t", true, false) { @@ -205,13 +206,13 @@ md_config_impl<lp>::md_config_impl(bool is_daemon) if (val != *def_str) { // if the validator normalizes the string into a different form than // what was compiled in, use that. - set_val_default(opt.name, val); + set_val_default(values, opt.name, val); } } } // Copy out values (defaults) into any legacy (C struct member) fields - update_legacy_vals(); + update_legacy_vals(values); } template<LockPolicy lp> @@ -257,18 +258,21 @@ const Option *md_config_impl<lp>::find_option(const string& name) const } template<LockPolicy lp> -void md_config_impl<lp>::set_val_default(const string& name, const std::string& val) +void md_config_impl<lp>::set_val_default(ConfigValues& values, + const string& name, const std::string& val) { auto locker = lock(); const Option *o = find_option(name); assert(o); string err; - int r = _set_val(val, *o, CONF_DEFAULT, &err); + int r = _set_val(values, val, *o, CONF_DEFAULT, &err); assert(r >= 0); } template<LockPolicy lp> int md_config_impl<lp>::set_mon_vals(CephContext *cct, + ConfigValues& values, + const ConfigProxy& proxy, const map<string,string>& kv, config_callback config_cb) { @@ -297,7 +301,7 @@ int md_config_impl<lp>::set_mon_vals(CephContext *cct, continue; } std::string err; - int r = _set_val(i.second, *o, CONF_MON, &err); + int r = _set_val(values, i.second, *o, CONF_MON, &err); if (r < 0) { lderr(cct) << __func__ << " failed to set " << i.first << " = " << i.second << ": " << err << dendl; @@ -325,7 +329,7 @@ int md_config_impl<lp>::set_mon_vals(CephContext *cct, values.rm_val(name, CONF_MON); }); values_bl.clear(); - _apply_changes(nullptr); + _apply_changes(values, proxy, nullptr); return 0; } @@ -357,7 +361,8 @@ void md_config_impl<lp>::remove_observer(md_config_obs_impl<lp>* observer_) } template<LockPolicy lp> -int md_config_impl<lp>::parse_config_files(const char *conf_files_str, +int md_config_impl<lp>::parse_config_files(ConfigValues& values, + const char *conf_files_str, std::ostream *warnings, int flags) { @@ -396,7 +401,7 @@ int md_config_impl<lp>::parse_config_files(const char *conf_files_str, // useless $data_dir item, skip p = conf_files.erase(p); } else { - early_expand_meta(s, warnings); + early_expand_meta(values, s, warnings); ++p; } } @@ -437,14 +442,14 @@ int md_config_impl<lp>::parse_config_files(const char *conf_files_str, } std::vector <std::string> my_sections; - _get_my_sections(my_sections); + _get_my_sections(values, my_sections); for (const auto &i : schema) { const auto &opt = i.second; std::string val; int ret = _get_val_from_conf_file(my_sections, opt.name, val); if (ret == 0) { std::string error_message; - int r = _set_val(val, opt, CONF_FILE, &error_message); + int r = _set_val(values, val, opt, CONF_FILE, &error_message); if (warnings != nullptr && (r < 0 || !error_message.empty())) { *warnings << "parse error setting '" << opt.name << "' to '" << val << "'"; @@ -478,13 +483,13 @@ int md_config_impl<lp>::parse_config_files(const char *conf_files_str, cerr << ". Please use the new style section names that include a period."; } - update_legacy_vals(); + update_legacy_vals(values); return 0; } template<LockPolicy lp> -void md_config_impl<lp>::parse_env(const char *args_var) +void md_config_impl<lp>::parse_env(ConfigValues& values, const char *args_var) { if (safe_to_start_threads) return; @@ -493,7 +498,7 @@ void md_config_impl<lp>::parse_env(const char *args_var) } if (getenv("CEPH_KEYRING")) { auto locker = lock(); - _set_val(getenv("CEPH_KEYRING"), *find_option("keyring"), + _set_val(values, getenv("CEPH_KEYRING"), *find_option("keyring"), CONF_ENV, nullptr); } if (const char *dir = getenv("CEPH_LIB")) { @@ -502,28 +507,28 @@ void md_config_impl<lp>::parse_env(const char *args_var) std::string err; const Option *o = find_option(name); assert(o); - _set_val(dir, *o, CONF_ENV, &err); + _set_val(values, dir, *o, CONF_ENV, &err); } } if (getenv(args_var)) { vector<const char *> env_args; env_to_vec(env_args, args_var); - parse_argv(env_args, CONF_ENV); + parse_argv(values, env_args, CONF_ENV); } } template<LockPolicy lp> -void md_config_impl<lp>::show_config(std::ostream& out) +void md_config_impl<lp>::show_config(const ConfigValues& values, std::ostream& out) { auto locker = lock(); - _show_config(&out, NULL); + _show_config(values, &out, nullptr); } template<LockPolicy lp> -void md_config_impl<lp>::show_config(Formatter *f) +void md_config_impl<lp>::show_config(const ConfigValues& values, Formatter *f) { auto locker = lock(); - _show_config(NULL, f); + _show_config(values, nullptr, f); } template<LockPolicy lp> @@ -538,7 +543,8 @@ void md_config_impl<lp>::config_options(Formatter *f) } template<LockPolicy lp> -void md_config_impl<lp>::_show_config(std::ostream *out, Formatter *f) +void md_config_impl<lp>::_show_config(const ConfigValues& values, + std::ostream *out, Formatter *f) { if (out) { *out << "name = " << values.name << std::endl; @@ -551,7 +557,7 @@ void md_config_impl<lp>::_show_config(std::ostream *out, Formatter *f) for (const auto& i: schema) { const Option &opt = i.second; string val; - conf_stringify(_get_val(opt), &val); + conf_stringify(_get_val(values, opt), &val); if (out) { *out << opt.name << " = " << val << std::endl; } @@ -562,7 +568,8 @@ void md_config_impl<lp>::_show_config(std::ostream *out, Formatter *f) } template<LockPolicy lp> -int md_config_impl<lp>::parse_argv(std::vector<const char*>& args, int level) +int md_config_impl<lp>::parse_argv(ConfigValues& values, + std::vector<const char*>& args, int level) { auto locker = lock(); if (safe_to_start_threads) { @@ -597,26 +604,26 @@ int md_config_impl<lp>::parse_argv(std::vector<const char*>& args, int level) values.no_mon_config = false; } else if (ceph_argparse_flag(args, i, "--foreground", "-f", (char*)NULL)) { - set_val_or_die("daemonize", "false"); + set_val_or_die(values, "daemonize", "false"); } else if (ceph_argparse_flag(args, i, "-d", (char*)NULL)) { - set_val_or_die("daemonize", "false"); - set_val_or_die("log_file", ""); - set_val_or_die("log_to_stderr", "true"); - set_val_or_die("err_to_stderr", "true"); - set_val_or_die("log_to_syslog", "false"); + set_val_or_die(values, "daemonize", "false"); + set_val_or_die(values, "log_file", ""); + set_val_or_die(values, "log_to_stderr", "true"); + set_val_or_die(values, "err_to_stderr", "true"); + set_val_or_die(values, "log_to_syslog", "false"); } // Some stuff that we wanted to give universal single-character options for // Careful: you can burn through the alphabet pretty quickly by adding // to this list. else if (ceph_argparse_witharg(args, i, &val, "--monmap", "-M", (char*)NULL)) { - set_val_or_die("monmap", val.c_str()); + set_val_or_die(values, "monmap", val.c_str()); } else if (ceph_argparse_witharg(args, i, &val, "--mon_host", "-m", (char*)NULL)) { - set_val_or_die("mon_host", val.c_str()); + set_val_or_die(values, "mon_host", val.c_str()); } else if (ceph_argparse_witharg(args, i, &val, "--bind", (char*)NULL)) { - set_val_or_die("public_addr", val.c_str()); + set_val_or_die(values, "public_addr", val.c_str()); } else if (ceph_argparse_witharg(args, i, &val, "--keyfile", "-K", (char*)NULL)) { bufferlist bl; @@ -629,17 +636,17 @@ int md_config_impl<lp>::parse_argv(std::vector<const char*>& args, int level) } if (r >= 0) { string k(bl.c_str(), bl.length()); - set_val_or_die("key", k.c_str()); + set_val_or_die(values, "key", k.c_str()); } } else if (ceph_argparse_witharg(args, i, &val, "--keyring", "-k", (char*)NULL)) { - set_val_or_die("keyring", val.c_str()); + set_val_or_die(values, "keyring", val.c_str()); } else if (ceph_argparse_witharg(args, i, &val, "--client_mountpoint", "-r", (char*)NULL)) { - set_val_or_die("client_mountpoint", val.c_str()); + set_val_or_die(values, "client_mountpoint", val.c_str()); } else { - int r = parse_option(args, i, NULL, level); + int r = parse_option(values, args, i, NULL, level); if (r < 0) { return r; } @@ -649,18 +656,19 @@ int md_config_impl<lp>::parse_argv(std::vector<const char*>& args, int level) } template<LockPolicy lp> -void md_config_impl<lp>::do_argv_commands() +void md_config_impl<lp>::do_argv_commands(const ConfigValues& values) { auto locker = lock(); if (do_show_config) { - _show_config(&cout, NULL); + _show_config(values, &cout, NULL); _exit(0); } if (do_show_config_value.size()) { string val; - int r = conf_stringify(_get_val(do_show_config_value, 0, &cerr), &val); + int r = conf_stringify(_get_val(values, do_show_config_value, 0, &cerr), + &val); if (r < 0) { if (r == -ENOENT) std::cerr << "failed to get config option '" @@ -677,10 +685,11 @@ void md_config_impl<lp>::do_argv_commands() } template<LockPolicy lp> -int md_config_impl<lp>::parse_option(std::vector<const char*>& args, - std::vector<const char*>::iterator& i, - ostream *oss, - int level) +int md_config_impl<lp>::parse_option(ConfigValues& values, + std::vector<const char*>& args, + std::vector<const char*>::iterator& i, + ostream *oss, + int level) { int ret = 0; size_t o = 0; @@ -700,9 +709,9 @@ int md_config_impl<lp>::parse_option(std::vector<const char*>& args, if (ceph_argparse_binary_flag(args, i, &res, oss, as_option.c_str(), (char*)NULL)) { if (res == 0) - ret = _set_val("false", opt, level, &error_message); + ret = _set_val(values, "false", opt, level, &error_message); else if (res == 1) - ret = _set_val("true", opt, level, &error_message); + ret = _set_val(values, "true", opt, level, &error_message); else ret = res; break; @@ -710,7 +719,7 @@ int md_config_impl<lp>::parse_option(std::vector<const char*>& args, std::string no("--no-"); no += opt.name; if (ceph_argparse_flag(args, i, no.c_str(), (char*)NULL)) { - ret = _set_val("false", opt, level, &error_message); + ret = _set_val(values, "false", opt, level, &error_message); break; } } @@ -721,7 +730,7 @@ int md_config_impl<lp>::parse_option(std::vector<const char*>& args, ret = -EINVAL; break; } - ret = _set_val(val, opt, level, &error_message); + ret = _set_val(values, val, opt, level, &error_message); break; } ++o; @@ -754,13 +763,13 @@ int md_config_impl<lp>::parse_option(std::vector<const char*>& args, } template<LockPolicy lp> -int md_config_impl<lp>::parse_injectargs(std::vector<const char*>& args, +int md_config_impl<lp>::parse_injectargs(ConfigValues& values, + std::vector<const char*>& args, std::ostream *oss) { - assert(lock.is_locked()); int ret = 0; for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) { - int r = parse_option(args, i, oss, CONF_OVERRIDE); + int r = parse_option(values, args, i, oss, CONF_OVERRIDE); if (r < 0) ret = r; } @@ -768,25 +777,29 @@ int md_config_impl<lp>::parse_injectargs(std::vector<const char*>& args, } template<LockPolicy lp> -void md_config_impl<lp>::apply_changes(std::ostream *oss) +void md_config_impl<lp>::apply_changes(ConfigValues& values, + const ConfigProxy& proxy, + std::ostream *oss) { auto locker = lock(); /* * apply changes until the cluster name is assigned */ if (values.cluster.size()) - _apply_changes(oss); + _apply_changes(values, proxy, oss); } template<LockPolicy lp> -void md_config_impl<lp>::_apply_changes(std::ostream *oss) +void md_config_impl<lp>::_apply_changes(ConfigValues& values, + const ConfigProxy& proxy, + std::ostream *oss) { /* Maps observers to the configuration options that they care about which * have changed. */ typedef std::map < md_config_obs_t*, std::set <std::string> > rev_obs_map_t; // meta expands could have modified anything. Copy it all out again. - update_legacy_vals(); + update_legacy_vals(values); // create the reverse observer mapping, mapping observers to the set of // changed keys that they'll get. @@ -797,7 +810,7 @@ void md_config_impl<lp>::_apply_changes(std::ostream *oss) c != changed.end(); ++c) { const std::string &key(*c); auto [first, last] = observers.equal_range(key); - if ((oss) && !conf_stringify(_get_val(key), &val)) { + if ((oss) && !conf_stringify(_get_val(values, key), &val)) { (*oss) << key << " = '" << val << "' "; if (first == last) { (*oss) << "(not observed, change may require restart) "; @@ -816,13 +829,12 @@ void md_config_impl<lp>::_apply_changes(std::ostream *oss) // Make any pending observer callbacks for (rev_obs_map_t::const_iterator r = robs.begin(); r != robs.end(); ++r) { md_config_obs_t *obs = r->first; - obs->handle_conf_change(this, r->second); + obs->handle_conf_change(proxy, r->second); } - } template<LockPolicy lp> -void md_config_impl<lp>::call_all_observers() +void md_config_impl<lp>::call_all_observers(const ConfigProxy& proxy) { std::map<md_config_obs_t*,std::set<std::string> > obs; // Have the scope of the lock extend to the scope of @@ -842,7 +854,7 @@ void md_config_impl<lp>::call_all_observers() for (auto p = obs.begin(); p != obs.end(); ++p) { - p->first->handle_conf_change(this, p->second); + p->first->handle_conf_change(proxy, p->second); } } @@ -859,7 +871,9 @@ void md_config_impl<lp>::_clear_safe_to_start_threads() } template<LockPolicy lp> -int md_config_impl<lp>::injectargs(const std::string& s, std::ostream *oss) +int md_config_impl<lp>::injectargs(ConfigValues& values, + const ConfigProxy& proxy, + const std::string& s, std::ostream *oss) { int ret; auto locker = lock(); @@ -875,7 +889,7 @@ int md_config_impl<lp>::injectargs(const std::string& s, std::ostream *oss) *p++ = 0; while (*p && *p == ' ') p++; } - ret = parse_injectargs(nargs, oss); + ret = parse_injectargs(values, nargs, oss); if (!nargs.empty()) { *oss << " failed to parse arguments: "; std::string prefix; @@ -887,16 +901,17 @@ int md_config_impl<lp>::injectargs(const std::string& s, std::ostream *oss) *oss << "\n"; ret = -EINVAL; } - _apply_changes(oss); + _apply_changes(values, proxy, oss); return ret; } template<LockPolicy lp> -void md_config_impl<lp>::set_val_or_die(const std::string &key, - const std::string &val) +void md_config_impl<lp>::set_val_or_die(ConfigValues& values, + const std::string &key, + const std::string &val) { std::stringstream err; - int ret = set_val(key, val, &err); + int ret = set_val(values, key, val, &err); if (ret != 0) { std::cerr << "set_val_or_die(" << key << "): " << err.str(); } @@ -904,8 +919,9 @@ void md_config_impl<lp>::set_val_or_die(const std::string &key, } template<LockPolicy lp> -int md_config_impl<lp>::set_val(const std::string &key, const char *val, - std::stringstream *err_ss) +int md_config_impl<lp>::set_val(ConfigValues& values, + const std::string &key, const char *val, + std::stringstream *err_ss) { auto locker = lock(); if (key.empty()) { @@ -924,7 +940,7 @@ int md_config_impl<lp>::set_val(const std::string &key, const char *val, if (opt_iter != schema.end()) { const Option &opt = opt_iter->second; std::string error_message; - int r = _set_val(v, opt, CONF_OVERRIDE, &error_message); + int r = _set_val(values, v, opt, CONF_OVERRIDE, &error_message); if (r >= 0) { if (err_ss) *err_ss << "Set " << opt.name << " to " << v; r = 0; @@ -939,14 +955,15 @@ int md_config_impl<lp>::set_val(const std::string &key, const char *val, } template<LockPolicy lp> -int md_config_impl<lp>::rm_val(const std::string& key) +int md_config_impl<lp>::rm_val(ConfigValues& values, const std::string& key) { auto locker = lock(); - return _rm_val(key, CONF_OVERRIDE); + return _rm_val(values, key, CONF_OVERRIDE); } template<LockPolicy lp> -void md_config_impl<lp>::get_defaults_bl(bufferlist *bl) +void md_config_impl<lp>::get_defaults_bl(const ConfigValues& values, + bufferlist *bl) { auto locker = lock(); if (defaults_bl.length() == 0) { @@ -972,6 +989,7 @@ void md_config_impl<lp>::get_defaults_bl(bufferlist *bl) template<LockPolicy lp> void md_config_impl<lp>::get_config_bl( + const ConfigValues& values, uint64_t have_version, bufferlist *bl, uint64_t *got_version) @@ -1026,31 +1044,36 @@ void md_config_impl<lp>::get_config_bl( } template<LockPolicy lp> -int md_config_impl<lp>::get_val(const std::string &key, char **buf, int len) const +int md_config_impl<lp>::get_val(const ConfigValues& values, + const std::string &key, char **buf, int len) const { auto locker = lock(); string k(ConfFile::normalize_key_name(key)); - return _get_val_cstr(k, buf, len); + return _get_val_cstr(values, k, buf, len); } template<LockPolicy lp> int md_config_impl<lp>::get_val( + const ConfigValues& values, const std::string &key, std::string *val) const { - return conf_stringify(get_val_generic(key), val); + return conf_stringify(get_val_generic(values, key), val); } template<LockPolicy lp> -Option::value_t md_config_impl<lp>::get_val_generic(const std::string &key) const +Option::value_t md_config_impl<lp>::get_val_generic( + const ConfigValues& values, + const std::string &key) const { auto locker = lock(); string k(ConfFile::normalize_key_name(key)); - return _get_val(k); + return _get_val(values, k); } template<LockPolicy lp> Option::value_t md_config_impl<lp>::_get_val( + const ConfigValues& values, const std::string &key, expand_stack_t *stack, std::ostream *err) const @@ -1069,11 +1092,12 @@ Option::value_t md_config_impl<lp>::_get_val( return Option::value_t(boost::blank()); } - return _get_val(*o, stack, err); + return _get_val(values, *o, stack, err); } template<LockPolicy lp> Option::value_t md_config_impl<lp>::_get_val( + const ConfigValues& values, const Option& o, expand_stack_t *stack, std::ostream *err) const @@ -1082,11 +1106,14 @@ Option::value_t md_config_impl<lp>::_get_val( if (!stack) { stack = &a_stack; } - return _expand_meta(_get_val_nometa(o), &o, stack, err); + return _expand_meta(values, + _get_val_nometa(values, o), + &o, stack, err); } template<LockPolicy lp> -Option::value_t md_config_impl<lp>::_get_val_nometa(const Option& o) const +Option::value_t md_config_impl<lp>::_get_val_nometa(const ConfigValues& values, + const Option& o) const { if (auto [value, found] = values.get_value(o.name, -1); found) { return value; @@ -1108,29 +1135,33 @@ const Option::value_t& md_config_impl<lp>::_get_val_default(const Option& o) con template<LockPolicy lp> void md_config_impl<lp>::early_expand_meta( + const ConfigValues& values, std::string &val, std::ostream *err) const { auto locker = lock(); expand_stack_t stack; - Option::value_t v = _expand_meta(Option::value_t(val), nullptr, &stack, err); + Option::value_t v = _expand_meta(values, + Option::value_t(val), + nullptr, &stack, err); conf_stringify(v, &val); } template<LockPolicy lp> -void md_config_impl<lp>::finalize_reexpand_meta() +void md_config_impl<lp>::finalize_reexpand_meta(ConfigValues& values, + const ConfigProxy& proxy) { - auto locker = lock(); for (auto &i : may_reexpand_meta) { - set_val(i.first, i.second); + set_val(values, i.first, i.second); } if (may_reexpand_meta.size()) - _apply_changes(NULL); + _apply_changes(values, proxy, NULL); } template<LockPolicy lp> Option::value_t md_config_impl<lp>::_expand_meta( + const ConfigValues& values, const Option::value_t& in, const Option *o, expand_stack_t *stack, @@ -1245,7 +1276,7 @@ Option::value_t md_config_impl<lp>::_expand_meta( } else { // recursively evaluate! string n; - conf_stringify(_get_val(*o, stack, err), &n); + conf_stringify(_get_val(values, *o, stack, err), &n); out += n; } } @@ -1265,6 +1296,7 @@ Option::value_t md_config_impl<lp>::_expand_meta( template<LockPolicy lp> int md_config_impl<lp>::_get_val_cstr( + const ConfigValues& values, const std::string &key, char **buf, int len) const { assert(lock.is_locked()); @@ -1273,7 +1305,7 @@ int md_config_impl<lp>::_get_val_cstr( return -EINVAL; string val; - if (conf_stringify(_get_val(key), &val) == 0) { + if (conf_stringify(_get_val(values, key), &val) == 0) { int l = val.length() + 1; if (len == -1) { *buf = (char*)malloc(l); @@ -1313,14 +1345,16 @@ void md_config_impl<lp>::get_all_keys(std::vector<std::string> *keys) const { * others had nothing. This should always be the global section. */ template<LockPolicy lp> -void md_config_impl<lp>::get_my_sections(std::vector <std::string> §ions) const +void md_config_impl<lp>::get_my_sections(const ConfigValues& values, + std::vector <std::string> §ions) const { auto locker = lock(); - _get_my_sections(sections); + _get_my_sections(values, sections); } template<LockPolicy lp> -void md_config_impl<lp>::_get_my_sections(std::vector <std::string> §ions) const +void md_config_impl<lp>::_get_my_sections(const ConfigValues& values, + std::vector <std::string> §ions) const { assert(lock.is_locked()); sections.push_back(values.name.to_str()); @@ -1344,6 +1378,7 @@ int md_config_impl<lp>::get_all_sections(std::vector <std::string> §ions) co template<LockPolicy lp> int md_config_impl<lp>::get_val_from_conf_file( + const ConfigValues& values, const std::vector <std::string> §ions, const std::string &key, std::string &out, @@ -1356,7 +1391,7 @@ int md_config_impl<lp>::get_val_from_conf_file( } if (emeta) { expand_stack_t stack; - auto v = _expand_meta(Option::value_t(out), nullptr, &stack, nullptr); + auto v = _expand_meta(values, Option::value_t(out), nullptr, &stack, nullptr); conf_stringify(v, &out); } return 0; @@ -1384,6 +1419,7 @@ int md_config_impl<lp>::_get_val_from_conf_file( template<LockPolicy lp> int md_config_impl<lp>::_set_val( + ConfigValues& values, const std::string &raw_val, const Option &opt, int level, @@ -1402,7 +1438,7 @@ int md_config_impl<lp>::_set_val( safe_to_start_threads && observers.count(opt.name) == 0) { // accept value if it is not actually a change - if (new_value != _get_val_nometa(opt)) { + if (new_value != _get_val_nometa(values, opt)) { *error_message = string("Configuration option '") + opt.name + "' may not be modified at runtime"; return -ENOSYS; @@ -1421,23 +1457,23 @@ int md_config_impl<lp>::_set_val( // fallthrough default: values_bl.clear(); - _refresh(opt); + _refresh(values, opt); return 1; } } template<LockPolicy lp> -void md_config_impl<lp>::_refresh(const Option& opt) +void md_config_impl<lp>::_refresh(ConfigValues& values, const Option& opt) { // Apply the value to its legacy field, if it has one auto legacy_ptr_iter = legacy_values.find(std::string(opt.name)); if (legacy_ptr_iter != legacy_values.end()) { - update_legacy_val(opt, legacy_ptr_iter->second); + update_legacy_val(values, opt, legacy_ptr_iter->second); } // Was this a debug_* option update? if (opt.subsys >= 0) { string actual_val; - conf_stringify(_get_val(opt), &actual_val); + conf_stringify(_get_val(values, opt), &actual_val); values.set_logging(opt.subsys, actual_val.c_str()); } else { // normal option, advertise the change. @@ -1446,7 +1482,9 @@ void md_config_impl<lp>::_refresh(const Option& opt) } template<LockPolicy lp> -int md_config_impl<lp>::_rm_val(const std::string& key, int level) +int md_config_impl<lp>::_rm_val(ConfigValues& values, + const std::string& key, + int level) { if (schema.count(key) == 0) { return -EINVAL; @@ -1456,7 +1494,7 @@ int md_config_impl<lp>::_rm_val(const std::string& key, int level) return ret; } if (ret == ConfigValues::SET_HAVE_EFFECT) { - _refresh(*find_option(key)); + _refresh(values, *find_option(key)); } values_bl.clear(); return 0; @@ -1515,21 +1553,22 @@ class assign_visitor : public boost::static_visitor<> } // anonymous namespace template<LockPolicy lp> -void md_config_impl<lp>::update_legacy_vals() +void md_config_impl<lp>::update_legacy_vals(ConfigValues& values) { for (const auto &i : legacy_values) { const auto &name = i.first; const auto &option = schema.at(name); auto ptr = i.second; - update_legacy_val(option, ptr); + update_legacy_val(values, option, ptr); } } template<LockPolicy lp> -void md_config_impl<lp>::update_legacy_val(const Option &opt, +void md_config_impl<lp>::update_legacy_val(ConfigValues& values, + const Option &opt, md_config_impl::member_ptr_t member_ptr) { - Option::value_t v = _get_val(opt); + Option::value_t v = _get_val(values, opt); boost::apply_visitor(assign_visitor(&values, v), member_ptr); } @@ -1550,11 +1589,12 @@ static void dump(Formatter *f, int level, Option::value_t in) template<LockPolicy lp> void md_config_impl<lp>::diff( + const ConfigValues& values, Formatter *f, string name) const { auto locker = lock(); - values.for_each([this, f] (auto& name, auto& configs) { + values.for_each([this, f, &values] (auto& name, auto& configs) { if (configs.size() == 1 && configs.begin()->first == CONF_DEFAULT) { // we only have a default value; exclude from diff @@ -1566,7 +1606,7 @@ void md_config_impl<lp>::diff( for (auto& j : configs) { dump(f, j.first, j.second); } - dump(f, CONF_FINAL, _get_val(*o)); + dump(f, CONF_FINAL, _get_val(values, *o)); f->close_section(); }); } diff --git a/src/common/config.h b/src/common/config.h index d6bef2b81f2..94500ce1ecd 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -109,11 +109,6 @@ public: */ std::map<std::string, const Option&> schema; - /** - * The current values of all settings described by the schema - */ - ConfigValues values; - /// values from mon that we failed to set std::map<std::string,std::string> ignored_mon_values; @@ -135,7 +130,7 @@ public: } opt_type_t; // Create a new md_config_t structure. - explicit md_config_impl(bool is_daemon=false); + explicit md_config_impl(ConfigValues& values, bool is_daemon=false); ~md_config_impl(); // Adds a new observer to this configuration. You can do this at any time, @@ -156,23 +151,26 @@ public: void remove_observer(md_config_obs_impl<lock_policy>* observer_); // Parse a config file - int parse_config_files(const char *conf_files, + int parse_config_files(ConfigValues& values, const char *conf_files, std::ostream *warnings, int flags); // Absorb config settings from the environment - void parse_env(const char *env_var = "CEPH_ARGS"); + void parse_env(ConfigValues& values, const char *env_var = "CEPH_ARGS"); // Absorb config settings from argv - int parse_argv(std::vector<const char*>& args, int level=CONF_CMDLINE); + int parse_argv(ConfigValues& values, + std::vector<const char*>& args, int level=CONF_CMDLINE); // do any commands we got from argv (--show-config, --show-config-val) - void do_argv_commands(); + void do_argv_commands(const ConfigValues& values); // Expand all metavariables. Make any pending observer callbacks. - void apply_changes(std::ostream *oss); - void _apply_changes(std::ostream *oss); + void apply_changes(ConfigValues& values, const ConfigProxy& proxy, + std::ostream *oss); + void _apply_changes(ConfigValues& values, const ConfigProxy& proxy, + std::ostream *oss); bool _internal_field(const string& k); - void call_all_observers(); + void call_all_observers(const ConfigProxy& proxy); void set_safe_to_start_threads(); void _clear_safe_to_start_threads(); // this is only used by the unit test @@ -181,77 +179,87 @@ public: const Option *find_option(const string& name) const; /// Set a default value - void set_val_default(const std::string& key, const std::string &val); + void set_val_default(ConfigValues& values, + const std::string& key, const std::string &val); /// Set a values from mon int set_mon_vals(CephContext *cct, + ConfigValues& values, + const ConfigProxy& proxy, const map<std::string,std::string>& kv, config_callback config_cb); // Called by the Ceph daemons to make configuration changes at runtime - int injectargs(const std::string &s, std::ostream *oss); + int injectargs(ConfigValues& values, const ConfigProxy& proxy, + const std::string &s, std::ostream *oss); // Set a configuration value, or crash // Metavariables will be expanded. - void set_val_or_die(const std::string &key, const std::string &val); + void set_val_or_die(ConfigValues& values, const std::string &key, const std::string &val); // Set a configuration value. // Metavariables will be expanded. - int set_val(const std::string &key, const char *val, + int set_val(ConfigValues& values, const std::string &key, const char *val, std::stringstream *err_ss=nullptr); - int set_val(const std::string &key, const string& s, + int set_val(ConfigValues& values, const std::string &key, const string& s, std::stringstream *err_ss=nullptr) { - return set_val(key, s.c_str(), err_ss); + return set_val(values, key, s.c_str(), err_ss); } /// clear override value - int rm_val(const std::string& key); + int rm_val(ConfigValues& values, const std::string& key); /// get encoded map<string,map<int32_t,string>> of entire config - void get_config_bl(uint64_t have_version, + void get_config_bl(const ConfigValues& values, + uint64_t have_version, bufferlist *bl, uint64_t *got_version); /// get encoded map<string,string> of compiled-in defaults - void get_defaults_bl(bufferlist *bl); + void get_defaults_bl(const ConfigValues& values, bufferlist *bl); // Get a configuration value. // No metavariables will be returned (they will have already been expanded) - int get_val(const std::string &key, char **buf, int len) const; - int get_val(const std::string &key, std::string *val) const; - Option::value_t get_val_generic(const std::string &key) const; - template<typename T> const T get_val(const std::string &key) const; + int get_val(const ConfigValues& values, const std::string &key, char **buf, int len) const; + int get_val(const ConfigValues& values, const std::string &key, std::string *val) const; + Option::value_t get_val_generic(const ConfigValues& values, const std::string &key) const; + template<typename T> const T get_val(const ConfigValues& values, const std::string &key) const; template<typename T, typename Callback, typename...Args> - auto with_val(const string& key, Callback&& cb, Args&&... args) const -> + auto with_val(const ConfigValues& values, const string& key, + Callback&& cb, Args&&... args) const -> std::result_of_t<Callback(const T&, Args...)> { return std::forward<Callback>(cb)( - boost::get<T>(this->get_val_generic(key)), + boost::get<T>(this->get_val_generic(values, key)), std::forward<Args>(args)...); } void get_all_keys(std::vector<std::string> *keys) const; // Return a list of all the sections that the current entity is a member of. - void get_my_sections(std::vector <std::string> §ions) const; + void get_my_sections(const ConfigValues& values, + std::vector <std::string> §ions) const; // Return a list of all sections int get_all_sections(std::vector <std::string> §ions) const; // Get a value from the configuration file that we read earlier. // Metavariables will be expanded if emeta is true. - int get_val_from_conf_file(const std::vector <std::string> §ions, + int get_val_from_conf_file(const ConfigValues& values, + const std::vector <std::string> §ions, std::string const &key, std::string &out, bool emeta) const; /// dump all config values to a stream - void show_config(std::ostream& out); + void show_config(const ConfigValues& values, std::ostream& out); /// dump all config values to a formatter - void show_config(Formatter *f); + void show_config(const ConfigValues& values, Formatter *f); /// dump all config settings to a formatter void config_options(Formatter *f); /// dump config diff from default, conf, mon, etc. - void diff(Formatter *f, std::string name=string{}) const; + void diff(const ConfigValues& values, + Formatter *f, + std::string name=string{}) const; /// print/log warnings/errors from parsing the config void complain_about_parse_errors(CephContext *cct); @@ -265,35 +273,44 @@ private: void validate_schema(); void validate_default_settings(); - int _get_val_cstr(const std::string &key, char **buf, int len) const; - Option::value_t _get_val(const std::string &key, + int _get_val_cstr(const ConfigValues& values, + const std::string &key, char **buf, int len) const; + Option::value_t _get_val(const ConfigValues& values, + const std::string &key, expand_stack_t *stack=0, std::ostream *err=0) const; - Option::value_t _get_val(const Option& o, + Option::value_t _get_val(const ConfigValues& values, + const Option& o, expand_stack_t *stack=0, std::ostream *err=0) const; const Option::value_t& _get_val_default(const Option& o) const; - Option::value_t _get_val_nometa(const Option& o) const; + Option::value_t _get_val_nometa(const ConfigValues& values, + const Option& o) const; - int _rm_val(const std::string& key, int level); + int _rm_val(ConfigValues& values, const std::string& key, int level); - void _refresh(const Option& opt); + void _refresh(ConfigValues& values, const Option& opt); - void _show_config(std::ostream *out, Formatter *f); + void _show_config(const ConfigValues& values, + std::ostream *out, Formatter *f); - void _get_my_sections(std::vector <std::string> §ions) const; + void _get_my_sections(const ConfigValues& values, + std::vector <std::string> §ions) const; int _get_val_from_conf_file(const std::vector <std::string> §ions, const std::string &key, std::string &out) const; - int parse_option(std::vector<const char*>& args, + int parse_option(ConfigValues& values, + std::vector<const char*>& args, std::vector<const char*>::iterator& i, std::ostream *oss, int level); - int parse_injectargs(std::vector<const char*>& args, - std::ostream *oss); + int parse_injectargs(ConfigValues& values, + std::vector<const char*>& args, + std::ostream *oss); int _set_val( + ConfigValues& values, const std::string &val, const Option &opt, int level, // CONF_* @@ -303,21 +320,25 @@ private: void assign_member(member_ptr_t ptr, const Option::value_t &val); - void update_legacy_vals(); - void update_legacy_val(const Option &opt, member_ptr_t member); + void update_legacy_vals(ConfigValues& values); + void update_legacy_val(ConfigValues& values, + const Option &opt, + member_ptr_t member); Option::value_t _expand_meta( + const ConfigValues& values, const Option::value_t& in, const Option *o, expand_stack_t *stack, std::ostream *err) const; public: // for global_init - void early_expand_meta(std::string &val, + void early_expand_meta(const ConfigValues& values, + std::string &val, std::ostream *oss) const; // for those want to reexpand special meta, e.g, $pid - void finalize_reexpand_meta(); + void finalize_reexpand_meta(ConfigValues& values, const ConfigProxy& proxy); private: /// expand all metavariables in config structure. @@ -345,9 +366,9 @@ public: string data_dir_option; ///< data_dir config option, if any public: - unsigned get_osd_pool_default_min_size() const { - auto min_size = get_val<uint64_t>("osd_pool_default_min_size"); - auto size = get_val<uint64_t>("osd_pool_default_size"); + unsigned get_osd_pool_default_min_size(const ConfigValues& values) const { + auto min_size = get_val<uint64_t>(values, "osd_pool_default_min_size"); + auto size = get_val<uint64_t>(values, "osd_pool_default_size"); return min_size ? std::min(min_size, size) : (size - size / 2); } @@ -362,8 +383,9 @@ public: template<LockPolicy lp> template<typename T> -const T md_config_impl<lp>::get_val(const std::string &key) const { - return boost::get<T>(this->get_val_generic(key)); +const T md_config_impl<lp>::get_val(const ConfigValues& values, + const std::string &key) const { + return boost::get<T>(this->get_val_generic(values, key)); } } // namespace ceph::internal diff --git a/src/common/config_cacher.h b/src/common/config_cacher.h index cbd5746fd56..a84bad08eee 100644 --- a/src/common/config_cacher.h +++ b/src/common/config_cacher.h @@ -29,10 +29,10 @@ class md_config_cacher_t : public md_config_obs_t { return keys; } - void handle_conf_change(const md_config_t* conf, + void handle_conf_change(const ConfigProxy& conf, const std::set<std::string>& changed) override { if (changed.count(option_name)) { - value_cache.store(conf->get_val<ValueT>(option_name)); + value_cache.store(conf.get_val<ValueT>(option_name)); } } diff --git a/src/common/config_obs.h b/src/common/config_obs.h index fad03b130d4..c32e4469207 100644 --- a/src/common/config_obs.h +++ b/src/common/config_obs.h @@ -38,10 +38,10 @@ public: * Note that it is not possible to change the set of tracked keys without re-subscribing. */ virtual const char** get_tracked_conf_keys() const = 0; /// React to a configuration change. - virtual void handle_conf_change(const md_config_impl<lp>* conf, + virtual void handle_conf_change(const ConfigProxy& conf, const std::set <std::string> &changed) = 0; /// Unused for now - virtual void handle_subsys_change(const md_config_impl<lp>* conf, + virtual void handle_subsys_change(const ConfigProxy& conf, const std::set<int>& changed) { } }; } diff --git a/src/common/config_proxy.h b/src/common/config_proxy.h index 71224fca694..29d208280c8 100644 --- a/src/common/config_proxy.h +++ b/src/common/config_proxy.h @@ -8,33 +8,36 @@ #include "common/config.h" #include "common/config_fwd.h" -template<bool is_const> -class ConfigProxyBase { -protected: - using config_t = std::conditional_t<is_const, - const md_config_t, - md_config_t>; - config_t* config; - ConfigProxyBase(config_t* c) - : config{c} - {} +class ConfigProxy { + /** + * The current values of all settings described by the schema + */ + + ConfigValues values; + std::unique_ptr<md_config_t> config; public: + explicit ConfigProxy(bool is_daemon) + : config{std::make_unique<md_config_t>(values, is_daemon)} + {} const ConfigValues* operator->() const noexcept { - return &config->values; + return &values; + } + ConfigValues* operator->() noexcept { + return &values; } int get_val(const std::string& key, char** buf, int len) const { - return config->get_val(key, buf, len); + return config->get_val(values, key, buf, len); } int get_val(const std::string &key, std::string *val) const { - return config->get_val(key, val); + return config->get_val(values, key, val); } template<typename T> const T get_val(const std::string& key) const { - return config->template get_val<T>(key); + return config->template get_val<T>(values, key); } template<typename T, typename Callback, typename...Args> auto with_val(const string& key, Callback&& cb, Args&&... args) const { - return config->template with_val<T>(key, std::forward<Callback>(cb), + return config->template with_val<T>(values, key, std::forward<Callback>(cb), std::forward<Args>(args)...); } const Option* get_schema(const std::string& key) const { @@ -49,10 +52,10 @@ public: return config->find_option(name); } void diff(Formatter *f, const std::string& name=string{}) const { - return config->diff(f, name); + return config->diff(values, f, name); } void get_my_sections(std::vector <std::string> §ions) const { - config->get_my_sections(sections); + config->get_my_sections(values, sections); } int get_all_sections(std::vector<std::string>& sections) const { return config->get_all_sections(sections); @@ -60,32 +63,17 @@ public: int get_val_from_conf_file(const std::vector<std::string>& sections, const std::string& key, std::string& out, bool emeta) const { - return config->get_val_from_conf_file(sections, key, out, emeta); + return config->get_val_from_conf_file(values, sections, key, out, emeta); } unsigned get_osd_pool_default_min_size() const { - return config->get_osd_pool_default_min_size(); + return config->get_osd_pool_default_min_size(values); } void early_expand_meta(std::string &val, std::ostream *oss) const { - return config->early_expand_meta(val, oss); + return config->early_expand_meta(values, val, oss); } -}; - -class ConfigReader final : public ConfigProxyBase<true> { -public: - explicit ConfigReader(const md_config_t* config) - : ConfigProxyBase<true>{config} - {} -}; - -class ConfigProxy final : public ConfigProxyBase<false> { - std::unique_ptr<md_config_t> conf; -public: - explicit ConfigProxy(bool is_daemon) - : ConfigProxyBase{nullptr}, - conf{std::make_unique<md_config_t>(is_daemon)} - { - config = conf.get(); + void finalize_reexpand_meta() { + config->finalize_reexpand_meta(values, *this); } void add_observer(md_config_obs_t* obs) { config->add_observer(obs); @@ -100,63 +88,66 @@ public: config->_clear_safe_to_start_threads(); } void call_all_observers() { - config->call_all_observers(); + config->call_all_observers(*this); } void show_config(std::ostream& out) { - config->show_config(out); + config->show_config(values, out); } void show_config(Formatter *f) { - config->show_config(f); + config->show_config(values, f); } void config_options(Formatter *f) { config->config_options(f); } int rm_val(const std::string& key) { - return config->rm_val(key); + return config->rm_val(values, key); } void apply_changes(std::ostream* oss) { - config->apply_changes(oss); + config->apply_changes(values, *this, oss); } int set_val(const std::string& key, const string& s, std::stringstream* err_ss=nullptr) { - return config->set_val(key, s, err_ss); + return config->set_val(values, key, s, err_ss); } void set_val_default(const std::string& key, const std::string& val) { - config->set_val_default(key, val); + config->set_val_default(values, key, val); } void set_val_or_die(const std::string& key, const std::string& val) { - config->set_val_or_die(key, val); + config->set_val_or_die(values, key, val); } int set_mon_vals(CephContext *cct, const map<std::string,std::string>& kv, md_config_t::config_callback config_cb) { - return config->set_mon_vals(cct, kv, config_cb); + return config->set_mon_vals(cct, values, *this, kv, config_cb); } int injectargs(const std::string &s, std::ostream *oss) { - return config->injectargs(s, oss); + return config->injectargs(values, *this, s, oss); } void parse_env(const char *env_var = "CEPH_ARGS") { - config->parse_env(env_var); + config->parse_env(values, env_var); } int parse_argv(std::vector<const char*>& args, int level=CONF_CMDLINE) { - return config->parse_argv(args, level); + return config->parse_argv(values, args, level); } int parse_config_files(const char *conf_files, std::ostream *warnings, int flags) { - return config->parse_config_files(conf_files, warnings, flags); + return config->parse_config_files(values, conf_files, warnings, flags); + } + size_t num_parse_errors() const { + return config->parse_errors.size(); } void complain_about_parse_errors(CephContext *cct) { return config->complain_about_parse_errors(cct); } void do_argv_commands() { - config->do_argv_commands(); + config->do_argv_commands(values); } void get_config_bl(uint64_t have_version, bufferlist *bl, uint64_t *got_version) { - config->get_config_bl(have_version, bl, got_version); + config->get_config_bl(values, have_version, bl, got_version); } void get_defaults_bl(bufferlist *bl) { - config->get_defaults_bl(bl); + config->get_defaults_bl(values, bl); } }; diff --git a/src/common/pick_address.cc b/src/common/pick_address.cc index 5a5af3728d2..dc3365670b8 100644 --- a/src/common/pick_address.cc +++ b/src/common/pick_address.cc @@ -123,7 +123,7 @@ struct Observer : public md_config_obs_t { const char** get_tracked_conf_keys() const override { return (const char **)keys; } - void handle_conf_change(const md_config_t *conf, + void handle_conf_change(const ConfigProxy& conf, const std::set <std::string> &changed) override { // do nothing. } diff --git a/src/global/global_init.cc b/src/global/global_init.cc index 39989e895cd..37f5d8f9770 100644 --- a/src/global/global_init.cc +++ b/src/global/global_init.cc @@ -305,7 +305,7 @@ global_init(const std::map<std::string,std::string> *defaults, #endif // Expand metavariables. Invoke configuration observers. Open log file. - g_conf().apply_changes(NULL); + g_conf().apply_changes(nullptr); if (g_conf()->run_dir.length() && code_env == CODE_ENVIRONMENT_DAEMON && diff --git a/src/global/signal_handler.cc b/src/global/signal_handler.cc index b36d41b880d..5af31c28df2 100644 --- a/src/global/signal_handler.cc +++ b/src/global/signal_handler.cc @@ -195,7 +195,7 @@ static void handle_fatal_signal(int signum) jf.open_object_section("crash"); jf.dump_string("crash_id", id); now.gmtime(jf.dump_stream("timestamp")); - jf.dump_string("entity_name", g_ceph_context->_conf.name().to_str()); + jf.dump_string("entity_name", g_ceph_context->_conf->name.to_str()); jf.dump_string("ceph_version", ceph_version_to_str()); struct utsname u; diff --git a/src/librbd/ImageCtx.cc b/src/librbd/ImageCtx.cc index 17c283559b6..48f98b12331 100644 --- a/src/librbd/ImageCtx.cc +++ b/src/librbd/ImageCtx.cc @@ -778,7 +778,7 @@ public: "rbd_qos_read_bps_limit", false)( "rbd_qos_write_bps_limit", false); - md_config_t local_config_t; + ConfigProxy local_config_t{false}; std::map<std::string, bufferlist> res; _filter_metadata_confs(METADATA_CONF_PREFIX, configs, meta, &res); diff --git a/src/librbd/Operations.cc b/src/librbd/Operations.cc index abd70c7063b..7c9e29ddcd8 100644 --- a/src/librbd/Operations.cc +++ b/src/librbd/Operations.cc @@ -1414,7 +1414,7 @@ int Operations<I>::metadata_set(const std::string &key, bool config_override = util::is_metadata_config_override(key, &config_key); if (config_override) { // validate config setting - int r = md_config_t().set_val(config_key.c_str(), value); + int r = ConfigProxy{false}.set_val(config_key.c_str(), value); if (r < 0) { return r; } diff --git a/src/mds/CInode.h b/src/mds/CInode.h index 6ca3267e3ae..083ddfb00e2 100644 --- a/src/mds/CInode.h +++ b/src/mds/CInode.h @@ -551,7 +551,7 @@ public: CDir* get_dirfrag(frag_t fg) { auto pi = dirfrags.find(fg); if (pi != dirfrags.end()) { - //assert(g_conf->debug_mds < 2 || dirfragtree.is_leaf(fg)); // performance hack FIXME + //assert(g_conf()->debug_mds < 2 || dirfragtree.is_leaf(fg)); // performance hack FIXME return pi->second; } return NULL; diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index e3bbe16c335..c50ea99db24 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -7657,10 +7657,10 @@ void MDCache::shutdown_check() char *o = old_val; g_conf().get_val("debug_mds", &o, sizeof(old_val)); g_conf().set_val("debug_mds", "10"); - g_conf().apply_changes(NULL); + g_conf().apply_changes(nullptr); show_cache(); g_conf().set_val("debug_mds", old_val); - g_conf().apply_changes(NULL); + g_conf().apply_changes(nullptr); mds->timer.add_event_after(g_conf()->mds_shutdown_check, new C_MDC_ShutdownCheck(this)); // this diff --git a/src/mds/MDSCacheObject.h b/src/mds/MDSCacheObject.h index 147ee133472..e66fcca35c2 100644 --- a/src/mds/MDSCacheObject.h +++ b/src/mds/MDSCacheObject.h @@ -329,7 +329,7 @@ protected: waiting->insert(pair<uint64_t, pair<uint64_t, MDSInternalContextBase*> >( mask, pair<uint64_t, MDSInternalContextBase*>(seq, c))); -// pdout(10,g_conf->debug_mds) << (mdsco_db_line_prefix(this)) +// pdout(10,g_conf()->debug_mds) << (mdsco_db_line_prefix(this)) // << "add_waiter " << hex << mask << dec << " " << c // << " on " << *this // << dendl; @@ -348,14 +348,14 @@ protected: } else { ls.push_back(it->second.second); } -// pdout(10,g_conf->debug_mds) << (mdsco_db_line_prefix(this)) +// pdout(10,g_conf()->debug_mds) << (mdsco_db_line_prefix(this)) // << "take_waiting mask " << hex << mask << dec << " took " << it->second // << " tag " << hex << it->first << dec // << " on " << *this // << dendl; waiting->erase(it++); } else { -// pdout(10,g_conf->debug_mds) << "take_waiting mask " << hex << mask << dec << " SKIPPING " << it->second +// pdout(10,g_conf()->debug_mds) << "take_waiting mask " << hex << mask << dec << " SKIPPING " << it->second // << " tag " << hex << it->first << dec // << " on " << *this // << dendl; diff --git a/src/mds/MDSDaemon.cc b/src/mds/MDSDaemon.cc index a250de9e5b6..30ddc93e5c4 100644 --- a/src/mds/MDSDaemon.cc +++ b/src/mds/MDSDaemon.cc @@ -365,7 +365,7 @@ const char** MDSDaemon::get_tracked_conf_keys() const return KEYS; } -void MDSDaemon::handle_conf_change(const md_config_t *mconf, +void MDSDaemon::handle_conf_change(const ConfigProxy& conf, const std::set <std::string> &changed) { // We may be called within mds_lock (via `tell`) or outwith the @@ -375,7 +375,6 @@ void MDSDaemon::handle_conf_change(const md_config_t *mconf, mds_lock.Lock(); } - ConfigReader conf{mconf}; if (changed.count("mds_op_complaint_time") || changed.count("mds_op_log_threshold")) { if (mds_rank) { @@ -416,7 +415,7 @@ void MDSDaemon::handle_conf_change(const md_config_t *mconf, } if (mds_rank) { - mds_rank->handle_conf_change(mconf, changed); + mds_rank->handle_conf_change(conf, changed); } if (!initially_locked) { diff --git a/src/mds/MDSDaemon.h b/src/mds/MDSDaemon.h index be192f5dd15..93d59008a18 100644 --- a/src/mds/MDSDaemon.h +++ b/src/mds/MDSDaemon.h @@ -94,7 +94,7 @@ class MDSDaemon : public Dispatcher, public md_config_obs_t { // config observer bits const char** get_tracked_conf_keys() const override; - void handle_conf_change(const md_config_t *conf, + void handle_conf_change(const ConfigProxy& conf, const std::set <std::string> &changed) override; protected: // tick and other timer fun diff --git a/src/mds/MDSRank.h b/src/mds/MDSRank.h index dca36a51384..dab99d5b6fe 100644 --- a/src/mds/MDSRank.h +++ b/src/mds/MDSRank.h @@ -221,7 +221,7 @@ class MDSRank { void handle_write_error(int err); - void handle_conf_change(const md_config_t *conf, + void handle_conf_change(const ConfigProxy& conf, const std::set <std::string> &changed) { mdcache->migrator->handle_conf_change(conf, changed, *mdsmap); diff --git a/src/mds/Migrator.cc b/src/mds/Migrator.cc index 4e6d9dd81f2..fa79c0456d9 100644 --- a/src/mds/Migrator.cc +++ b/src/mds/Migrator.cc @@ -3438,12 +3438,12 @@ void Migrator::logged_import_caps(CInode *in, in->auth_unpin(this); } -void Migrator::handle_conf_change(const md_config_t* conf, +void Migrator::handle_conf_change(const ConfigProxy& conf, const std::set <std::string> &changed, const MDSMap &mds_map) { if (changed.count("mds_inject_migrator_session_race")) { - inject_session_race = conf->get_val<bool>("mds_inject_migrator_session_race"); + inject_session_race = conf.get_val<bool>("mds_inject_migrator_session_race"); dout(0) << "mds_inject_migrator_session_race is " << inject_session_race << dendl; } } diff --git a/src/mds/Migrator.h b/src/mds/Migrator.h index b0399b72b1b..ee2509b6e25 100644 --- a/src/mds/Migrator.h +++ b/src/mds/Migrator.h @@ -106,7 +106,7 @@ public: inject_session_race = g_conf().get_val<bool>("mds_inject_migrator_session_race"); } - void handle_conf_change(const md_config_t *conf, + void handle_conf_change(const ConfigProxy& conf, const std::set <std::string> &changed, const MDSMap &mds_map); diff --git a/src/mds/PurgeQueue.cc b/src/mds/PurgeQueue.cc index 60012db79c4..c71a5bc5d33 100644 --- a/src/mds/PurgeQueue.cc +++ b/src/mds/PurgeQueue.cc @@ -590,7 +590,7 @@ void PurgeQueue::update_op_limit(const MDSMap &mds_map) } } -void PurgeQueue::handle_conf_change(const md_config_t *mconf, +void PurgeQueue::handle_conf_change(const ConfigProxy& conf, const std::set <std::string> &changed, const MDSMap &mds_map) { @@ -598,7 +598,6 @@ void PurgeQueue::handle_conf_change(const md_config_t *mconf, || changed.count("mds_max_purge_ops_per_pg")) { update_op_limit(mds_map); } else if (changed.count("mds_max_purge_files")) { - ConfigReader conf{mconf}; Mutex::Locker l(lock); if (in_flight.empty()) { // We might have gone from zero to a finite limit, so diff --git a/src/mds/PurgeQueue.h b/src/mds/PurgeQueue.h index 4c4de89fa43..ae2c358745d 100644 --- a/src/mds/PurgeQueue.h +++ b/src/mds/PurgeQueue.h @@ -176,7 +176,7 @@ public: void update_op_limit(const MDSMap &mds_map); - void handle_conf_change(const md_config_t *conf, + void handle_conf_change(const ConfigProxy& conf, const std::set <std::string> &changed, const MDSMap &mds_map); diff --git a/src/mgr/DaemonServer.cc b/src/mgr/DaemonServer.cc index 63eca2f6b6d..d94e663ae1e 100644 --- a/src/mgr/DaemonServer.cc +++ b/src/mgr/DaemonServer.cc @@ -2206,7 +2206,7 @@ const char** DaemonServer::get_tracked_conf_keys() const return KEYS; } -void DaemonServer::handle_conf_change(const md_config_t *conf, +void DaemonServer::handle_conf_change(const ConfigProxy& conf, const std::set <std::string> &changed) { // We may be called within lock (via MCommand `config set`) or outwith the diff --git a/src/mgr/DaemonServer.h b/src/mgr/DaemonServer.h index c10b4708125..26554a47283 100644 --- a/src/mgr/DaemonServer.h +++ b/src/mgr/DaemonServer.h @@ -145,7 +145,7 @@ public: void _send_configure(ConnectionRef c); virtual const char** get_tracked_conf_keys() const override; - virtual void handle_conf_change(const md_config_t *conf, + virtual void handle_conf_change(const ConfigProxy& conf, const std::set <std::string> &changed) override; }; diff --git a/src/mgr/MgrStandby.cc b/src/mgr/MgrStandby.cc index 57289b31f64..57ceaeeb8da 100644 --- a/src/mgr/MgrStandby.cc +++ b/src/mgr/MgrStandby.cc @@ -84,7 +84,7 @@ const char** MgrStandby::get_tracked_conf_keys() const } void MgrStandby::handle_conf_change( - const md_config_t *conf, + const ConfigProxy& conf, const std::set <std::string> &changed) { if (changed.count("clog_to_monitors") || diff --git a/src/mgr/MgrStandby.h b/src/mgr/MgrStandby.h index bda41ffcefd..9b1071117ee 100644 --- a/src/mgr/MgrStandby.h +++ b/src/mgr/MgrStandby.h @@ -35,7 +35,7 @@ class MgrStandby : public Dispatcher, public: // config observer bits const char** get_tracked_conf_keys() const override; - void handle_conf_change(const md_config_t *conf, + void handle_conf_change(const ConfigProxy& conf, const std::set <std::string> &changed) override; protected: diff --git a/src/mon/LogMonitor.cc b/src/mon/LogMonitor.cc index 4209c4aa401..95ea2bda5aa 100644 --- a/src/mon/LogMonitor.cc +++ b/src/mon/LogMonitor.cc @@ -828,7 +828,7 @@ ceph::logging::Graylog::Ref LogMonitor::log_channel_info::get_graylog( return graylogs[channel]; } -void LogMonitor::handle_conf_change(const md_config_t *conf, +void LogMonitor::handle_conf_change(const ConfigProxy& conf, const std::set<std::string> &changed) { if (changed.count("mon_cluster_log_to_syslog") || diff --git a/src/mon/LogMonitor.h b/src/mon/LogMonitor.h index f7c003489c8..964058418aa 100644 --- a/src/mon/LogMonitor.h +++ b/src/mon/LogMonitor.h @@ -199,7 +199,7 @@ private: }; return KEYS; } - void handle_conf_change(const md_config_t *conf, + void handle_conf_change(const ConfigProxy& conf, const std::set<std::string> &changed) override; }; #endif diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index ff31d211c5c..c43d5faa644 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -495,7 +495,7 @@ const char** Monitor::get_tracked_conf_keys() const return KEYS; } -void Monitor::handle_conf_change(const md_config_t *mconf, +void Monitor::handle_conf_change(const ConfigProxy& conf, const std::set<std::string> &changed) { sanitize_options(); @@ -521,7 +521,6 @@ void Monitor::handle_conf_change(const md_config_t *mconf, } if (changed.count("mon_scrub_interval")) { - ConfigReader conf{mconf}; scrub_update_interval(conf->mon_scrub_interval); } } diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index e078d691082..a7e200815fd 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -921,7 +921,7 @@ public: // config observer const char** get_tracked_conf_keys() const override; - void handle_conf_change(const md_config_t *conf, + void handle_conf_change(const ConfigProxy& conf, const std::set<std::string> &changed) override; void update_log_clients(); diff --git a/src/msg/async/dpdk/DPDKStack.cc b/src/msg/async/dpdk/DPDKStack.cc index a48e99d435b..bb2f807f4bb 100644 --- a/src/msg/async/dpdk/DPDKStack.cc +++ b/src/msg/async/dpdk/DPDKStack.cc @@ -181,14 +181,14 @@ DPDKWorker::Impl::Impl(CephContext *cct, unsigned i, EventCenter *c, std::shared : id(i), _netif(cct, dev, c), _dev(dev), _inet(cct, c, &_netif) { vector<AvailableIPAddress> tuples; - bool parsed = parse_available_address(cct->_conf->get_val<std::string>("ms_dpdk_host_ipv4_addr"), - cct->_conf->get_val<std::string>("ms_dpdk_gateway_ipv4_addr"), - cct->_conf->get_val<std::string>("ms_dpdk_netmask_ipv4_addr"), tuples); + bool parsed = parse_available_address(cct->_conf.get_val<std::string>("ms_dpdk_host_ipv4_addr"), + cct->_conf.get_val<std::string>("ms_dpdk_gateway_ipv4_addr"), + cct->_conf.get_val<std::string>("ms_dpdk_netmask_ipv4_addr"), tuples); if (!parsed) { lderr(cct) << __func__ << " no available address " - << cct->_conf->get_val<std::string>("ms_dpdk_host_ipv4_addr") << ", " - << cct->_conf->get_val<std::string>("ms_dpdk_gateway_ipv4_addr") << ", " - << cct->_conf->get_val<std::string>("ms_dpdk_netmask_ipv4_addr") << ", " + << cct->_conf.get_val<std::string>("ms_dpdk_host_ipv4_addr") << ", " + << cct->_conf.get_val<std::string>("ms_dpdk_gateway_ipv4_addr") << ", " + << cct->_conf.get_val<std::string>("ms_dpdk_netmask_ipv4_addr") << ", " << dendl; ceph_abort(); } diff --git a/src/msg/async/dpdk/dpdk_rte.cc b/src/msg/async/dpdk/dpdk_rte.cc index 4c1cf9f0237..9f9d343b51a 100644 --- a/src/msg/async/dpdk/dpdk_rte.cc +++ b/src/msg/async/dpdk/dpdk_rte.cc @@ -52,7 +52,7 @@ namespace dpdk { } bool done = false; - auto num = std::stoull(c->_conf->get_val<std::string>("ms_dpdk_coremask"), + auto num = std::stoull(c->_conf.get_val<std::string>("ms_dpdk_coremask"), nullptr, 16); unsigned int coremaskbit = bitcount(num); @@ -62,7 +62,7 @@ namespace dpdk { // TODO: Inherit these from the app parameters - "opts" std::vector<std::vector<char>> args { string2vector(string("ceph")), - string2vector("-c"), string2vector(c->_conf->get_val<std::string>("ms_dpdk_coremask")), + string2vector("-c"), string2vector(c->_conf.get_val<std::string>("ms_dpdk_coremask")), string2vector("-n"), string2vector(c->_conf->ms_dpdk_memory_channel), }; diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 45404abc214..79d163996ea 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -3828,7 +3828,7 @@ const char **BlueStore::get_tracked_conf_keys() const return KEYS; } -void BlueStore::handle_conf_change(const md_config_t *mconf, +void BlueStore::handle_conf_change(const ConfigProxy& conf, const std::set<std::string> &changed) { if (changed.count("bluestore_csum_type")) { @@ -3869,7 +3869,6 @@ void BlueStore::handle_conf_change(const md_config_t *mconf, _set_throttle_params(); } } - ConfigReader conf{mconf}; if (changed.count("bluestore_throttle_bytes")) { throttle_bytes.reset_max(conf->bluestore_throttle_bytes); throttle_deferred_bytes.reset_max( diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index ecc6a9994ac..bfd2c2eef8c 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -131,7 +131,7 @@ class BlueStore : public ObjectStore, public: // config observer const char** get_tracked_conf_keys() const override; - void handle_conf_change(const md_config_t *conf, + void handle_conf_change(const ConfigProxy& conf, const std::set<std::string> &changed) override; //handler for discard event diff --git a/src/os/bluestore/PMEMDevice.cc b/src/os/bluestore/PMEMDevice.cc index 606691bbefb..1cad25ce28f 100644 --- a/src/os/bluestore/PMEMDevice.cc +++ b/src/os/bluestore/PMEMDevice.cc @@ -95,7 +95,7 @@ int PMEMDevice::open(const string& p) // blksize doesn't strictly matter except that some file systems may // require a read/modify/write if we write something smaller than // it. - block_size = g_conf->bdev_block_size; + block_size = g_conf()->bdev_block_size; if (block_size != (unsigned)st.st_blksize) { dout(1) << __func__ << " backing device/file reports st_blksize " << st.st_blksize << ", using bdev_block_size " @@ -219,8 +219,8 @@ int PMEMDevice::write(uint64_t off, bufferlist& bl, bool buffered) bl.hexdump(*_dout); *_dout << dendl; - if (g_conf->bdev_inject_crash && - rand() % g_conf->bdev_inject_crash == 0) { + if (g_conf()->bdev_inject_crash && + rand() % g_conf()->bdev_inject_crash == 0) { derr << __func__ << " bdev_inject_crash: dropping io " << off << "~" << len << dendl; ++injecting_crash; diff --git a/src/os/filestore/FDCache.h b/src/os/filestore/FDCache.h index 6f5d4cc69c5..db4eac55d9a 100644 --- a/src/os/filestore/FDCache.h +++ b/src/os/filestore/FDCache.h @@ -97,9 +97,8 @@ public: }; return KEYS; } - void handle_conf_change(const md_config_t *mconf, + void handle_conf_change(const ConfigProxy& conf, const std::set<std::string> &changed) override { - ConfigReader conf{mconf}; if (changed.count("filestore_fd_cache_size")) { for (int i = 0; i < registry_shards; ++i) registry[i].set_size( diff --git a/src/os/filestore/FileJournal.h b/src/os/filestore/FileJournal.h index 2ee22f8b394..9502ea299b0 100644 --- a/src/os/filestore/FileJournal.h +++ b/src/os/filestore/FileJournal.h @@ -308,7 +308,7 @@ private: int set_throttle_params(); const char** get_tracked_conf_keys() const override; void handle_conf_change( - const md_config_t *conf, + const ConfigProxy& conf, const std::set <std::string> &changed) override { for (const char **i = get_tracked_conf_keys(); *i; diff --git a/src/os/filestore/FileStore.cc b/src/os/filestore/FileStore.cc index 4e4e7feb76c..133ab5e7e1a 100644 --- a/src/os/filestore/FileStore.cc +++ b/src/os/filestore/FileStore.cc @@ -5882,7 +5882,7 @@ const char** FileStore::get_tracked_conf_keys() const return KEYS; } -void FileStore::handle_conf_change(const md_config_t *mconf, +void FileStore::handle_conf_change(const ConfigProxy& conf, const std::set <std::string> &changed) { if (changed.count("filestore_max_inline_xattr_size") || @@ -5915,7 +5915,6 @@ void FileStore::handle_conf_change(const md_config_t *mconf, set_throttle_params(); } - ConfigReader conf{mconf}; if (changed.count("filestore_min_sync_interval") || changed.count("filestore_max_sync_interval") || changed.count("filestore_kill_at") || diff --git a/src/os/filestore/FileStore.h b/src/os/filestore/FileStore.h index 92e8cd26ef5..84fe1ca76d2 100644 --- a/src/os/filestore/FileStore.h +++ b/src/os/filestore/FileStore.h @@ -790,7 +790,7 @@ private: const SequencerPosition &spos); const char** get_tracked_conf_keys() const override; - void handle_conf_change(const md_config_t *conf, + void handle_conf_change(const ConfigProxy& conf, const std::set <std::string> &changed) override; int set_throttle_params(); float m_filestore_commit_timeout; diff --git a/src/os/filestore/WBThrottle.cc b/src/os/filestore/WBThrottle.cc index b9ac4f2392f..ddffffc5747 100644 --- a/src/os/filestore/WBThrottle.cc +++ b/src/os/filestore/WBThrottle.cc @@ -118,7 +118,7 @@ void WBThrottle::set_from_conf() cond.Signal(); } -void WBThrottle::handle_conf_change(const md_config_t *conf, +void WBThrottle::handle_conf_change(const ConfigProxy& conf, const std::set<std::string> &changed) { Mutex::Locker l(lock); diff --git a/src/os/filestore/WBThrottle.h b/src/os/filestore/WBThrottle.h index b10b0bb8e3b..06e4906e5c6 100644 --- a/src/os/filestore/WBThrottle.h +++ b/src/os/filestore/WBThrottle.h @@ -177,7 +177,7 @@ public: /// md_config_obs_t const char** get_tracked_conf_keys() const override; - void handle_conf_change(const md_config_t *conf, + void handle_conf_change(const ConfigProxy& conf, const std::set<std::string> &changed) override; /// Thread diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 88ccebfaf3b..eedc5cf013b 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -3259,7 +3259,7 @@ int OSD::shutdown() cct->_conf.set_val("debug_filestore", "100"); cct->_conf.set_val("debug_bluestore", "100"); cct->_conf.set_val("debug_ms", "100"); - cct->_conf.apply_changes(NULL); + cct->_conf.apply_changes(nullptr); } // stop MgrClient earlier as it's more like an internal consumer of OSD @@ -5002,7 +5002,7 @@ void TestOpsSocketHook::test_ops(OSDService *service, ObjectStore *store, << r; return; } - service->cct->_conf.apply_changes(NULL); + service->cct->_conf.apply_changes(nullptr); ss << "set_recovery_delay: set osd_recovery_delay_start " << "to " << service->cct->_conf->osd_recovery_delay_start; return; @@ -6126,7 +6126,7 @@ void OSD::do_command(Connection *con, ceph_tid_t tid, vector<string>& cmd, buffe << r; goto out; } - cct->_conf.apply_changes(NULL); + cct->_conf.apply_changes(nullptr); ss << "kicking recovery queue. set osd_recovery_delay_start " << "to " << cct->_conf->osd_recovery_delay_start; } @@ -8986,7 +8986,7 @@ const char** OSD::get_tracked_conf_keys() const return KEYS; } -void OSD::handle_conf_change(const md_config_t *conf, +void OSD::handle_conf_change(const ConfigProxy& conf, const std::set <std::string> &changed) { if (changed.count("osd_max_backfills")) { @@ -9035,7 +9035,7 @@ void OSD::handle_conf_change(const md_config_t *conf, update_log_config(); } if (changed.count("osd_pg_epoch_max_lag_factor")) { - m_osd_pg_epoch_max_lag_factor = conf->get_val<double>( + m_osd_pg_epoch_max_lag_factor = conf.get_val<double>( "osd_pg_epoch_max_lag_factor"); } diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 0eb44d504fe..2decffed89b 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -1230,7 +1230,7 @@ class OSD : public Dispatcher, public: // config observer bits const char** get_tracked_conf_keys() const override; - void handle_conf_change(const md_config_t *conf, + void handle_conf_change(const ConfigProxy& conf, const std::set <std::string> &changed) override; void update_log_config(); void check_config(); diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc index 32041e09e32..c6e4e8cd5d7 100644 --- a/src/osdc/Objecter.cc +++ b/src/osdc/Objecter.cc @@ -216,7 +216,7 @@ const char** Objecter::get_tracked_conf_keys() const } -void Objecter::handle_conf_change(const md_config_t *conf, +void Objecter::handle_conf_change(const ConfigProxy& conf, const std::set <std::string> &changed) { if (changed.count("crush_location")) { diff --git a/src/osdc/Objecter.h b/src/osdc/Objecter.h index ac79a7c684f..bc13542fa4d 100644 --- a/src/osdc/Objecter.h +++ b/src/osdc/Objecter.h @@ -1207,7 +1207,7 @@ class Objecter : public md_config_obs_t, public Dispatcher { public: // config observer bits const char** get_tracked_conf_keys() const override; - void handle_conf_change(const md_config_t *conf, + void handle_conf_change(const ConfigProxy& conf, const std::set <std::string> &changed) override; public: diff --git a/src/rgw/librgw.cc b/src/rgw/librgw.cc index 6e5d7e6d6c8..faa0f5c23ae 100644 --- a/src/rgw/librgw.cc +++ b/src/rgw/librgw.cc @@ -451,7 +451,7 @@ namespace rgw { int RGWLibFrontend::init() { pprocess = new RGWLibProcess(g_ceph_context, &env, - g_conf->rgw_thread_pool_size, conf); + g_conf()->rgw_thread_pool_size, conf); return 0; } @@ -481,7 +481,7 @@ namespace rgw { SafeTimer init_timer(g_ceph_context, mutex); init_timer.init(); mutex.Lock(); - init_timer.add_event_after(g_conf->rgw_init_timeout, new C_InitTimeout); + init_timer.add_event_after(g_conf()->rgw_init_timeout, new C_InitTimeout); mutex.Unlock(); common_init_finish(g_ceph_context); @@ -491,11 +491,11 @@ namespace rgw { rgw_init_resolver(); store = RGWStoreManager::get_storage(g_ceph_context, - g_conf->rgw_enable_gc_threads, - g_conf->rgw_enable_lc_threads, - g_conf->rgw_enable_quota_threads, - g_conf->rgw_run_sync_thread, - g_conf->rgw_dynamic_resharding); + g_conf()->rgw_enable_gc_threads, + g_conf()->rgw_enable_lc_threads, + g_conf()->rgw_enable_quota_threads, + g_conf()->rgw_run_sync_thread, + g_conf()->rgw_dynamic_resharding); if (!store) { mutex.Lock(); @@ -538,9 +538,9 @@ namespace rgw { // XXX ex-RGWRESTMgr_lib, mgr->set_logging(true) - if (!g_conf->rgw_ops_log_socket_path.empty()) { - olog = new OpsLogSocket(g_ceph_context, g_conf->rgw_ops_log_data_backlog); - olog->init(g_conf->rgw_ops_log_socket_path); + if (!g_conf()->rgw_ops_log_socket_path.empty()) { + olog = new OpsLogSocket(g_ceph_context, g_conf()->rgw_ops_log_data_backlog); + olog->init(g_conf()->rgw_ops_log_socket_path); } int port = 80; diff --git a/src/rgw/librgw_admin_user.cc b/src/rgw/librgw_admin_user.cc index fe036c124a1..2cdccc34c55 100644 --- a/src/rgw/librgw_admin_user.cc +++ b/src/rgw/librgw_admin_user.cc @@ -92,7 +92,7 @@ namespace rgw { SafeTimer init_timer(g_ceph_context, mutex); init_timer.init(); mutex.Lock(); - init_timer.add_event_after(g_conf->rgw_init_timeout, new C_InitTimeout); + init_timer.add_event_after(g_conf()->rgw_init_timeout, new C_InitTimeout); mutex.Unlock(); common_init_finish(g_ceph_context); diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 155542d62df..685f94de35c 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -2588,8 +2588,8 @@ int main(int argc, const char **argv) CODE_ENVIRONMENT_UTILITY, 0); // for region -> zonegroup conversion (must happen before common_init_finish()) - if (!g_conf->rgw_region.empty() && g_conf->rgw_zonegroup.empty()) { - g_conf->set_val_or_die("rgw_zonegroup", g_conf->rgw_region.c_str()); + if (!g_conf()->rgw_region.empty() && g_conf()->rgw_zonegroup.empty()) { + g_conf().set_val_or_die("rgw_zonegroup", g_conf()->rgw_region.c_str()); } common_init_finish(g_ceph_context); @@ -3159,9 +3159,9 @@ int main(int argc, const char **argv) exit(1); } - realm_name = g_conf->rgw_realm; - zone_name = g_conf->rgw_zone; - zonegroup_name = g_conf->rgw_zonegroup; + realm_name = g_conf()->rgw_realm; + zone_name = g_conf()->rgw_zone; + zonegroup_name = g_conf()->rgw_zonegroup; RGWStreamFlusher f(formatter, cout); @@ -3254,7 +3254,7 @@ int main(int argc, const char **argv) store = RGWStoreManager::get_raw_storage(g_ceph_context); } else { store = RGWStoreManager::get_storage(g_ceph_context, false, false, false, false, false, - need_cache && g_conf->rgw_cache_enabled); + need_cache && g_conf()->rgw_cache_enabled); } if (!store) { cerr << "couldn't init storage provider" << std::endl; @@ -6154,7 +6154,7 @@ next: int ret = br.cancel(); if (ret < 0) { if (ret == -EBUSY) { - cerr << "There is ongoing resharding, please retry after " << g_conf->rgw_reshard_bucket_lock_duration << + cerr << "There is ongoing resharding, please retry after " << g_conf()->rgw_reshard_bucket_lock_duration << " seconds " << std::endl; } else { cerr << "Error canceling bucket " << bucket_name << " resharding: " << cpp_strerror(-ret) << @@ -6679,7 +6679,7 @@ next: return -ret; } - auto num_shards = g_conf->rgw_md_log_max_shards; + auto num_shards = g_conf()->rgw_md_log_max_shards; ret = crs.run(create_admin_meta_log_trim_cr(store, &http, num_shards)); if (ret < 0) { cerr << "automated mdlog trim failed with " << cpp_strerror(ret) << std::endl; diff --git a/src/rgw/rgw_auth_keystone.cc b/src/rgw/rgw_auth_keystone.cc index c3e011c3120..101f031f3ad 100644 --- a/src/rgw/rgw_auth_keystone.cc +++ b/src/rgw/rgw_auth_keystone.cc @@ -283,7 +283,7 @@ TokenEngine::authenticate(const std::string& token, } ldout(cct, 0) << "user does not hold a matching role; required roles: " - << g_conf->rgw_keystone_accepted_roles << dendl; + << g_conf()->rgw_keystone_accepted_roles << dendl; return result_t::deny(-EPERM); } diff --git a/src/rgw/rgw_civetweb_frontend.cc b/src/rgw/rgw_civetweb_frontend.cc index 7d7325d9439..bd98c52d599 100644 --- a/src/rgw/rgw_civetweb_frontend.cc +++ b/src/rgw/rgw_civetweb_frontend.cc @@ -52,7 +52,7 @@ int RGWCivetWebFrontend::run() auto& conf_map = conf->get_config_map(); set_conf_default(conf_map, "num_threads", - std::to_string(g_conf->rgw_thread_pool_size)); + std::to_string(g_conf()->rgw_thread_pool_size)); set_conf_default(conf_map, "decode_url", "no"); set_conf_default(conf_map, "enable_keep_alive", "yes"); set_conf_default(conf_map, "validate_http_method", "no"); diff --git a/src/rgw/rgw_fcgi_process.cc b/src/rgw/rgw_fcgi_process.cc index 3d6eac2b5dd..525dedca548 100644 --- a/src/rgw/rgw_fcgi_process.cc +++ b/src/rgw/rgw_fcgi_process.cc @@ -24,12 +24,12 @@ void RGWFCGXProcess::run() int socket_backlog; conf->get_val("socket_path", "", &socket_path); - conf->get_val("socket_port", g_conf->rgw_port, &socket_port); - conf->get_val("socket_host", g_conf->rgw_host, &socket_host); - socket_backlog = g_conf->rgw_fcgi_socket_backlog; + conf->get_val("socket_port", g_conf()->rgw_port, &socket_port); + conf->get_val("socket_host", g_conf()->rgw_host, &socket_host); + socket_backlog = g_conf()->rgw_fcgi_socket_backlog; if (socket_path.empty() && socket_port.empty() && socket_host.empty()) { - socket_path = g_conf->rgw_socket_path; + socket_path = g_conf()->rgw_socket_path; if (socket_path.empty()) { dout(0) << "ERROR: no socket server point defined, cannot " "start fcgi frontend" << dendl; diff --git a/src/rgw/rgw_frontend.h b/src/rgw/rgw_frontend.h index 75bdd86d748..80746b955b5 100644 --- a/src/rgw/rgw_frontend.h +++ b/src/rgw/rgw_frontend.h @@ -194,7 +194,7 @@ public: int init() override { pprocess = new RGWFCGXProcess(g_ceph_context, &env, - g_conf->rgw_thread_pool_size, conf); + g_conf()->rgw_thread_pool_size, conf); return 0; } }; /* RGWFCGXFrontend */ @@ -206,7 +206,7 @@ public: int init() override { int num_threads; - conf->get_val("num_threads", g_conf->rgw_thread_pool_size, &num_threads); + conf->get_val("num_threads", g_conf()->rgw_thread_pool_size, &num_threads); RGWLoadGenProcess *pp = new RGWLoadGenProcess(g_ceph_context, &env, num_threads, conf); diff --git a/src/rgw/rgw_main.cc b/src/rgw/rgw_main.cc index 8bfccf1212a..b046a5764ca 100644 --- a/src/rgw/rgw_main.cc +++ b/src/rgw/rgw_main.cc @@ -197,8 +197,8 @@ int main(int argc, const char **argv) flags); list<string> frontends; - g_conf->early_expand_meta(g_conf->rgw_frontends, &cerr); - get_str_list(g_conf->rgw_frontends, ",", frontends); + g_conf().early_expand_meta(g_conf()->rgw_frontends, &cerr); + get_str_list(g_conf()->rgw_frontends, ",", frontends); multimap<string, RGWFrontendConfig *> fe_map; list<RGWFrontendConfig *> configs; if (frontends.empty()) { @@ -245,32 +245,32 @@ int main(int argc, const char **argv) flags, "rgw_data", false); // maintain existing region root pool for new multisite objects - if (!g_conf->rgw_region_root_pool.empty()) { - const char *root_pool = g_conf->rgw_region_root_pool.c_str(); - if (g_conf->rgw_zonegroup_root_pool.empty()) { - g_conf->set_val_or_die("rgw_zonegroup_root_pool", root_pool); + if (!g_conf()->rgw_region_root_pool.empty()) { + const char *root_pool = g_conf()->rgw_region_root_pool.c_str(); + if (g_conf()->rgw_zonegroup_root_pool.empty()) { + g_conf().set_val_or_die("rgw_zonegroup_root_pool", root_pool); } - if (g_conf->rgw_period_root_pool.empty()) { - g_conf->set_val_or_die("rgw_period_root_pool", root_pool); + if (g_conf()->rgw_period_root_pool.empty()) { + g_conf().set_val_or_die("rgw_period_root_pool", root_pool); } - if (g_conf->rgw_realm_root_pool.empty()) { - g_conf->set_val_or_die("rgw_realm_root_pool", root_pool); + if (g_conf()->rgw_realm_root_pool.empty()) { + g_conf().set_val_or_die("rgw_realm_root_pool", root_pool); } } // for region -> zonegroup conversion (must happen before common_init_finish()) - if (!g_conf->rgw_region.empty() && g_conf->rgw_zonegroup.empty()) { - g_conf->set_val_or_die("rgw_zonegroup", g_conf->rgw_region.c_str()); + if (!g_conf()->rgw_region.empty() && g_conf()->rgw_zonegroup.empty()) { + g_conf().set_val_or_die("rgw_zonegroup", g_conf()->rgw_region.c_str()); } - if (g_conf->daemonize) { + if (g_conf()->daemonize) { global_init_daemonize(g_ceph_context); } Mutex mutex("main"); SafeTimer init_timer(g_ceph_context, mutex); init_timer.init(); mutex.Lock(); - init_timer.add_event_after(g_conf->rgw_init_timeout, new C_InitTimeout); + init_timer.add_event_after(g_conf()->rgw_init_timeout, new C_InitTimeout); mutex.Unlock(); // Enable the perf counter before starting the service thread @@ -299,8 +299,8 @@ int main(int argc, const char **argv) #endif RGWRados *store = RGWStoreManager::get_storage(g_ceph_context, - g_conf->rgw_enable_gc_threads, g_conf->rgw_enable_lc_threads, g_conf->rgw_enable_quota_threads, - g_conf->rgw_run_sync_thread, g_conf->rgw_dynamic_resharding, g_conf->rgw_cache_enabled); + g_conf()->rgw_enable_gc_threads, g_conf()->rgw_enable_lc_threads, g_conf()->rgw_enable_quota_threads, + g_conf()->rgw_run_sync_thread, g_conf()->rgw_dynamic_resharding, g_conf()->rgw_cache_enabled); if (!store) { mutex.Lock(); init_timer.cancel_all_events(); @@ -332,7 +332,7 @@ int main(int argc, const char **argv) list<string> apis; - get_str_list(g_conf->rgw_enable_apis, apis); + get_str_list(g_conf()->rgw_enable_apis, apis); map<string, bool> apis_map; for (list<string>::iterator li = apis.begin(); li != apis.end(); ++li) { @@ -342,7 +342,7 @@ int main(int argc, const char **argv) // S3 website mode is a specialization of S3 const bool s3website_enabled = apis_map.count("s3website") > 0; // Swift API entrypoint could placed in the root instead of S3 - const bool swift_at_root = g_conf->rgw_swift_url_prefix == "/"; + const bool swift_at_root = g_conf()->rgw_swift_url_prefix == "/"; if (apis_map.count("s3") > 0 || s3website_enabled) { if (! swift_at_root) { rest.register_default_mgr(set_logging(rest_filter(store, RGW_REST_S3, @@ -357,7 +357,7 @@ int main(int argc, const char **argv) if (apis_map.count("swift") > 0) { RGWRESTMgr_SWIFT* const swift_resource = new RGWRESTMgr_SWIFT; - if (! g_conf->rgw_cross_domain_policy.empty()) { + if (! g_conf()->rgw_cross_domain_policy.empty()) { swift_resource->register_resource("crossdomain.xml", set_logging(new RGWRESTMgr_SWIFT_CrossDomain)); } @@ -369,7 +369,7 @@ int main(int argc, const char **argv) set_logging(new RGWRESTMgr_SWIFT_Info)); if (! swift_at_root) { - rest.register_resource(g_conf->rgw_swift_url_prefix, + rest.register_resource(g_conf()->rgw_swift_url_prefix, set_logging(rest_filter(store, RGW_REST_SWIFT, swift_resource))); } else { @@ -384,7 +384,7 @@ int main(int argc, const char **argv) } if (apis_map.count("swift_auth") > 0) { - rest.register_resource(g_conf->rgw_swift_auth_entry, + rest.register_resource(g_conf()->rgw_swift_auth_entry, set_logging(new RGWRESTMgr_SWIFT_Auth)); } @@ -400,7 +400,7 @@ int main(int argc, const char **argv) admin_resource->register_resource("opstate", new RGWRESTMgr_Opstate); admin_resource->register_resource("config", new RGWRESTMgr_Config); admin_resource->register_resource("realm", new RGWRESTMgr_Realm); - rest.register_resource(g_conf->rgw_admin_entry, admin_resource); + rest.register_resource(g_conf()->rgw_admin_entry, admin_resource); } /* Initialize the registry of auth strategies which will coordinate @@ -409,13 +409,13 @@ int main(int argc, const char **argv) rgw::auth::StrategyRegistry::create(g_ceph_context, store); /* Header custom behavior */ - rest.register_x_headers(g_conf->rgw_log_http_headers); + rest.register_x_headers(g_conf()->rgw_log_http_headers); OpsLogSocket *olog = NULL; - if (!g_conf->rgw_ops_log_socket_path.empty()) { - olog = new OpsLogSocket(g_ceph_context, g_conf->rgw_ops_log_data_backlog); - olog->init(g_conf->rgw_ops_log_socket_path); + if (!g_conf()->rgw_ops_log_socket_path.empty()) { + olog = new OpsLogSocket(g_ceph_context, g_conf()->rgw_ops_log_data_backlog); + olog->init(g_conf()->rgw_ops_log_socket_path); } r = signal_fd_init(); diff --git a/src/rgw/rgw_object_expirer.cc b/src/rgw/rgw_object_expirer.cc index 9c8484ef592..93258b4208b 100644 --- a/src/rgw/rgw_object_expirer.cc +++ b/src/rgw/rgw_object_expirer.cc @@ -75,7 +75,7 @@ int main(const int argc, const char **argv) } } - if (g_conf->daemonize) { + if (g_conf()->daemonize) { global_init_daemonize(g_ceph_context); } diff --git a/src/rgw/rgw_process.cc b/src/rgw/rgw_process.cc index 0e9def5c78d..91914310f48 100644 --- a/src/rgw/rgw_process.cc +++ b/src/rgw/rgw_process.cc @@ -17,7 +17,7 @@ void RGWProcess::RGWWQ::_dump_queue() { - if (!g_conf->subsys.should_gather<ceph_subsys_rgw, 20>()) { + if (!g_conf()->subsys.should_gather<ceph_subsys_rgw, 20>()) { return; } deque<RGWRequest *>::iterator iter; diff --git a/src/rgw/rgw_process.h b/src/rgw/rgw_process.h index 6fa788db0e5..ae0585c43cc 100644 --- a/src/rgw/rgw_process.h +++ b/src/rgw/rgw_process.h @@ -117,8 +117,8 @@ public: conf(conf), sock_fd(-1), uri_prefix(pe->uri_prefix), - req_wq(this, g_conf->rgw_op_thread_timeout, - g_conf->rgw_op_thread_suicide_timeout, &m_tp) { + req_wq(this, g_conf()->rgw_op_thread_timeout, + g_conf()->rgw_op_thread_suicide_timeout, &m_tp) { } virtual ~RGWProcess() = default; diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index 33d6fc8dc8f..5c3e6c6cf56 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -718,13 +718,13 @@ static inline int handle_metadata_errors(req_state* const s, const int op_ret) * (stored as xattr) size. */ const auto error_message = boost::str( boost::format("Metadata value longer than %lld") - % s->cct->_conf->get_val<Option::size_t>("rgw_max_attr_size")); + % s->cct->_conf.get_val<Option::size_t>("rgw_max_attr_size")); set_req_state_err(s, EINVAL, error_message); return -EINVAL; } else if (op_ret == -E2BIG) { const auto error_message = boost::str( boost::format("Too many metadata items; max %lld") - % s->cct->_conf->get_val<size_t>("rgw_max_attrs_num_in_req")); + % s->cct->_conf.get_val<size_t>("rgw_max_attrs_num_in_req")); set_req_state_err(s, EINVAL, error_message); return -EINVAL; } @@ -1695,7 +1695,7 @@ void RGWGetCrossDomainPolicy_ObjStore_SWIFT::send_response() << R"(<!DOCTYPE cross-domain-policy SYSTEM )" << R"("http://www.adobe.com/xml/dtds/cross-domain-policy.dtd" >)" << "\n" << R"(<cross-domain-policy>)" << "\n" - << g_conf->rgw_cross_domain_policy << "\n" + << g_conf()->rgw_cross_domain_policy << "\n" << R"(</cross-domain-policy>)"; dump_body(s, ss.str()); @@ -1749,7 +1749,7 @@ void RGWInfo_ObjStore_SWIFT::execute() s->formatter->close_section(); } else { - pair.second.list_data(*(s->formatter), *(s->cct->_conf), *store); + pair.second.list_data(*(s->formatter), s->cct->_conf, *store); } } @@ -1768,31 +1768,31 @@ void RGWInfo_ObjStore_SWIFT::send_response() } void RGWInfo_ObjStore_SWIFT::list_swift_data(Formatter& formatter, - const md_config_t& config, + const ConfigProxy& config, RGWRados& store) { formatter.open_object_section("swift"); - formatter.dump_int("max_file_size", config.rgw_max_put_size); + formatter.dump_int("max_file_size", config->rgw_max_put_size); formatter.dump_int("container_listing_limit", RGW_LIST_BUCKETS_LIMIT_MAX); string ceph_version(CEPH_GIT_NICE_VER); formatter.dump_string("version", ceph_version); const size_t max_attr_name_len = \ - g_conf->get_val<size_t>("rgw_max_attr_name_len"); + g_conf().get_val<size_t>("rgw_max_attr_name_len"); if (max_attr_name_len) { const size_t meta_name_limit = \ max_attr_name_len - strlen(RGW_ATTR_PREFIX RGW_AMZ_META_PREFIX); formatter.dump_int("max_meta_name_length", meta_name_limit); } - const size_t meta_value_limit = g_conf->get_val<Option::size_t>("rgw_max_attr_size"); + const size_t meta_value_limit = g_conf().get_val<Option::size_t>("rgw_max_attr_size"); if (meta_value_limit) { formatter.dump_int("max_meta_value_length", meta_value_limit); } const size_t meta_num_limit = \ - g_conf->get_val<size_t>("rgw_max_attrs_num_in_req"); + g_conf().get_val<size_t>("rgw_max_attrs_num_in_req"); if (meta_num_limit) { formatter.dump_int("max_meta_count", meta_num_limit); } @@ -1816,7 +1816,7 @@ void RGWInfo_ObjStore_SWIFT::list_swift_data(Formatter& formatter, } void RGWInfo_ObjStore_SWIFT::list_tempauth_data(Formatter& formatter, - const md_config_t& config, + const ConfigProxy& config, RGWRados& store) { formatter.open_object_section("tempauth"); @@ -1824,7 +1824,7 @@ void RGWInfo_ObjStore_SWIFT::list_tempauth_data(Formatter& formatter, formatter.close_section(); } void RGWInfo_ObjStore_SWIFT::list_tempurl_data(Formatter& formatter, - const md_config_t& config, + const ConfigProxy& config, RGWRados& store) { formatter.open_object_section("tempurl"); @@ -1839,11 +1839,11 @@ void RGWInfo_ObjStore_SWIFT::list_tempurl_data(Formatter& formatter, } void RGWInfo_ObjStore_SWIFT::list_slo_data(Formatter& formatter, - const md_config_t& config, + const ConfigProxy& config, RGWRados& store) { formatter.open_object_section("slo"); - formatter.dump_int("max_manifest_segments", config.rgw_max_slo_entries); + formatter.dump_int("max_manifest_segments", config->rgw_max_slo_entries); formatter.close_section(); } @@ -2811,23 +2811,23 @@ int RGWHandler_REST_SWIFT::init_from_header(struct req_state* const s, } if ('\0' == req_name[0]) { - return g_conf->rgw_swift_url_prefix == "/" ? -ERR_BAD_URL : 0; + return g_conf()->rgw_swift_url_prefix == "/" ? -ERR_BAD_URL : 0; } req = req_name; size_t pos = req.find('/'); - if (std::string::npos != pos && g_conf->rgw_swift_url_prefix != "/") { - bool cut_url = g_conf->rgw_swift_url_prefix.length(); + if (std::string::npos != pos && g_conf()->rgw_swift_url_prefix != "/") { + bool cut_url = g_conf()->rgw_swift_url_prefix.length(); first = req.substr(0, pos); - if (first.compare(g_conf->rgw_swift_url_prefix) == 0) { + if (first.compare(g_conf()->rgw_swift_url_prefix) == 0) { if (cut_url) { /* Rewind to the "v1/..." part. */ next_tok(req, first, '/'); } } - } else if (req.compare(g_conf->rgw_swift_url_prefix) == 0) { + } else if (req.compare(g_conf()->rgw_swift_url_prefix) == 0) { s->formatter = new RGWFormatter_Plain; return -ERR_BAD_URL; } else { @@ -2835,19 +2835,19 @@ int RGWHandler_REST_SWIFT::init_from_header(struct req_state* const s, } std::string tenant_path; - if (! g_conf->rgw_swift_tenant_name.empty()) { + if (! g_conf()->rgw_swift_tenant_name.empty()) { tenant_path = "/AUTH_"; - tenant_path.append(g_conf->rgw_swift_tenant_name); + tenant_path.append(g_conf()->rgw_swift_tenant_name); } /* verify that the request_uri conforms with what's expected */ - char buf[g_conf->rgw_swift_url_prefix.length() + 16 + tenant_path.length()]; + char buf[g_conf()->rgw_swift_url_prefix.length() + 16 + tenant_path.length()]; int blen; - if (g_conf->rgw_swift_url_prefix == "/") { + if (g_conf()->rgw_swift_url_prefix == "/") { blen = sprintf(buf, "/v1%s", tenant_path.c_str()); } else { blen = sprintf(buf, "/%s/v1%s", - g_conf->rgw_swift_url_prefix.c_str(), tenant_path.c_str()); + g_conf()->rgw_swift_url_prefix.c_str(), tenant_path.c_str()); } if (strncmp(reqbuf, buf, blen) != 0) { @@ -2862,7 +2862,7 @@ int RGWHandler_REST_SWIFT::init_from_header(struct req_state* const s, next_tok(req, ver, '/'); - if (!tenant_path.empty() || g_conf->rgw_swift_account_in_url) { + if (!tenant_path.empty() || g_conf()->rgw_swift_account_in_url) { string account_name; next_tok(req, account_name, '/'); diff --git a/src/rgw/rgw_rest_swift.h b/src/rgw/rgw_rest_swift.h index 6ed9346d5b8..c6d387fe1a0 100644 --- a/src/rgw/rgw_rest_swift.h +++ b/src/rgw/rgw_rest_swift.h @@ -233,7 +233,7 @@ protected: struct info { bool is_admin_info; - function<void (Formatter&, const md_config_t&, RGWRados&)> list_data; + function<void (Formatter&, const ConfigProxy&, RGWRados&)> list_data; }; static const vector<pair<string, struct info>> swift_info; @@ -243,10 +243,10 @@ public: void execute() override; void send_response() override; - static void list_swift_data(Formatter& formatter, const md_config_t& config, RGWRados& store); - static void list_tempauth_data(Formatter& formatter, const md_config_t& config, RGWRados& store); - static void list_tempurl_data(Formatter& formatter, const md_config_t& config, RGWRados& store); - static void list_slo_data(Formatter& formatter, const md_config_t& config, RGWRados& store); + static void list_swift_data(Formatter& formatter, const ConfigProxy& config, RGWRados& store); + static void list_tempauth_data(Formatter& formatter, const ConfigProxy& config, RGWRados& store); + static void list_tempurl_data(Formatter& formatter, const ConfigProxy& config, RGWRados& store); + static void list_slo_data(Formatter& formatter, const ConfigProxy& config, RGWRados& store); static bool is_expired(const std::string& expires, CephContext* cct); }; diff --git a/src/rgw/rgw_swift_auth.cc b/src/rgw/rgw_swift_auth.cc index 9092f3ebe1a..571a6286031 100644 --- a/src/rgw/rgw_swift_auth.cc +++ b/src/rgw/rgw_swift_auth.cc @@ -289,7 +289,7 @@ TempURLEngine::authenticate(const req_state* const s) const * of Swift API entry point removed. */ /* XXX can we search this ONCE? */ - const size_t pos = g_conf->rgw_swift_url_prefix.find_last_not_of('/') + 1; + const size_t pos = g_conf()->rgw_swift_url_prefix.find_last_not_of('/') + 1; const boost::string_view ref_uri = s->decoded_uri; const std::array<boost::string_view, 2> allowed_paths = { ref_uri, @@ -355,7 +355,7 @@ bool ExternalTokenEngine::is_applicable(const std::string& token) const noexcept { if (token.empty()) { return false; - } else if (g_conf->rgw_swift_auth_url.empty()) { + } else if (g_conf()->rgw_swift_auth_url.empty()) { return false; } else { return true; @@ -370,7 +370,7 @@ ExternalTokenEngine::authenticate(const std::string& token, return result_t::deny(); } - std::string auth_url = g_conf->rgw_swift_auth_url; + std::string auth_url = g_conf()->rgw_swift_auth_url; if (auth_url.back() != '/') { auth_url.append("/"); } @@ -591,8 +591,8 @@ void RGW_SWIFT_Auth_Get::execute() RGWAccessKey *swift_key; map<string, RGWAccessKey>::iterator siter; - string swift_url = g_conf->rgw_swift_url; - string swift_prefix = g_conf->rgw_swift_url_prefix; + string swift_url = g_conf()->rgw_swift_url; + string swift_prefix = g_conf()->rgw_swift_url_prefix; string tenant_path; /* @@ -662,10 +662,10 @@ void RGW_SWIFT_Auth_Get::execute() goto done; } - if (!g_conf->rgw_swift_tenant_name.empty()) { + if (!g_conf()->rgw_swift_tenant_name.empty()) { tenant_path = "/AUTH_"; - tenant_path.append(g_conf->rgw_swift_tenant_name); - } else if (g_conf->rgw_swift_account_in_url) { + tenant_path.append(g_conf()->rgw_swift_tenant_name); + } else if (g_conf()->rgw_swift_account_in_url) { tenant_path = "/AUTH_"; tenant_path.append(info.user_id.to_str()); } diff --git a/src/test/common/test_config.cc b/src/test/common/test_config.cc index 7794f84835d..abc7133a131 100644 --- a/src/test/common/test_config.cc +++ b/src/test/common/test_config.cc @@ -19,21 +19,20 @@ * * */ -#include "common/config.h" +#include "common/config_proxy.h" #include "common/errno.h" #include "gtest/gtest.h" extern std::string exec(const char* cmd); // defined in test_hostname.cc -class test_md_config_t : public md_config_t, public ::testing::Test { +class test_config_proxy : public ConfigProxy, public ::testing::Test { public: - test_md_config_t() - : md_config_t(true), Test() + test_config_proxy() + : ConfigProxy{true}, Test() {} void test_expand_meta() { - auto locker = lock(); // successfull meta expansion $run_dir and ${run_dir} { ostringstream oss; @@ -126,7 +125,7 @@ public: } }; -TEST_F(test_md_config_t, expand_meta) +TEST_F(test_config_proxy, expand_meta) { test_expand_meta(); } @@ -134,7 +133,7 @@ TEST_F(test_md_config_t, expand_meta) TEST(md_config_t, set_val) { int buf_size = 1024; - md_config_t conf; + ConfigProxy conf{false}; { char *run_dir = (char*)malloc(buf_size); EXPECT_EQ(0, conf.get_val("run_dir", &run_dir, buf_size)); diff --git a/src/test/common/test_context.cc b/src/test/common/test_context.cc index 1ddf21cbee5..1d1e22e2558 100644 --- a/src/test/common/test_context.cc +++ b/src/test/common/test_context.cc @@ -23,7 +23,7 @@ #include "include/types.h" #include "include/msgr.h" #include "common/ceph_context.h" -#include "common/config.h" +#include "common/config_proxy.h" #include "log/Log.h" TEST(CephContext, do_command) @@ -34,7 +34,7 @@ TEST(CephContext, do_command) string key("key"); string value("value"); - cct->_conf->set_val(key.c_str(), value.c_str()); + cct->_conf.set_val(key.c_str(), value.c_str()); cmdmap_t cmdmap; cmdmap["var"] = key; @@ -71,30 +71,30 @@ TEST(CephContext, experimental_features) ASSERT_FALSE(cct->check_experimental_feature_enabled("bar")); ASSERT_FALSE(cct->check_experimental_feature_enabled("baz")); - cct->_conf->set_val("enable_experimental_unrecoverable_data_corrupting_features", + cct->_conf.set_val("enable_experimental_unrecoverable_data_corrupting_features", "foo,bar"); - cct->_conf->apply_changes(&cout); + cct->_conf.apply_changes(&cout); ASSERT_TRUE(cct->check_experimental_feature_enabled("foo")); ASSERT_TRUE(cct->check_experimental_feature_enabled("bar")); ASSERT_FALSE(cct->check_experimental_feature_enabled("baz")); - cct->_conf->set_val("enable_experimental_unrecoverable_data_corrupting_features", + cct->_conf.set_val("enable_experimental_unrecoverable_data_corrupting_features", "foo bar"); - cct->_conf->apply_changes(&cout); + cct->_conf.apply_changes(&cout); ASSERT_TRUE(cct->check_experimental_feature_enabled("foo")); ASSERT_TRUE(cct->check_experimental_feature_enabled("bar")); ASSERT_FALSE(cct->check_experimental_feature_enabled("baz")); - cct->_conf->set_val("enable_experimental_unrecoverable_data_corrupting_features", + cct->_conf.set_val("enable_experimental_unrecoverable_data_corrupting_features", "baz foo"); - cct->_conf->apply_changes(&cout); + cct->_conf.apply_changes(&cout); ASSERT_TRUE(cct->check_experimental_feature_enabled("foo")); ASSERT_FALSE(cct->check_experimental_feature_enabled("bar")); ASSERT_TRUE(cct->check_experimental_feature_enabled("baz")); - cct->_conf->set_val("enable_experimental_unrecoverable_data_corrupting_features", + cct->_conf.set_val("enable_experimental_unrecoverable_data_corrupting_features", "*"); - cct->_conf->apply_changes(&cout); + cct->_conf.apply_changes(&cout); ASSERT_TRUE(cct->check_experimental_feature_enabled("foo")); ASSERT_TRUE(cct->check_experimental_feature_enabled("bar")); ASSERT_TRUE(cct->check_experimental_feature_enabled("baz")); diff --git a/src/test/compressor/test_compression.cc b/src/test/compressor/test_compression.cc index e747205ff11..0bdc2f2601e 100644 --- a/src/test/compressor/test_compression.cc +++ b/src/test/compressor/test_compression.cc @@ -33,7 +33,7 @@ public: CompressorTest() { // note for later - old_zlib_isal = g_conf->compressor_zlib_isal; + old_zlib_isal = g_conf()->compressor_zlib_isal; plugin = GetParam(); size_t pos = plugin.find('/'); @@ -41,11 +41,11 @@ public: string isal = plugin.substr(pos + 1); plugin = plugin.substr(0, pos); if (isal == "isal") { - g_conf->set_val("compressor_zlib_isal", "true"); - g_ceph_context->_conf->apply_changes(NULL); + g_conf().set_val("compressor_zlib_isal", "true"); + g_ceph_context->_conf.apply_changes(nullptr); } else if (isal == "noisal") { - g_conf->set_val("compressor_zlib_isal", "false"); - g_ceph_context->_conf->apply_changes(NULL); + g_conf().set_val("compressor_zlib_isal", "false"); + g_ceph_context->_conf.apply_changes(nullptr); } else { assert(0 == "bad option"); } @@ -53,8 +53,8 @@ public: cout << "[plugin " << plugin << " (" << GetParam() << ")]" << std::endl; } ~CompressorTest() override { - g_conf->set_val("compressor_zlib_isal", old_zlib_isal ? "true" : "false"); - g_ceph_context->_conf->apply_changes(NULL); + g_conf().set_val("compressor_zlib_isal", old_zlib_isal ? "true" : "false"); + g_ceph_context->_conf.apply_changes(nullptr); } void SetUp() override { @@ -343,15 +343,15 @@ INSTANTIATE_TEST_CASE_P( TEST(ZlibCompressor, zlib_isal_compatibility) { - g_conf->set_val("compressor_zlib_isal", "true"); - g_ceph_context->_conf->apply_changes(NULL); + g_conf().set_val("compressor_zlib_isal", "true"); + g_ceph_context->_conf.apply_changes(nullptr); CompressorRef isal = Compressor::create(g_ceph_context, "zlib"); if (!isal) { // skip the test if the plugin is not ready return; } - g_conf->set_val("compressor_zlib_isal", "false"); - g_ceph_context->_conf->apply_changes(NULL); + g_conf().set_val("compressor_zlib_isal", "false"); + g_ceph_context->_conf.apply_changes(nullptr); CompressorRef zlib = Compressor::create(g_ceph_context, "zlib"); char test[101]; srand(time(0)); @@ -407,15 +407,15 @@ TEST(CompressionPlugin, all) TEST(ZlibCompressor, isal_compress_zlib_decompress_random) { - g_conf->set_val("compressor_zlib_isal", "true"); - g_ceph_context->_conf->apply_changes(NULL); + g_conf().set_val("compressor_zlib_isal", "true"); + g_ceph_context->_conf.apply_changes(nullptr); CompressorRef isal = Compressor::create(g_ceph_context, "zlib"); if (!isal) { // skip the test if the plugin is not ready return; } - g_conf->set_val("compressor_zlib_isal", "false"); - g_ceph_context->_conf->apply_changes(NULL); + g_conf().set_val("compressor_zlib_isal", "false"); + g_ceph_context->_conf.apply_changes(nullptr); CompressorRef zlib = Compressor::create(g_ceph_context, "zlib"); for (int cnt=0; cnt<100; cnt++) @@ -443,15 +443,15 @@ TEST(ZlibCompressor, isal_compress_zlib_decompress_random) TEST(ZlibCompressor, isal_compress_zlib_decompress_walk) { - g_conf->set_val("compressor_zlib_isal", "true"); - g_ceph_context->_conf->apply_changes(NULL); + g_conf().set_val("compressor_zlib_isal", "true"); + g_ceph_context->_conf.apply_changes(nullptr); CompressorRef isal = Compressor::create(g_ceph_context, "zlib"); if (!isal) { // skip the test if the plugin is not ready return; } - g_conf->set_val("compressor_zlib_isal", "false"); - g_ceph_context->_conf->apply_changes(NULL); + g_conf().set_val("compressor_zlib_isal", "false"); + g_ceph_context->_conf.apply_changes(nullptr); CompressorRef zlib = Compressor::create(g_ceph_context, "zlib"); for (int cnt=0; cnt<100; cnt++) @@ -490,9 +490,9 @@ TEST(QAT, enc_qat_dec_noqat) { const char* alg_collection[] = {"zlib", "snappy"}; #endif for (auto alg : alg_collection) { - g_conf->set_val("qat_compressor_enabled", "true"); + g_conf().set_val("qat_compressor_enabled", "true"); CompressorRef q = Compressor::create(g_ceph_context, alg); - g_conf->set_val("qat_compressor_enabled", "false"); + g_conf().set_val("qat_compressor_enabled", "false"); CompressorRef noq = Compressor::create(g_ceph_context, alg); // generate random buffer @@ -526,9 +526,9 @@ TEST(QAT, enc_noqat_dec_qat) { const char* alg_collection[] = {"zlib", "snappy"}; #endif for (auto alg : alg_collection) { - g_conf->set_val("qat_compressor_enabled", "true"); + g_conf().set_val("qat_compressor_enabled", "true"); CompressorRef q = Compressor::create(g_ceph_context, alg); - g_conf->set_val("qat_compressor_enabled", "false"); + g_conf().set_val("qat_compressor_enabled", "false"); CompressorRef noq = Compressor::create(g_ceph_context, alg); // generate random buffer diff --git a/src/test/confutils.cc b/src/test/confutils.cc index 49aadaa36cb..e89c80730ea 100644 --- a/src/test/confutils.cc +++ b/src/test/confutils.cc @@ -475,18 +475,18 @@ TEST(ConfUtils, Overrides) { conf->name.set(CEPH_ENTITY_TYPE_MON, "0"); conf.parse_config_files(override_conf_1_f.c_str(), &warn, 0); - ASSERT_EQ(conf.parse_errors.size(), 0U); - ASSERT_EQ(conf.log_file, "global_log"); + ASSERT_EQ(conf.num_parse_errors(), 0U); + ASSERT_EQ(conf->log_file, "global_log"); conf->name.set(CEPH_ENTITY_TYPE_MDS, "a"); conf.parse_config_files(override_conf_1_f.c_str(), &warn, 0); - ASSERT_EQ(conf.parse_errors.size(), 0U); - ASSERT_EQ(conf.log_file, "mds_log"); + ASSERT_EQ(conf.num_parse_errors(), 0U); + ASSERT_EQ(conf->log_file, "mds_log"); conf->name.set(CEPH_ENTITY_TYPE_OSD, "0"); conf.parse_config_files(override_conf_1_f.c_str(), &warn, 0); - ASSERT_EQ(conf.parse_errors.size(), 0U); - ASSERT_EQ(conf.log_file, "osd0_log"); + ASSERT_EQ(conf.num_parse_errors(), 0U); + ASSERT_EQ(conf->log_file, "osd0_log"); } TEST(ConfUtils, DupKey) { @@ -496,8 +496,8 @@ TEST(ConfUtils, DupKey) { conf->name.set(CEPH_ENTITY_TYPE_MDS, "a"); conf.parse_config_files(dup_key_config_f.c_str(), &warn, 0); - ASSERT_EQ(conf.parse_errors.size(), 0U); - ASSERT_EQ(conf.log_file, string("3")); + ASSERT_EQ(conf.num_parse_errors(), 0U); + ASSERT_EQ(conf->log_file, string("3")); } diff --git a/src/test/crimson/test_alien_echo.cc b/src/test/crimson/test_alien_echo.cc index b06bc686a17..84b46056851 100644 --- a/src/test/crimson/test_alien_echo.cc +++ b/src/test/crimson/test_alien_echo.cc @@ -102,7 +102,7 @@ struct Server { Server(CephContext* cct, const entity_inst_t& entity) : dispatcher(cct) { - msgr.reset(Messenger::create(cct, cct->_conf->get_val<string>("ms_type"), + msgr.reset(Messenger::create(cct, cct->_conf.get_val<string>("ms_type"), entity.name, "pong", entity.addr.get_nonce(), 0)); msgr->set_cluster_protocol(CEPH_OSD_PROTOCOL); msgr->set_default_policy(Messenger::Policy::stateless_server(0)); @@ -164,7 +164,7 @@ struct Client { Client(CephContext *cct) : dispatcher(cct) { - msgr.reset(Messenger::create(cct, cct->_conf->get_val<string>("ms_type"), + msgr.reset(Messenger::create(cct, cct->_conf.get_val<string>("ms_type"), entity_name_t::CLIENT(-1), "ping", getpid(), 0)); msgr->set_cluster_protocol(CEPH_OSD_PROTOCOL); diff --git a/src/test/daemon_config.cc b/src/test/daemon_config.cc index c9248c788df..bfe99379875 100644 --- a/src/test/daemon_config.cc +++ b/src/test/daemon_config.cc @@ -98,7 +98,7 @@ TEST(DaemonConfig, SubstitutionBracesTrailing) { ASSERT_EQ(0, ret); ret = g_ceph_context->_conf.set_val("public_network", "bar${host}"); ASSERT_EQ(0, ret); - g_ceph_context->_conf.apply_changes(NULL); + g_ceph_context->_conf.apply_changes(nullptr); char buf[128]; memset(buf, 0, sizeof(buf)); char *tmp = buf; @@ -114,7 +114,7 @@ TEST(DaemonConfig, SubstitutionMultiple) { ASSERT_EQ(0, ret); ret = g_ceph_context->_conf.set_val("keyring", "$mon_host/$cluster.keyring,$mon_host/$cluster.mon.keyring"); ASSERT_EQ(0, ret); - g_ceph_context->_conf.apply_changes(NULL); + g_ceph_context->_conf.apply_changes(nullptr); char buf[512]; memset(buf, 0, sizeof(buf)); char *tmp = buf; @@ -302,7 +302,7 @@ TEST(DaemonConfig, InjectArgsLogfile) { // Let's turn off the logfile. ret = g_ceph_context->_conf.set_val("log_file", ""); ASSERT_EQ(0, ret); - g_ceph_context->_conf.apply_changes(NULL); + g_ceph_context->_conf.apply_changes(nullptr); ret = g_ceph_context->_conf.get_val("log_file", &tmp, sizeof(buf)); ASSERT_EQ(0, ret); ASSERT_EQ(string(""), string(buf)); diff --git a/src/test/erasure-code/TestErasureCodeLrc.cc b/src/test/erasure-code/TestErasureCodeLrc.cc index 21926af2b93..9df75dabc91 100644 --- a/src/test/erasure-code/TestErasureCodeLrc.cc +++ b/src/test/erasure-code/TestErasureCodeLrc.cc @@ -22,13 +22,13 @@ #include "include/stringify.h" #include "erasure-code/lrc/ErasureCodeLrc.h" #include "global/global_context.h" -#include "common/config.h" +#include "common/config_proxy.h" #include "gtest/gtest.h" TEST(ErasureCodeLrc, parse_rule) { - ErasureCodeLrc lrc(g_conf->get_val<std::string>("erasure_code_dir")); + ErasureCodeLrc lrc(g_conf().get_val<std::string>("erasure_code_dir")); EXPECT_EQ("default", lrc.rule_root); EXPECT_EQ("host", lrc.rule_steps.front().type); @@ -130,7 +130,7 @@ TEST(ErasureCodeTest, create_rule) c->finalize(); - ErasureCodeLrc lrc(g_conf->get_val<std::string>("erasure_code_dir")); + ErasureCodeLrc lrc(g_conf().get_val<std::string>("erasure_code_dir")); EXPECT_EQ(0, lrc.create_rule("rule1", *c, &cerr)); ErasureCodeProfile profile; @@ -171,7 +171,7 @@ TEST(ErasureCodeTest, create_rule) TEST(ErasureCodeLrc, parse_kml) { - ErasureCodeLrc lrc(g_conf->get_val<std::string>("erasure_code_dir")); + ErasureCodeLrc lrc(g_conf().get_val<std::string>("erasure_code_dir")); ErasureCodeProfile profile; EXPECT_EQ(0, lrc.parse_kml(profile, &cerr)); profile["k"] = "4"; @@ -246,7 +246,7 @@ TEST(ErasureCodeLrc, parse_kml) TEST(ErasureCodeLrc, layers_description) { - ErasureCodeLrc lrc(g_conf->get_val<std::string>("erasure_code_dir")); + ErasureCodeLrc lrc(g_conf().get_val<std::string>("erasure_code_dir")); ErasureCodeProfile profile; json_spirit::mArray description; @@ -275,7 +275,7 @@ TEST(ErasureCodeLrc, layers_description) TEST(ErasureCodeLrc, layers_parse) { { - ErasureCodeLrc lrc(g_conf->get_val<std::string>("erasure_code_dir")); + ErasureCodeLrc lrc(g_conf().get_val<std::string>("erasure_code_dir")); ErasureCodeProfile profile; const char *description_string ="[ 0 ]"; @@ -287,7 +287,7 @@ TEST(ErasureCodeLrc, layers_parse) } { - ErasureCodeLrc lrc(g_conf->get_val<std::string>("erasure_code_dir")); + ErasureCodeLrc lrc(g_conf().get_val<std::string>("erasure_code_dir")); ErasureCodeProfile profile; const char *description_string ="[ [ 0 ] ]"; @@ -299,7 +299,7 @@ TEST(ErasureCodeLrc, layers_parse) } { - ErasureCodeLrc lrc(g_conf->get_val<std::string>("erasure_code_dir")); + ErasureCodeLrc lrc(g_conf().get_val<std::string>("erasure_code_dir")); ErasureCodeProfile profile; const char *description_string ="[ [ \"\", 0 ] ]"; @@ -315,7 +315,7 @@ TEST(ErasureCodeLrc, layers_parse) // profile. // { - ErasureCodeLrc lrc(g_conf->get_val<std::string>("erasure_code_dir")); + ErasureCodeLrc lrc(g_conf().get_val<std::string>("erasure_code_dir")); ErasureCodeProfile profile; const char *description_string ="[ [ \"\", { \"a\": \"b\" }, \"ignored\" ] ]"; @@ -331,7 +331,7 @@ TEST(ErasureCodeLrc, layers_parse) // profile. // { - ErasureCodeLrc lrc(g_conf->get_val<std::string>("erasure_code_dir")); + ErasureCodeLrc lrc(g_conf().get_val<std::string>("erasure_code_dir")); ErasureCodeProfile profile; const char *description_string ="[ [ \"\", \"a=b c=d\" ] ]"; @@ -348,7 +348,7 @@ TEST(ErasureCodeLrc, layers_parse) TEST(ErasureCodeLrc, layers_sanity_checks) { { - ErasureCodeLrc lrc(g_conf->get_val<std::string>("erasure_code_dir")); + ErasureCodeLrc lrc(g_conf().get_val<std::string>("erasure_code_dir")); ErasureCodeProfile profile; profile["mapping"] = "__DDD__DD"; @@ -362,7 +362,7 @@ TEST(ErasureCodeLrc, layers_sanity_checks) EXPECT_EQ(0, lrc.init(profile, &cerr)); } { - ErasureCodeLrc lrc(g_conf->get_val<std::string>("erasure_code_dir")); + ErasureCodeLrc lrc(g_conf().get_val<std::string>("erasure_code_dir")); ErasureCodeProfile profile; const char *description_string = "[ " @@ -371,7 +371,7 @@ TEST(ErasureCodeLrc, layers_sanity_checks) EXPECT_EQ(ERROR_LRC_MAPPING, lrc.init(profile, &cerr)); } { - ErasureCodeLrc lrc(g_conf->get_val<std::string>("erasure_code_dir")); + ErasureCodeLrc lrc(g_conf().get_val<std::string>("erasure_code_dir")); ErasureCodeProfile profile; profile["mapping"] = ""; const char *description_string = @@ -381,7 +381,7 @@ TEST(ErasureCodeLrc, layers_sanity_checks) EXPECT_EQ(ERROR_LRC_LAYERS_COUNT, lrc.init(profile, &cerr)); } { - ErasureCodeLrc lrc(g_conf->get_val<std::string>("erasure_code_dir")); + ErasureCodeLrc lrc(g_conf().get_val<std::string>("erasure_code_dir")); ErasureCodeProfile profile; profile["mapping"] = "DD"; @@ -399,7 +399,7 @@ TEST(ErasureCodeLrc, layers_sanity_checks) TEST(ErasureCodeLrc, layers_init) { { - ErasureCodeLrc lrc(g_conf->get_val<std::string>("erasure_code_dir")); + ErasureCodeLrc lrc(g_conf().get_val<std::string>("erasure_code_dir")); ErasureCodeProfile profile; const char* env = getenv("CEPH_LIB"); @@ -422,7 +422,7 @@ TEST(ErasureCodeLrc, layers_init) TEST(ErasureCodeLrc, init) { - ErasureCodeLrc lrc(g_conf->get_val<std::string>("erasure_code_dir")); + ErasureCodeLrc lrc(g_conf().get_val<std::string>("erasure_code_dir")); ErasureCodeProfile profile; profile["mapping"] = "__DDD__DD"; @@ -438,7 +438,7 @@ TEST(ErasureCodeLrc, init) TEST(ErasureCodeLrc, init_kml) { - ErasureCodeLrc lrc(g_conf->get_val<std::string>("erasure_code_dir")); + ErasureCodeLrc lrc(g_conf().get_val<std::string>("erasure_code_dir")); ErasureCodeProfile profile; profile["k"] = "4"; profile["m"] = "2"; @@ -451,7 +451,7 @@ TEST(ErasureCodeLrc, minimum_to_decode) { // trivial : no erasures, the minimum is want_to_read { - ErasureCodeLrc lrc(g_conf->get_val<std::string>("erasure_code_dir")); + ErasureCodeLrc lrc(g_conf().get_val<std::string>("erasure_code_dir")); ErasureCodeProfile profile; profile["mapping"] = "__DDD__DD"; @@ -474,7 +474,7 @@ TEST(ErasureCodeLrc, minimum_to_decode) } // locally repairable erasure { - ErasureCodeLrc lrc(g_conf->get_val<std::string>("erasure_code_dir")); + ErasureCodeLrc lrc(g_conf().get_val<std::string>("erasure_code_dir")); ErasureCodeProfile profile; profile["mapping"] = "__DDD__DD_"; @@ -524,7 +524,7 @@ TEST(ErasureCodeLrc, minimum_to_decode) } // implicit parity required { - ErasureCodeLrc lrc(g_conf->get_val<std::string>("erasure_code_dir")); + ErasureCodeLrc lrc(g_conf().get_val<std::string>("erasure_code_dir")); ErasureCodeProfile profile; profile["mapping"] = "__DDD__DD"; @@ -602,7 +602,7 @@ TEST(ErasureCodeLrc, minimum_to_decode) TEST(ErasureCodeLrc, encode_decode) { - ErasureCodeLrc lrc(g_conf->get_val<std::string>("erasure_code_dir")); + ErasureCodeLrc lrc(g_conf().get_val<std::string>("erasure_code_dir")); ErasureCodeProfile profile; profile["mapping"] = "__DD__DD"; @@ -615,7 +615,7 @@ TEST(ErasureCodeLrc, encode_decode) profile["layers"] = description_string; EXPECT_EQ(0, lrc.init(profile, &cerr)); EXPECT_EQ(4U, lrc.get_data_chunk_count()); - unsigned int chunk_size = g_conf->get_val<Option::size_t>("osd_pool_erasure_code_stripe_unit"); + unsigned int chunk_size = g_conf().get_val<Option::size_t>("osd_pool_erasure_code_stripe_unit"); unsigned int stripe_width = lrc.get_data_chunk_count() * chunk_size; EXPECT_EQ(chunk_size, lrc.get_chunk_size(stripe_width)); set<int> want_to_encode; @@ -735,7 +735,7 @@ TEST(ErasureCodeLrc, encode_decode) TEST(ErasureCodeLrc, encode_decode_2) { - ErasureCodeLrc lrc(g_conf->get_val<std::string>("erasure_code_dir")); + ErasureCodeLrc lrc(g_conf().get_val<std::string>("erasure_code_dir")); ErasureCodeProfile profile; profile["mapping"] = "DD__DD__"; @@ -748,7 +748,7 @@ TEST(ErasureCodeLrc, encode_decode_2) profile["layers"] = description_string; EXPECT_EQ(0, lrc.init(profile, &cerr)); EXPECT_EQ(4U, lrc.get_data_chunk_count()); - unsigned int chunk_size = g_conf->get_val<Option::size_t>("osd_pool_erasure_code_stripe_unit"); + unsigned int chunk_size = g_conf().get_val<Option::size_t>("osd_pool_erasure_code_stripe_unit"); unsigned int stripe_width = lrc.get_data_chunk_count() * chunk_size; EXPECT_EQ(chunk_size, lrc.get_chunk_size(stripe_width)); set<int> want_to_encode; diff --git a/src/test/erasure-code/TestErasureCodePlugin.cc b/src/test/erasure-code/TestErasureCodePlugin.cc index dd2e142c9bf..08404b6e503 100644 --- a/src/test/erasure-code/TestErasureCodePlugin.cc +++ b/src/test/erasure-code/TestErasureCodePlugin.cc @@ -21,7 +21,7 @@ #include "common/Thread.h" #include "erasure-code/ErasureCodePlugin.h" #include "global/global_context.h" -#include "common/config.h" +#include "common/config_proxy.h" #include "gtest/gtest.h" @@ -42,7 +42,7 @@ protected: ErasureCodeInterfaceRef erasure_code; pthread_cleanup_push(cleanup, NULL); instance.factory("hangs", - g_conf->get_val<std::string>("erasure_code_dir"), + g_conf().get_val<std::string>("erasure_code_dir"), profile, &erasure_code, &cerr); pthread_cleanup_pop(0); return NULL; @@ -82,36 +82,36 @@ TEST_F(ErasureCodePluginRegistryTest, factory_mutex) { TEST_F(ErasureCodePluginRegistryTest, all) { ErasureCodeProfile profile; - string directory = g_conf->get_val<std::string>("erasure_code_dir"); + string directory = g_conf().get_val<std::string>("erasure_code_dir"); ErasureCodeInterfaceRef erasure_code; ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance(); EXPECT_FALSE(erasure_code); EXPECT_EQ(-EIO, instance.factory("invalid", - g_conf->get_val<std::string>("erasure_code_dir"), + g_conf().get_val<std::string>("erasure_code_dir"), profile, &erasure_code, &cerr)); EXPECT_FALSE(erasure_code); EXPECT_EQ(-EXDEV, instance.factory("missing_version", - g_conf->get_val<std::string>("erasure_code_dir"), + g_conf().get_val<std::string>("erasure_code_dir"), profile, &erasure_code, &cerr)); EXPECT_FALSE(erasure_code); EXPECT_EQ(-ENOENT, instance.factory("missing_entry_point", - g_conf->get_val<std::string>("erasure_code_dir"), + g_conf().get_val<std::string>("erasure_code_dir"), profile, &erasure_code, &cerr)); EXPECT_FALSE(erasure_code); EXPECT_EQ(-ESRCH, instance.factory("fail_to_initialize", - g_conf->get_val<std::string>("erasure_code_dir"), + g_conf().get_val<std::string>("erasure_code_dir"), profile, &erasure_code, &cerr)); EXPECT_FALSE(erasure_code); EXPECT_EQ(-EBADF, instance.factory("fail_to_register", - g_conf->get_val<std::string>("erasure_code_dir"), + g_conf().get_val<std::string>("erasure_code_dir"), profile, &erasure_code, &cerr)); EXPECT_FALSE(erasure_code); EXPECT_EQ(0, instance.factory("example", - g_conf->get_val<std::string>("erasure_code_dir"), + g_conf().get_val<std::string>("erasure_code_dir"), profile, &erasure_code, &cerr)); EXPECT_TRUE(erasure_code.get()); ErasureCodePlugin *plugin = 0; diff --git a/src/test/erasure-code/TestErasureCodePluginIsa.cc b/src/test/erasure-code/TestErasureCodePluginIsa.cc index 0656f54dd9f..b57bf489654 100644 --- a/src/test/erasure-code/TestErasureCodePluginIsa.cc +++ b/src/test/erasure-code/TestErasureCodePluginIsa.cc @@ -18,7 +18,7 @@ #include "arch/intel.h" #include "erasure-code/ErasureCodePlugin.h" #include "global/global_context.h" -#include "common/config.h" +#include "common/config_proxy.h" #include "gtest/gtest.h" TEST(ErasureCodePlugin, factory) @@ -29,7 +29,7 @@ TEST(ErasureCodePlugin, factory) ErasureCodeInterfaceRef erasure_code; EXPECT_FALSE(erasure_code); EXPECT_EQ(-EIO, instance.factory("no-isa", - g_conf->get_val<std::string>("erasure_code_dir"), + g_conf().get_val<std::string>("erasure_code_dir"), profile, &erasure_code, &cerr)); EXPECT_FALSE(erasure_code); @@ -43,7 +43,7 @@ TEST(ErasureCodePlugin, factory) profile["technique"] = *technique; EXPECT_FALSE(erasure_code); EXPECT_EQ(0, instance.factory("isa", - g_conf->get_val<std::string>("erasure_code_dir"), + g_conf().get_val<std::string>("erasure_code_dir"), profile, &erasure_code, &cerr)); EXPECT_TRUE(erasure_code.get()); diff --git a/src/test/erasure-code/TestErasureCodePluginJerasure.cc b/src/test/erasure-code/TestErasureCodePluginJerasure.cc index 93ae080a5b4..0010d020670 100644 --- a/src/test/erasure-code/TestErasureCodePluginJerasure.cc +++ b/src/test/erasure-code/TestErasureCodePluginJerasure.cc @@ -20,7 +20,7 @@ #include "erasure-code/ErasureCodePlugin.h" #include "log/Log.h" #include "global/global_context.h" -#include "common/config.h" +#include "common/config_proxy.h" #include "gtest/gtest.h" TEST(ErasureCodePlugin, factory) @@ -31,7 +31,7 @@ TEST(ErasureCodePlugin, factory) ErasureCodeInterfaceRef erasure_code; EXPECT_FALSE(erasure_code); EXPECT_EQ(-ENOENT, instance.factory("jerasure", - g_conf->get_val<std::string>("erasure_code_dir"), + g_conf().get_val<std::string>("erasure_code_dir"), profile, &erasure_code, &cerr)); EXPECT_FALSE(erasure_code); @@ -52,7 +52,7 @@ TEST(ErasureCodePlugin, factory) profile["technique"] = *technique; EXPECT_FALSE(erasure_code); EXPECT_EQ(0, instance.factory("jerasure", - g_conf->get_val<std::string>("erasure_code_dir"), + g_conf().get_val<std::string>("erasure_code_dir"), profile, &erasure_code, &cerr)); EXPECT_TRUE(erasure_code.get()); diff --git a/src/test/erasure-code/TestErasureCodePluginLrc.cc b/src/test/erasure-code/TestErasureCodePluginLrc.cc index 2b9b5c19f21..4df3711a1f1 100644 --- a/src/test/erasure-code/TestErasureCodePluginLrc.cc +++ b/src/test/erasure-code/TestErasureCodePluginLrc.cc @@ -21,7 +21,7 @@ #include "arch/intel.h" #include "erasure-code/ErasureCodePlugin.h" #include "global/global_context.h" -#include "common/config.h" +#include "common/config_proxy.h" #include "gtest/gtest.h" @@ -34,7 +34,7 @@ TEST(ErasureCodePlugin, factory) ErasureCodeInterfaceRef erasure_code; EXPECT_FALSE(erasure_code); EXPECT_EQ(0, instance.factory("lrc", - g_conf->get_val<std::string>("erasure_code_dir"), + g_conf().get_val<std::string>("erasure_code_dir"), profile, &erasure_code, &cerr)); EXPECT_TRUE(erasure_code.get()); } diff --git a/src/test/erasure-code/TestErasureCodePluginShec.cc b/src/test/erasure-code/TestErasureCodePluginShec.cc index 603f34fc9ef..10088343b0a 100644 --- a/src/test/erasure-code/TestErasureCodePluginShec.cc +++ b/src/test/erasure-code/TestErasureCodePluginShec.cc @@ -21,7 +21,7 @@ #include "erasure-code/ErasureCodePlugin.h" #include "global/global_context.h" #include "gtest/gtest.h" -#include "common/config.h" +#include "common/config_proxy.h" TEST(ErasureCodePlugin, factory) { @@ -31,7 +31,7 @@ TEST(ErasureCodePlugin, factory) ErasureCodeInterfaceRef erasure_code; EXPECT_FALSE(erasure_code); EXPECT_EQ(0, instance.factory("shec", - g_conf->get_val<std::string>("erasure_code_dir"), + g_conf().get_val<std::string>("erasure_code_dir"), profile, &erasure_code, &cerr)); EXPECT_TRUE(erasure_code.get()); @@ -46,7 +46,7 @@ TEST(ErasureCodePlugin, factory) profile["technique"] = *technique; EXPECT_FALSE(erasure_code); EXPECT_EQ(0, instance.factory("shec", - g_conf->get_val<std::string>("erasure_code_dir"), + g_conf().get_val<std::string>("erasure_code_dir"), profile, &erasure_code, &cerr)); EXPECT_TRUE(erasure_code.get()); diff --git a/src/test/erasure-code/ceph_erasure_code.cc b/src/test/erasure-code/ceph_erasure_code.cc index 9b52eb6d488..19eef327cb4 100644 --- a/src/test/erasure-code/ceph_erasure_code.cc +++ b/src/test/erasure-code/ceph_erasure_code.cc @@ -89,7 +89,7 @@ int ErasureCodeCommand::setup(int argc, char** argv) { CODE_ENVIRONMENT_UTILITY, CINIT_FLAG_NO_MON_CONFIG); common_init_finish(g_ceph_context); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.apply_changes(nullptr); if (vm.count("help")) { cout << desc << std::endl; @@ -128,7 +128,7 @@ int ErasureCodeCommand::plugin_exists() { Mutex::Locker l(instance.lock); stringstream ss; int code = instance.load(vm["plugin_exists"].as<string>(), - g_conf->get_val<std::string>("erasure_code_dir"), &plugin, &ss); + g_conf().get_val<std::string>("erasure_code_dir"), &plugin, &ss); if (code) cerr << ss.str() << endl; return code; @@ -144,7 +144,7 @@ int ErasureCodeCommand::display_information() { } int code = instance.factory(profile["plugin"], - g_conf->get_val<std::string>("erasure_code_dir"), + g_conf().get_val<std::string>("erasure_code_dir"), profile, &erasure_code, &cerr); if (code) diff --git a/src/test/erasure-code/ceph_erasure_code_benchmark.cc b/src/test/erasure-code/ceph_erasure_code_benchmark.cc index f74f393abac..7dbdf171155 100644 --- a/src/test/erasure-code/ceph_erasure_code_benchmark.cc +++ b/src/test/erasure-code/ceph_erasure_code_benchmark.cc @@ -87,7 +87,7 @@ int ErasureCodeBench::setup(int argc, char** argv) { CODE_ENVIRONMENT_UTILITY, CINIT_FLAG_NO_DEFAULT_CONFIG_FILE); common_init_finish(g_ceph_context); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.apply_changes(nullptr); if (vm.count("help")) { cout << desc << std::endl; @@ -154,7 +154,7 @@ int ErasureCodeBench::encode() ErasureCodeInterfaceRef erasure_code; stringstream messages; int code = instance.factory(plugin, - g_conf->get_val<std::string>("erasure_code_dir"), + g_conf().get_val<std::string>("erasure_code_dir"), profile, &erasure_code, &messages); if (code) { cerr << messages.str() << endl; @@ -258,7 +258,7 @@ int ErasureCodeBench::decode() ErasureCodeInterfaceRef erasure_code; stringstream messages; int code = instance.factory(plugin, - g_conf->get_val<std::string>("erasure_code_dir"), + g_conf().get_val<std::string>("erasure_code_dir"), profile, &erasure_code, &messages); if (code) { cerr << messages.str() << endl; diff --git a/src/test/erasure-code/ceph_erasure_code_non_regression.cc b/src/test/erasure-code/ceph_erasure_code_non_regression.cc index 58af60a7ee3..410bb5ec117 100644 --- a/src/test/erasure-code/ceph_erasure_code_non_regression.cc +++ b/src/test/erasure-code/ceph_erasure_code_non_regression.cc @@ -96,7 +96,7 @@ int ErasureCodeNonRegression::setup(int argc, char** argv) { CODE_ENVIRONMENT_UTILITY, CINIT_FLAG_NO_MON_CONFIG); common_init_finish(g_ceph_context); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.apply_changes(nullptr); if (vm.count("help")) { cout << desc << std::endl; @@ -155,7 +155,7 @@ int ErasureCodeNonRegression::run_create() ErasureCodeInterfaceRef erasure_code; stringstream messages; int code = instance.factory(plugin, - g_conf->get_val<std::string>("erasure_code_dir"), + g_conf().get_val<std::string>("erasure_code_dir"), profile, &erasure_code, &messages); if (code) { cerr << messages.str() << endl; @@ -227,7 +227,7 @@ int ErasureCodeNonRegression::run_check() ErasureCodeInterfaceRef erasure_code; stringstream messages; int code = instance.factory(plugin, - g_conf->get_val<std::string>("erasure_code_dir"), + g_conf().get_val<std::string>("erasure_code_dir"), profile, &erasure_code, &messages); if (code) { cerr << messages.str() << endl; diff --git a/src/test/filestore/TestFileStore.cc b/src/test/filestore/TestFileStore.cc index 9b095e838c3..88ec02f484e 100644 --- a/src/test/filestore/TestFileStore.cc +++ b/src/test/filestore/TestFileStore.cc @@ -72,8 +72,8 @@ int main(int argc, char **argv) { CODE_ENVIRONMENT_UTILITY, CINIT_FLAG_NO_DEFAULT_CONFIG_FILE); common_init_finish(g_ceph_context); - g_ceph_context->_conf->set_val("osd_journal_size", "100"); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.set_val("osd_journal_size", "100"); + g_ceph_context->_conf.apply_changes(NULL); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); diff --git a/src/test/fio/fio_ceph_objectstore.cc b/src/test/fio/fio_ceph_objectstore.cc index 8f092d40aff..61c028aa4f9 100644 --- a/src/test/fio/fio_ceph_objectstore.cc +++ b/src/test/fio/fio_ceph_objectstore.cc @@ -276,7 +276,7 @@ struct Engine { cct->get_perfcounters_collection()->dump_formatted(f, false); ostr << "FIO plugin "; f->flush(ostr); - if (g_conf->rocksdb_perf) { + if (g_conf()->rocksdb_perf) { os->get_db_statistics(f); ostr << "FIO get_db_statistics "; f->flush(ostr); @@ -327,19 +327,19 @@ Engine::Engine(thread_data* td) // create the ObjectStore os.reset(ObjectStore::create(g_ceph_context, - g_conf->osd_objectstore, - g_conf->osd_data, - g_conf->osd_journal)); + g_conf()->osd_objectstore, + g_conf()->osd_data, + g_conf()->osd_journal)); if (!os) - throw std::runtime_error("bad objectstore type " + g_conf->osd_objectstore); + throw std::runtime_error("bad objectstore type " + g_conf()->osd_objectstore); unsigned num_shards; - if(g_conf->osd_op_num_shards) - num_shards = g_conf->osd_op_num_shards; + if(g_conf()->osd_op_num_shards) + num_shards = g_conf()->osd_op_num_shards; else if(os->is_rotational()) - num_shards = g_conf->osd_op_num_shards_hdd; + num_shards = g_conf()->osd_op_num_shards_hdd; else - num_shards = g_conf->osd_op_num_shards_ssd; + num_shards = g_conf()->osd_op_num_shards_ssd; os->set_cache_shards(num_shards); //normalize options @@ -363,7 +363,7 @@ Engine::Engine(thread_data* td) // create shared collections up to osd_pool_default_pg_num if (o->single_pool_mode) { - uint64_t count = g_conf->get_val<uint64_t>("osd_pool_default_pg_num"); + uint64_t count = g_conf()->get_val<uint64_t>("osd_pool_default_pg_num"); if (count > td->o.nr_files) count = td->o.nr_files; init_collections(os, Collection::MIN_POOL_ID, collections, count); @@ -417,7 +417,7 @@ Job::Job(Engine* engine, const thread_data* td) std::vector<Collection>* colls; // create private collections up to osd_pool_default_pg_num if (!o->single_pool_mode) { - uint64_t count = g_conf->get_val<uint64_t>("osd_pool_default_pg_num"); + uint64_t count = g_conf()->get_val<uint64_t>("osd_pool_default_pg_num"); if (count > td->o.nr_files) count = td->o.nr_files; // use the fio thread_number for our unique pool id @@ -606,18 +606,18 @@ enum fio_q_status fio_ceph_os_queue(thread_data* td, io_u* u) if (o->pglog_omap_len_high && pglog_ver_cnt >= coll.pglog_ver_tail + - g_conf->osd_min_pg_log_entries + g_conf->osd_pg_log_trim_min) { + g_conf()->osd_min_pg_log_entries + g_conf()->osd_pg_log_trim_min) { pglog_trim_tail = coll.pglog_ver_tail; coll.pglog_ver_tail = pglog_trim_head = - pglog_trim_tail + g_conf->osd_pg_log_trim_min; + pglog_trim_tail + g_conf()->osd_pg_log_trim_min; if (o->pglog_dup_omap_len_high && pglog_ver_cnt >= - coll.pglog_dup_ver_tail + g_conf->osd_pg_log_dups_tracked + - g_conf->osd_pg_log_trim_min) { + coll.pglog_dup_ver_tail + g_conf()->osd_pg_log_dups_tracked + + g_conf()->osd_pg_log_trim_min) { pglog_dup_trim_tail = coll.pglog_dup_ver_tail; coll.pglog_dup_ver_tail = pglog_dup_trim_head = - pglog_dup_trim_tail + g_conf->osd_pg_log_trim_min; + pglog_dup_trim_tail + g_conf()->osd_pg_log_trim_min; } } } diff --git a/src/test/journal/test_main.cc b/src/test/journal/test_main.cc index 7808aa68322..afb535d3111 100644 --- a/src/test/journal/test_main.cc +++ b/src/test/journal/test_main.cc @@ -4,7 +4,7 @@ #include "gtest/gtest.h" #include "common/ceph_argparse.h" #include "common/ceph_crypto.h" -#include "common/config.h" +#include "common/config_proxy.h" #include "global/global_context.h" #include "global/global_init.h" #include <vector> @@ -19,7 +19,7 @@ int main(int argc, char **argv) auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_OSD, CODE_ENVIRONMENT_UTILITY, CINIT_FLAG_NO_MON_CONFIG); - g_conf->set_val("lockdep", "true"); + g_conf().set_val("lockdep", "true"); common_init_finish(g_ceph_context); int r = RUN_ALL_TESTS(); diff --git a/src/test/librados/misc.cc b/src/test/librados/misc.cc index 152c61512b9..aa6f7691052 100644 --- a/src/test/librados/misc.cc +++ b/src/test/librados/misc.cc @@ -168,7 +168,7 @@ TEST_F(LibRadosMiscPP, WaitOSDMapPP) { TEST_F(LibRadosMiscPP, LongNamePP) { bufferlist bl; bl.append("content"); - int maxlen = g_conf->osd_max_object_name_len; + int maxlen = g_conf()->osd_max_object_name_len; ASSERT_EQ(0, ioctx.write(string(maxlen/2, 'a').c_str(), bl, bl.length(), 0)); ASSERT_EQ(0, ioctx.write(string(maxlen-1, 'a').c_str(), bl, bl.length(), 0)); ASSERT_EQ(0, ioctx.write(string(maxlen, 'a').c_str(), bl, bl.length(), 0)); @@ -179,7 +179,7 @@ TEST_F(LibRadosMiscPP, LongNamePP) { TEST_F(LibRadosMiscPP, LongLocatorPP) { bufferlist bl; bl.append("content"); - int maxlen = g_conf->osd_max_object_name_len; + int maxlen = g_conf()->osd_max_object_name_len; ioctx.locator_set_key( string((maxlen/2), 'a')); ASSERT_EQ( @@ -220,7 +220,7 @@ TEST_F(LibRadosMiscPP, LongLocatorPP) { TEST_F(LibRadosMiscPP, LongNSpacePP) { bufferlist bl; bl.append("content"); - int maxlen = g_conf->osd_max_object_namespace_len; + int maxlen = g_conf()->osd_max_object_namespace_len; ioctx.set_namespace( string((maxlen/2), 'a')); ASSERT_EQ( @@ -261,7 +261,7 @@ TEST_F(LibRadosMiscPP, LongNSpacePP) { TEST_F(LibRadosMiscPP, LongAttrNamePP) { bufferlist bl; bl.append("content"); - int maxlen = g_conf->osd_max_attr_name_len; + int maxlen = g_conf()->osd_max_attr_name_len; ASSERT_EQ(0, ioctx.setxattr("bigattrobj", string(maxlen/2, 'a').c_str(), bl)); ASSERT_EQ(0, ioctx.setxattr("bigattrobj", string(maxlen-1, 'a').c_str(), bl)); ASSERT_EQ(0, ioctx.setxattr("bigattrobj", string(maxlen, 'a').c_str(), bl)); @@ -733,17 +733,17 @@ TEST_F(LibRadosMiscPP, BigAttrPP) { bufferlist got; - cout << "osd_max_attr_size = " << g_conf->osd_max_attr_size << std::endl; - if (g_conf->osd_max_attr_size) { + cout << "osd_max_attr_size = " << g_conf()->osd_max_attr_size << std::endl; + if (g_conf()->osd_max_attr_size) { bl.clear(); got.clear(); - bl.append(buffer::create(g_conf->osd_max_attr_size)); + bl.append(buffer::create(g_conf()->osd_max_attr_size)); ASSERT_EQ(0, ioctx.setxattr("foo", "one", bl)); ASSERT_EQ((int)bl.length(), ioctx.getxattr("foo", "one", got)); ASSERT_TRUE(bl.contents_equal(got)); bl.clear(); - bl.append(buffer::create(g_conf->osd_max_attr_size+1)); + bl.append(buffer::create(g_conf()->osd_max_attr_size+1)); ASSERT_EQ(-EFBIG, ioctx.setxattr("foo", "one", bl)); } else { cout << "osd_max_attr_size == 0; skipping test" << std::endl; @@ -752,7 +752,7 @@ TEST_F(LibRadosMiscPP, BigAttrPP) { for (int i=0; i<1000; i++) { bl.clear(); got.clear(); - bl.append(buffer::create(std::min<uint64_t>(g_conf->osd_max_attr_size, + bl.append(buffer::create(std::min<uint64_t>(g_conf()->osd_max_attr_size, 1024))); char n[10]; snprintf(n, sizeof(n), "a%d", i); @@ -812,7 +812,7 @@ TEST_F(LibRadosMiscPP, CopyPP) { } // do a big object - bl.append(buffer::create(g_conf->osd_copyfrom_max_chunk * 3)); + bl.append(buffer::create(g_conf()->osd_copyfrom_max_chunk * 3)); bl.zero(); bl.append("tail"); blc = bl; @@ -923,7 +923,7 @@ TEST_F(LibRadosMiscPP, CopyScrubPP) { bufferlist inbl, bl, x; for (int i=0; i<100; ++i) x.append("barrrrrrrrrrrrrrrrrrrrrrrrrr"); - bl.append(buffer::create(g_conf->osd_copyfrom_max_chunk * 3)); + bl.append(buffer::create(g_conf()->osd_copyfrom_max_chunk * 3)); bl.zero(); bl.append("tail"); bufferlist cbl; diff --git a/src/test/librados/service.cc b/src/test/librados/service.cc index afb4ee23d8c..da37fb3d62f 100644 --- a/src/test/librados/service.cc +++ b/src/test/librados/service.cc @@ -1,8 +1,9 @@ #include "include/rados/librados.h" #include "include/rados/librados.hpp" +#include "include/stringify.h" +#include "common/config_proxy.h" #include "test/librados/test.h" #include "test/librados/TestCase.h" -#include "include/stringify.h" #include <algorithm> #include <thread> @@ -134,8 +135,8 @@ TEST(LibRadosServicePP, Close) { cluster.shutdown(); } // mgr updates servicemap every tick - //sleep(g_conf->get_val<int64_t>("mgr_tick_period")); - std::this_thread::sleep_for(g_conf->get_val<std::chrono::seconds>( + //sleep(g_conf().get_val<int64_t>("mgr_tick_period")); + std::this_thread::sleep_for(g_conf().get_val<std::chrono::seconds>( "mgr_tick_period")); // make sure we are deregistered { diff --git a/src/test/librbd/managed_lock/test_mock_AcquireRequest.cc b/src/test/librbd/managed_lock/test_mock_AcquireRequest.cc index b270ba4ab9d..986849e6428 100644 --- a/src/test/librbd/managed_lock/test_mock_AcquireRequest.cc +++ b/src/test/librbd/managed_lock/test_mock_AcquireRequest.cc @@ -34,9 +34,9 @@ struct BreakRequest<librbd::MockImageCtx> { uint32_t blacklist_expire_seconds, bool force_break_lock, Context *on_finish) { CephContext *cct = reinterpret_cast<CephContext *>(ioctx.cct()); - EXPECT_EQ(cct->_conf->get_val<bool>("rbd_blacklist_on_break_lock"), + EXPECT_EQ(cct->_conf.get_val<bool>("rbd_blacklist_on_break_lock"), blacklist_locker); - EXPECT_EQ(cct->_conf->get_val<int64_t>("rbd_blacklist_expire_seconds"), + EXPECT_EQ(cct->_conf.get_val<int64_t>("rbd_blacklist_expire_seconds"), (int)blacklist_expire_seconds); EXPECT_FALSE(force_break_lock); assert(s_instance != nullptr); diff --git a/src/test/messenger/simple_client.cc b/src/test/messenger/simple_client.cc index 276371a2ab5..a0c4559c4d8 100644 --- a/src/test/messenger/simple_client.cc +++ b/src/test/messenger/simple_client.cc @@ -102,7 +102,7 @@ int main(int argc, const char **argv) "initial msgs (pipe depth) " << n_msgs << " " << "data buffer size " << n_dsize << std::endl; - messenger = Messenger::create(g_ceph_context, g_conf->get_val<std::string>("ms_type"), + messenger = Messenger::create(g_ceph_context, g_conf().get_val<std::string>("ms_type"), entity_name_t::MON(-1), "client", getpid(), 0); diff --git a/src/test/messenger/simple_server.cc b/src/test/messenger/simple_server.cc index ba54879ea88..8b85f3afbcf 100644 --- a/src/test/messenger/simple_server.cc +++ b/src/test/messenger/simple_server.cc @@ -73,7 +73,7 @@ int main(int argc, const char **argv) dest_str += port; entity_addr_from_url(&bind_addr, dest_str.c_str()); - messenger = Messenger::create(g_ceph_context, g_conf->get_val<std::string>("ms_type"), + messenger = Messenger::create(g_ceph_context, g_conf().get_val<std::string>("ms_type"), entity_name_t::MON(-1), "simple_server", 0 /* nonce */, diff --git a/src/test/mon/MonMap.cc b/src/test/mon/MonMap.cc index 52ae30161f0..2b09f33e758 100644 --- a/src/test/mon/MonMap.cc +++ b/src/test/mon/MonMap.cc @@ -97,7 +97,7 @@ TEST_F(MonMapTest, build_initial_config_from_dns) { CephContext *cct = (new CephContext(CEPH_ENTITY_TYPE_MON))->get(); - cct->_conf->set_val("mon_dns_srv_name", "cephmon"); + cct->_conf.set_val("mon_dns_srv_name", "cephmon"); MonMap monmap; int r = monmap.build_initial(cct, std::cerr); @@ -195,7 +195,7 @@ TEST_F(MonMapTest, build_initial_config_from_dns_with_domain) { CephContext *cct = (new CephContext(CEPH_ENTITY_TYPE_MON))->get(); - cct->_conf->set_val("mon_dns_srv_name", "cephmon_ceph.com"); + cct->_conf.set_val("mon_dns_srv_name", "cephmon_ceph.com"); MonMap monmap; int r = monmap.build_initial(cct, std::cerr); diff --git a/src/test/mon/test-mon-msg.cc b/src/test/mon/test-mon-msg.cc index f033e859af1..0afa9844395 100644 --- a/src/test/mon/test-mon-msg.cc +++ b/src/test/mon/test-mon-msg.cc @@ -80,7 +80,7 @@ public: int init_messenger() { dout(1) << __func__ << dendl; - std::string public_msgr_type = cct->_conf->ms_public_type.empty() ? cct->_conf->get_val<std::string>("ms_type") : cct->_conf->ms_public_type; + std::string public_msgr_type = cct->_conf->ms_public_type.empty() ? cct->_conf.get_val<std::string>("ms_type") : cct->_conf->ms_public_type; msg = Messenger::create(cct, public_msgr_type, entity_name_t::CLIENT(-1), "test-mon-msg", 0, 0); assert(msg != NULL); @@ -331,7 +331,7 @@ int main(int argc, char *argv[]) CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, CINIT_FLAG_NO_DEFAULT_CONFIG_FILE); common_init_finish(g_ceph_context); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.apply_changes(nullptr); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); diff --git a/src/test/mon/test_mon_workloadgen.cc b/src/test/mon/test_mon_workloadgen.cc index 1b968d33650..2f976a4e132 100644 --- a/src/test/mon/test_mon_workloadgen.cc +++ b/src/test/mon/test_mon_workloadgen.cc @@ -361,12 +361,12 @@ class OSDStub : public TestStub << cct->_conf->auth_supported << dendl; stringstream ss; ss << "client-osd" << whoami; - std::string public_msgr_type = cct->_conf->ms_public_type.empty() ? cct->_conf->get_val<std::string>("ms_type") : cct->_conf->ms_public_type; + std::string public_msgr_type = cct->_conf->ms_public_type.empty() ? cct->_conf.get_val<std::string>("ms_type") : cct->_conf->ms_public_type; messenger.reset(Messenger::create(cct, public_msgr_type, entity_name_t::OSD(whoami), ss.str().c_str(), getpid(), 0)); Throttle throttler(g_ceph_context, "osd_client_bytes", - g_conf->osd_client_message_size_cap); + g_conf()->osd_client_message_size_cap); messenger->set_default_policy( Messenger::Policy::stateless_server(0)); @@ -380,8 +380,8 @@ class OSDStub : public TestStub messenger->set_policy(entity_name_t::TYPE_OSD, Messenger::Policy::stateless_server(0)); - dout(10) << __func__ << " public addr " << g_conf->public_addr << dendl; - int err = messenger->bind(g_conf->public_addr); + dout(10) << __func__ << " public addr " << g_conf()->public_addr << dendl; + int err = messenger->bind(g_conf()->public_addr); if (err < 0) exit(1); @@ -397,8 +397,8 @@ class OSDStub : public TestStub Mutex::Locker l(lock); dout(1) << __func__ << " fsid " << monc.monmap.fsid - << " osd_fsid " << g_conf->osd_uuid << dendl; - dout(1) << __func__ << " name " << g_conf->name << dendl; + << " osd_fsid " << g_conf()->osd_uuid << dendl; + dout(1) << __func__ << " name " << g_conf()->name << dendl; timer.init(); messenger->add_dispatcher_head(this); @@ -1001,7 +1001,7 @@ int main(int argc, const char *argv[]) CINIT_FLAG_NO_DEFAULT_CONFIG_FILE); common_init_finish(g_ceph_context); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.apply_changes(nullptr); set<int> stub_ids; double duration = 300.0; diff --git a/src/test/msgr/perf_msgr_client.cc b/src/test/msgr/perf_msgr_client.cc index 1442b05784a..e247fca5e91 100644 --- a/src/test/msgr/perf_msgr_client.cc +++ b/src/test/msgr/perf_msgr_client.cc @@ -183,7 +183,7 @@ int main(int argc, char **argv) CODE_ENVIRONMENT_UTILITY, CINIT_FLAG_NO_DEFAULT_CONFIG_FILE); common_init_finish(g_ceph_context); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.apply_changes(nullptr); if (args.size() < 6) { usage(argv[0]); @@ -196,7 +196,7 @@ int main(int argc, char **argv) int think_time = atoi(args[4]); int len = atoi(args[5]); - std::string public_msgr_type = g_ceph_context->_conf->ms_public_type.empty() ? g_ceph_context->_conf->get_val<std::string>("ms_type") : g_ceph_context->_conf->ms_public_type; + std::string public_msgr_type = g_ceph_context->_conf->ms_public_type.empty() ? g_ceph_context->_conf.get_val<std::string>("ms_type") : g_ceph_context->_conf->ms_public_type; cerr << " using ms-public-type " << public_msgr_type << std::endl; cerr << " server ip:port " << args[0] << std::endl; diff --git a/src/test/msgr/perf_msgr_server.cc b/src/test/msgr/perf_msgr_server.cc index 7df732853da..fc7ff16ca4b 100644 --- a/src/test/msgr/perf_msgr_server.cc +++ b/src/test/msgr/perf_msgr_server.cc @@ -149,7 +149,7 @@ int main(int argc, char **argv) CODE_ENVIRONMENT_UTILITY, CINIT_FLAG_NO_DEFAULT_CONFIG_FILE); common_init_finish(g_ceph_context); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.apply_changes(nullptr); if (args.size() < 3) { usage(argv[0]); @@ -158,7 +158,7 @@ int main(int argc, char **argv) int worker_threads = atoi(args[1]); int think_time = atoi(args[2]); - std::string public_msgr_type = g_ceph_context->_conf->ms_public_type.empty() ? g_ceph_context->_conf->get_val<std::string>("ms_type") : g_ceph_context->_conf->ms_public_type; + std::string public_msgr_type = g_ceph_context->_conf->ms_public_type.empty() ? g_ceph_context->_conf.get_val<std::string>("ms_type") : g_ceph_context->_conf->ms_public_type; cerr << " This tool won't handle connection error alike things, " << std::endl; cerr << "please ensure the proper network environment to test." << std::endl; diff --git a/src/test/msgr/test_async_networkstack.cc b/src/test/msgr/test_async_networkstack.cc index 9bd9f611cc9..921539b1f9b 100644 --- a/src/test/msgr/test_async_networkstack.cc +++ b/src/test/msgr/test_async_networkstack.cc @@ -53,7 +53,7 @@ public: const char** get_tracked_conf_keys() const override { return ptrs; } - void handle_conf_change(const md_config_t *conf, + void handle_conf_change(const ConfigProxy& conf, const std::set <std::string> &changed) override { } }; @@ -73,17 +73,17 @@ class NetworkWorkerTest : public ::testing::TestWithParam<const char*> { void SetUp() override { cerr << __func__ << " start set up " << GetParam() << std::endl; if (strncmp(GetParam(), "dpdk", 4)) { - g_ceph_context->_conf->set_val("ms_type", "async+posix"); + g_ceph_context->_conf.set_val("ms_type", "async+posix"); addr = "127.0.0.1:15000"; port_addr = "127.0.0.1:15001"; } else { - g_ceph_context->_conf->set_val_or_die("ms_type", "async+dpdk"); - g_ceph_context->_conf->set_val_or_die("ms_dpdk_debug_allow_loopback", "true"); - g_ceph_context->_conf->set_val_or_die("ms_async_op_threads", "2"); - g_ceph_context->_conf->set_val_or_die("ms_dpdk_coremask", "0x7"); - g_ceph_context->_conf->set_val_or_die("ms_dpdk_host_ipv4_addr", "172.16.218.3"); - g_ceph_context->_conf->set_val_or_die("ms_dpdk_gateway_ipv4_addr", "172.16.218.2"); - g_ceph_context->_conf->set_val_or_die("ms_dpdk_netmask_ipv4_addr", "255.255.255.0"); + g_ceph_context->_conf.set_val_or_die("ms_type", "async+dpdk"); + g_ceph_context->_conf.set_val_or_die("ms_dpdk_debug_allow_loopback", "true"); + g_ceph_context->_conf.set_val_or_die("ms_async_op_threads", "2"); + g_ceph_context->_conf.set_val_or_die("ms_dpdk_coremask", "0x7"); + g_ceph_context->_conf.set_val_or_die("ms_dpdk_host_ipv4_addr", "172.16.218.3"); + g_ceph_context->_conf.set_val_or_die("ms_dpdk_gateway_ipv4_addr", "172.16.218.2"); + g_ceph_context->_conf.set_val_or_die("ms_dpdk_netmask_ipv4_addr", "255.255.255.0"); addr = "172.16.218.3:15000"; port_addr = "172.16.218.3:15001"; } diff --git a/src/test/msgr/test_msgr.cc b/src/test/msgr/test_msgr.cc index 159279c8c7c..c4cafa9c022 100644 --- a/src/test/msgr/test_msgr.cc +++ b/src/test/msgr/test_msgr.cc @@ -390,7 +390,7 @@ TEST_P(MessengerTest, FeatureTest) { } TEST_P(MessengerTest, TimeoutTest) { - g_ceph_context->_conf->set_val("ms_tcp_read_timeout", "1"); + g_ceph_context->_conf.set_val("ms_tcp_read_timeout", "1"); FakeDispatcher cli_dispatcher(false), srv_dispatcher(true); entity_addr_t bind_addr; bind_addr.parse("127.0.0.1"); @@ -425,7 +425,7 @@ TEST_P(MessengerTest, TimeoutTest) { client_msgr->shutdown(); client_msgr->wait(); - g_ceph_context->_conf->set_val("ms_tcp_read_timeout", "900"); + g_ceph_context->_conf.set_val("ms_tcp_read_timeout", "900"); } TEST_P(MessengerTest, StatefulTest) { @@ -677,9 +677,9 @@ TEST_P(MessengerTest, ClientStandbyTest) { } TEST_P(MessengerTest, AuthTest) { - g_ceph_context->_conf->set_val("auth_cluster_required", "cephx"); - g_ceph_context->_conf->set_val("auth_service_required", "cephx"); - g_ceph_context->_conf->set_val("auth_client_required", "cephx"); + g_ceph_context->_conf.set_val("auth_cluster_required", "cephx"); + g_ceph_context->_conf.set_val("auth_service_required", "cephx"); + g_ceph_context->_conf.set_val("auth_client_required", "cephx"); FakeDispatcher cli_dispatcher(false), srv_dispatcher(true); entity_addr_t bind_addr; bind_addr.parse("127.0.0.1"); @@ -705,9 +705,9 @@ TEST_P(MessengerTest, AuthTest) { ASSERT_EQ(1U, static_cast<Session*>(conn->get_priv().get())->get_count()); // 2. mix auth - g_ceph_context->_conf->set_val("auth_cluster_required", "none"); - g_ceph_context->_conf->set_val("auth_service_required", "none"); - g_ceph_context->_conf->set_val("auth_client_required", "none"); + g_ceph_context->_conf.set_val("auth_cluster_required", "none"); + g_ceph_context->_conf.set_val("auth_service_required", "none"); + g_ceph_context->_conf.set_val("auth_client_required", "none"); conn->mark_down(); ASSERT_FALSE(conn->is_connected()); conn = client_msgr->connect_to(server_msgr->get_mytype(), @@ -1253,9 +1253,9 @@ TEST_P(MessengerTest, SyntheticStressTest1) { TEST_P(MessengerTest, SyntheticInjectTest) { uint64_t dispatch_throttle_bytes = g_ceph_context->_conf->ms_dispatch_throttle_bytes; - g_ceph_context->_conf->set_val("ms_inject_socket_failures", "30"); - g_ceph_context->_conf->set_val("ms_inject_internal_delays", "0.1"); - g_ceph_context->_conf->set_val("ms_dispatch_throttle_bytes", "16777216"); + g_ceph_context->_conf.set_val("ms_inject_socket_failures", "30"); + g_ceph_context->_conf.set_val("ms_inject_internal_delays", "0.1"); + g_ceph_context->_conf.set_val("ms_dispatch_throttle_bytes", "16777216"); SyntheticWorkload test_msg(8, 32, GetParam(), 100, Messenger::Policy::stateful_server(0), Messenger::Policy::lossless_client(0)); @@ -1282,15 +1282,15 @@ TEST_P(MessengerTest, SyntheticInjectTest) { } } test_msg.wait_for_done(); - g_ceph_context->_conf->set_val("ms_inject_socket_failures", "0"); - g_ceph_context->_conf->set_val("ms_inject_internal_delays", "0"); - g_ceph_context->_conf->set_val( + g_ceph_context->_conf.set_val("ms_inject_socket_failures", "0"); + g_ceph_context->_conf.set_val("ms_inject_internal_delays", "0"); + g_ceph_context->_conf.set_val( "ms_dispatch_throttle_bytes", std::to_string(dispatch_throttle_bytes)); } TEST_P(MessengerTest, SyntheticInjectTest2) { - g_ceph_context->_conf->set_val("ms_inject_socket_failures", "30"); - g_ceph_context->_conf->set_val("ms_inject_internal_delays", "0.1"); + g_ceph_context->_conf.set_val("ms_inject_socket_failures", "30"); + g_ceph_context->_conf.set_val("ms_inject_internal_delays", "0.1"); SyntheticWorkload test_msg(8, 16, GetParam(), 100, Messenger::Policy::lossless_peer_reuse(0), Messenger::Policy::lossless_peer_reuse(0)); @@ -1317,13 +1317,13 @@ TEST_P(MessengerTest, SyntheticInjectTest2) { } } test_msg.wait_for_done(); - g_ceph_context->_conf->set_val("ms_inject_socket_failures", "0"); - g_ceph_context->_conf->set_val("ms_inject_internal_delays", "0"); + g_ceph_context->_conf.set_val("ms_inject_socket_failures", "0"); + g_ceph_context->_conf.set_val("ms_inject_internal_delays", "0"); } TEST_P(MessengerTest, SyntheticInjectTest3) { - g_ceph_context->_conf->set_val("ms_inject_socket_failures", "600"); - g_ceph_context->_conf->set_val("ms_inject_internal_delays", "0.1"); + g_ceph_context->_conf.set_val("ms_inject_socket_failures", "600"); + g_ceph_context->_conf.set_val("ms_inject_internal_delays", "0.1"); SyntheticWorkload test_msg(8, 16, GetParam(), 100, Messenger::Policy::stateless_server(0), Messenger::Policy::lossy_client(0)); @@ -1350,17 +1350,17 @@ TEST_P(MessengerTest, SyntheticInjectTest3) { } } test_msg.wait_for_done(); - g_ceph_context->_conf->set_val("ms_inject_socket_failures", "0"); - g_ceph_context->_conf->set_val("ms_inject_internal_delays", "0"); + g_ceph_context->_conf.set_val("ms_inject_socket_failures", "0"); + g_ceph_context->_conf.set_val("ms_inject_internal_delays", "0"); } TEST_P(MessengerTest, SyntheticInjectTest4) { - g_ceph_context->_conf->set_val("ms_inject_socket_failures", "30"); - g_ceph_context->_conf->set_val("ms_inject_internal_delays", "0.1"); - g_ceph_context->_conf->set_val("ms_inject_delay_probability", "1"); - g_ceph_context->_conf->set_val("ms_inject_delay_type", "client osd"); - g_ceph_context->_conf->set_val("ms_inject_delay_max", "5"); + g_ceph_context->_conf.set_val("ms_inject_socket_failures", "30"); + g_ceph_context->_conf.set_val("ms_inject_internal_delays", "0.1"); + g_ceph_context->_conf.set_val("ms_inject_delay_probability", "1"); + g_ceph_context->_conf.set_val("ms_inject_delay_type", "client osd"); + g_ceph_context->_conf.set_val("ms_inject_delay_max", "5"); SyntheticWorkload test_msg(16, 32, GetParam(), 100, Messenger::Policy::lossless_peer(0), Messenger::Policy::lossless_peer(0)); @@ -1387,11 +1387,11 @@ TEST_P(MessengerTest, SyntheticInjectTest4) { } } test_msg.wait_for_done(); - g_ceph_context->_conf->set_val("ms_inject_socket_failures", "0"); - g_ceph_context->_conf->set_val("ms_inject_internal_delays", "0"); - g_ceph_context->_conf->set_val("ms_inject_delay_probability", "0"); - g_ceph_context->_conf->set_val("ms_inject_delay_type", ""); - g_ceph_context->_conf->set_val("ms_inject_delay_max", "0"); + g_ceph_context->_conf.set_val("ms_inject_socket_failures", "0"); + g_ceph_context->_conf.set_val("ms_inject_internal_delays", "0"); + g_ceph_context->_conf.set_val("ms_inject_delay_probability", "0"); + g_ceph_context->_conf.set_val("ms_inject_delay_type", ""); + g_ceph_context->_conf.set_val("ms_inject_delay_max", "0"); } @@ -1556,13 +1556,13 @@ int main(int argc, char **argv) { auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, CINIT_FLAG_NO_DEFAULT_CONFIG_FILE); - g_ceph_context->_conf->set_val("auth_cluster_required", "none"); - g_ceph_context->_conf->set_val("auth_service_required", "none"); - g_ceph_context->_conf->set_val("auth_client_required", "none"); - g_ceph_context->_conf->set_val("enable_experimental_unrecoverable_data_corrupting_features", "ms-type-async"); - g_ceph_context->_conf->set_val("ms_die_on_bad_msg", "true"); - g_ceph_context->_conf->set_val("ms_die_on_old_message", "true"); - g_ceph_context->_conf->set_val("ms_max_backoff", "1"); + g_ceph_context->_conf.set_val("auth_cluster_required", "none"); + g_ceph_context->_conf.set_val("auth_service_required", "none"); + g_ceph_context->_conf.set_val("auth_client_required", "none"); + g_ceph_context->_conf.set_val("enable_experimental_unrecoverable_data_corrupting_features", "ms-type-async"); + g_ceph_context->_conf.set_val("ms_die_on_bad_msg", "true"); + g_ceph_context->_conf.set_val("ms_die_on_old_message", "true"); + g_ceph_context->_conf.set_val("ms_max_backoff", "1"); common_init_finish(g_ceph_context); ::testing::InitGoogleTest(&argc, argv); diff --git a/src/test/objectstore/ObjectStoreTransactionBenchmark.cc b/src/test/objectstore/ObjectStoreTransactionBenchmark.cc index 7a166d7d4d5..5e248cbe21f 100644 --- a/src/test/objectstore/ObjectStoreTransactionBenchmark.cc +++ b/src/test/objectstore/ObjectStoreTransactionBenchmark.cc @@ -250,7 +250,7 @@ int main(int argc, char **argv) CODE_ENVIRONMENT_UTILITY, CINIT_FLAG_NO_DEFAULT_CONFIG_FILE); common_init_finish(g_ceph_context); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.apply_changes(nullptr); Cycles::init(); cerr << "args: " << args << std::endl; diff --git a/src/test/objectstore/chain_xattr.cc b/src/test/objectstore/chain_xattr.cc index 3f0d599b24f..76e7a6c5777 100644 --- a/src/test/objectstore/chain_xattr.cc +++ b/src/test/objectstore/chain_xattr.cc @@ -440,9 +440,9 @@ int main(int argc, char **argv) { CODE_ENVIRONMENT_UTILITY, CINIT_FLAG_NO_DEFAULT_CONFIG_FILE); common_init_finish(g_ceph_context); - g_ceph_context->_conf->set_val("err_to_stderr", "false"); - g_ceph_context->_conf->set_val("log_to_stderr", "false"); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.set_val("err_to_stderr", "false"); + g_ceph_context->_conf.set_val("log_to_stderr", "false"); + g_ceph_context->_conf.apply_changes(nullptr); const char* file = FILENAME; int x = 1234; diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc index 941cc81d12f..dc55ac28600 100644 --- a/src/test/objectstore/store_test.cc +++ b/src/test/objectstore/store_test.cc @@ -152,7 +152,7 @@ public: uint64_t align)> MatrixTest; void StartDeferred(size_t min_alloc_size) { - SetVal(g_conf, "bluestore_min_alloc_size", stringify(min_alloc_size).c_str()); + SetVal(g_conf(), "bluestore_min_alloc_size", stringify(min_alloc_size).c_str()); DeferredSetup(); } @@ -175,7 +175,7 @@ protected: return stringify(num_ops); } else { char *buf; - g_conf->get_val(k, &buf, -1); + g_conf().get_val(k, &buf, -1); string v = buf; free(buf); return v; @@ -192,7 +192,7 @@ protected: } else if (string(k) == "num_ops") { num_ops = atoll(v); } else { - SetVal(g_conf, k, v); + SetVal(g_conf(), k, v); } } @@ -217,7 +217,7 @@ protected: cout << " " << matrix[k][0] << " = " << matrix_get(matrix[k][0]) << std::endl; } - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.apply_changes(nullptr); fn(num_ops, max_size, max_write, alignment); } } @@ -589,7 +589,7 @@ TEST_P(StoreTest, SimpleColPreHashTest) { std::ostringstream oss; if (merge_threshold > 0) { oss << "-" << merge_threshold; - SetVal(g_conf, "filestore_merge_threshold", oss.str().c_str()); + SetVal(g_conf(), "filestore_merge_threshold", oss.str().c_str()); } uint32_t pg_num = 128; @@ -1051,8 +1051,8 @@ void StoreTest::doCompressionTest() EXPECT_EQ(store->mount(), 0); ch = store->open_collection(cid); auto settingsBookmark = BookmarkSettings(); - SetVal(g_conf, "bluestore_compression_min_blob_size", "262144"); - g_ceph_context->_conf->apply_changes(NULL); + SetVal(g_conf(), "bluestore_compression_min_blob_size", "262144"); + g_ceph_context->_conf.apply_changes(nullptr); { data.resize(0x10000*6); @@ -1085,14 +1085,14 @@ TEST_P(StoreTest, CompressionTest) { if (string(GetParam()) != "bluestore") return; - SetVal(g_conf, "bluestore_compression_algorithm", "snappy"); - SetVal(g_conf, "bluestore_compression_mode", "force"); - g_ceph_context->_conf->apply_changes(NULL); + SetVal(g_conf(), "bluestore_compression_algorithm", "snappy"); + SetVal(g_conf(), "bluestore_compression_mode", "force"); + g_ceph_context->_conf.apply_changes(nullptr); doCompressionTest(); - SetVal(g_conf, "bluestore_compression_algorithm", "zlib"); - SetVal(g_conf, "bluestore_compression_mode", "aggressive"); - g_ceph_context->_conf->apply_changes(NULL); + SetVal(g_conf(), "bluestore_compression_algorithm", "zlib"); + SetVal(g_conf(), "bluestore_compression_mode", "aggressive"); + g_ceph_context->_conf.apply_changes(nullptr); doCompressionTest(); } @@ -1316,10 +1316,10 @@ TEST_P(StoreTestSpecificAUSize, BluestoreStatFSTest) { if(string(GetParam()) != "bluestore") return; StartDeferred(65536); - SetVal(g_conf, "bluestore_compression_mode", "force"); + SetVal(g_conf(), "bluestore_compression_mode", "force"); // just a big number to disble gc - SetVal(g_conf, "bluestore_gc_enable_total_threshold", "100000"); - g_conf->apply_changes(NULL); + SetVal(g_conf(), "bluestore_gc_enable_total_threshold", "100000"); + g_conf().apply_changes(nullptr); int r; coll_t cid; @@ -1357,8 +1357,8 @@ TEST_P(StoreTestSpecificAUSize, BluestoreStatFSTest) { ASSERT_EQ(r, 0); ASSERT_EQ( 0u, statfs.allocated); ASSERT_EQ( 0u, statfs.stored); - ASSERT_EQ(g_conf->bluestore_block_size, statfs.total); - ASSERT_TRUE(statfs.available > 0u && statfs.available < g_conf->bluestore_block_size); + ASSERT_EQ(g_conf()->bluestore_block_size, statfs.total); + ASSERT_TRUE(statfs.available > 0u && statfs.available < g_conf()->bluestore_block_size); //force fsck ch.reset(); EXPECT_EQ(store->umount(), 0); @@ -1604,10 +1604,10 @@ TEST_P(StoreTestSpecificAUSize, BluestoreFragmentedBlobTest) { struct store_statfs_t statfs; int r = store->statfs(&statfs); ASSERT_EQ(r, 0); - ASSERT_EQ(g_conf->bluestore_block_size, statfs.total); + ASSERT_EQ(g_conf()->bluestore_block_size, statfs.total); ASSERT_EQ(0u, statfs.allocated); ASSERT_EQ(0u, statfs.stored); - ASSERT_TRUE(statfs.available > 0u && statfs.available < g_conf->bluestore_block_size); + ASSERT_TRUE(statfs.available > 0u && statfs.available < g_conf()->bluestore_block_size); } std::string data; data.resize(0x10000 * 3); @@ -1931,7 +1931,7 @@ TEST_P(StoreTest, AppendDeferredVsTailCache) { r = store->queue_transaction(ch, std::move(t)); ASSERT_EQ(r, 0); } - unsigned min_alloc = g_conf->bluestore_min_alloc_size; + unsigned min_alloc = g_conf()->bluestore_min_alloc_size; unsigned size = min_alloc / 3; bufferptr bpa(size); memset(bpa.c_str(), 1, bpa.length()); @@ -2008,7 +2008,7 @@ TEST_P(StoreTest, AppendZeroTrailingSharedBlock) { r = store->queue_transaction(ch, std::move(t)); ASSERT_EQ(r, 0); } - unsigned min_alloc = g_conf->bluestore_min_alloc_size; + unsigned min_alloc = g_conf()->bluestore_min_alloc_size; unsigned size = min_alloc / 3; bufferptr bpa(size); memset(bpa.c_str(), 1, bpa.length()); @@ -4261,9 +4261,9 @@ void StoreTest::doSyntheticTest( gen_type rng(time(NULL)); coll_t cid(spg_t(pg_t(0,555), shard_id_t::NO_SHARD)); - SetVal(g_conf, "bluestore_fsck_on_mount", "false"); - SetVal(g_conf, "bluestore_fsck_on_umount", "false"); - g_ceph_context->_conf->apply_changes(NULL); + SetVal(g_conf(), "bluestore_fsck_on_mount", "false"); + SetVal(g_conf(), "bluestore_fsck_on_umount", "false"); + g_ceph_context->_conf.apply_changes(nullptr); SyntheticWorkloadState test_obj(store.get(), &gen, &rng, cid, max_obj, max_wr, align); @@ -5538,8 +5538,8 @@ TEST_P(StoreTest, TryMoveRename) { TEST_P(StoreTest, BluestoreOnOffCSumTest) { if (string(GetParam()) != "bluestore") return; - SetVal(g_conf, "bluestore_csum_type", "crc32c"); - g_conf->apply_changes(NULL); + SetVal(g_conf(), "bluestore_csum_type", "crc32c"); + g_conf().apply_changes(nullptr); int r; coll_t cid; @@ -5570,8 +5570,8 @@ TEST_P(StoreTest, BluestoreOnOffCSumTest) { r = queue_transaction(store, ch, std::move(t)); ASSERT_EQ(r, 0); - SetVal(g_conf, "bluestore_csum_type", "none"); - g_conf->apply_changes(NULL); + SetVal(g_conf(), "bluestore_csum_type", "none"); + g_conf().apply_changes(nullptr); bufferlist in; r = store->read(ch, hoid, 0, block_size, in); @@ -5594,8 +5594,8 @@ TEST_P(StoreTest, BluestoreOnOffCSumTest) { r = queue_transaction(store, ch, std::move(t)); ASSERT_EQ(r, 0); - SetVal(g_conf, "bluestore_csum_type", "crc32c"); - g_conf->apply_changes(NULL); + SetVal(g_conf(), "bluestore_csum_type", "crc32c"); + g_conf().apply_changes(nullptr); bufferlist in; r = store->read(ch, hoid, 0, block_size, in); @@ -5616,8 +5616,8 @@ TEST_P(StoreTest, BluestoreOnOffCSumTest) { r = queue_transaction(store, ch, std::move(t)); ASSERT_EQ(r, 0); - SetVal(g_conf, "bluestore_csum_type", "none"); - g_conf->apply_changes(NULL); + SetVal(g_conf(), "bluestore_csum_type", "none"); + g_conf().apply_changes(nullptr); ObjectStore::Transaction t2; t2.write(cid, hoid, block_size*2, bl.length(), bl); @@ -5634,8 +5634,8 @@ TEST_P(StoreTest, BluestoreOnOffCSumTest) { ASSERT_EQ((int)block_size, r); ASSERT_TRUE(bl_eq(orig, in)); - SetVal(g_conf, "bluestore_csum_type", "crc32c"); - g_conf->apply_changes(NULL); + SetVal(g_conf(), "bluestore_csum_type", "crc32c"); + g_conf().apply_changes(nullptr); in.clear(); r = store->read(ch, hoid, 0, block_size, in); ASSERT_EQ((int)block_size, r); @@ -5661,8 +5661,8 @@ TEST_P(StoreTest, BluestoreOnOffCSumTest) { r = queue_transaction(store, ch, std::move(t)); ASSERT_EQ(r, 0); - SetVal(g_conf, "bluestore_csum_type", "none"); - g_conf->apply_changes(NULL); + SetVal(g_conf(), "bluestore_csum_type", "none"); + g_conf().apply_changes(nullptr); ObjectStore::Transaction t2; bl.clear(); @@ -5686,8 +5686,8 @@ TEST_P(StoreTest, BluestoreOnOffCSumTest) { ASSERT_EQ((int)block_size, r); ASSERT_TRUE(bl_eq(orig2, in)); - SetVal(g_conf, "bluestore_csum_type", "crc32c"); - g_conf->apply_changes(NULL); + SetVal(g_conf(), "bluestore_csum_type", "crc32c"); + g_conf().apply_changes(nullptr); ObjectStore::Transaction t3; bl.clear(); @@ -5811,8 +5811,8 @@ TEST_P(StoreTestSpecificAUSize, Many4KWritesNoCSumTest) { if (string(GetParam()) != "bluestore") return; StartDeferred(0x10000); - SetVal(g_conf, "bluestore_csum_type", "none"); - g_ceph_context->_conf->apply_changes(NULL); + SetVal(g_conf(), "bluestore_csum_type", "none"); + g_ceph_context->_conf.apply_changes(nullptr); const unsigned max_object = 4*1024*1024; doMany4KWritesTest(store, 1, 1000, max_object, 4*1024, 0 ); @@ -5848,11 +5848,11 @@ TEST_P(StoreTestSpecificAUSize, OnodeSizeTracking) { size_t block_size = 4096; StartDeferred(block_size); - SetVal(g_conf, "bluestore_compression_mode", "none"); - SetVal(g_conf, "bluestore_csum_type", "none"); - SetVal(g_conf, "bluestore_cache_size_hdd", "400000000"); - SetVal(g_conf, "bluestore_cache_size_ssd", "400000000"); - g_conf->apply_changes(NULL); + SetVal(g_conf(), "bluestore_compression_mode", "none"); + SetVal(g_conf(), "bluestore_csum_type", "none"); + SetVal(g_conf(), "bluestore_cache_size_hdd", "400000000"); + SetVal(g_conf(), "bluestore_cache_size_ssd", "400000000"); + g_conf().apply_changes(nullptr); int r; coll_t cid; @@ -5948,8 +5948,8 @@ TEST_P(StoreTestSpecificAUSize, BlobReuseOnOverwrite) { size_t block_size = 4096; StartDeferred(block_size); - SetVal(g_conf, "bluestore_max_blob_size", "65536"); - g_conf->apply_changes(NULL); + SetVal(g_conf(), "bluestore_max_blob_size", "65536"); + g_conf().apply_changes(nullptr); int r; coll_t cid; @@ -6121,8 +6121,8 @@ TEST_P(StoreTestSpecificAUSize, BlobReuseOnOverwriteReverse) { size_t block_size = 4096; StartDeferred(block_size); - SetVal(g_conf, "bluestore_max_blob_size", "65536"); - g_conf->apply_changes(NULL); + SetVal(g_conf(), "bluestore_max_blob_size", "65536"); + g_conf().apply_changes(nullptr); int r; coll_t cid; @@ -6302,8 +6302,8 @@ TEST_P(StoreTestSpecificAUSize, BlobReuseOnSmallOverwrite) { size_t block_size = 4096; StartDeferred(block_size); - SetVal(g_conf, "bluestore_max_blob_size", "65536"); - g_conf->apply_changes(NULL); + SetVal(g_conf(), "bluestore_max_blob_size", "65536"); + g_conf().apply_changes(nullptr); int r; coll_t cid; @@ -6381,10 +6381,10 @@ TEST_P(StoreTestSpecificAUSize, SmallWriteOnShardedExtents) { size_t block_size = 0x10000; StartDeferred(block_size); - SetVal(g_conf, "bluestore_csum_type", "xxhash64"); - SetVal(g_conf, "bluestore_max_blob_size", "524288"); // for sure + SetVal(g_conf(), "bluestore_csum_type", "xxhash64"); + SetVal(g_conf(), "bluestore_max_blob_size", "524288"); // for sure - g_conf->apply_changes(NULL); + g_conf().apply_changes(nullptr); int r; coll_t cid; @@ -6462,10 +6462,10 @@ TEST_P(StoreTestSpecificAUSize, ExcessiveFragmentation) { if (string(GetParam()) != "bluestore") return; - SetVal(g_conf, "bluestore_block_size", + SetVal(g_conf(), "bluestore_block_size", stringify((uint64_t)2048 * 1024 * 1024).c_str()); - ASSERT_EQ(g_conf->get_val<uint64_t>("bluefs_alloc_size"), + ASSERT_EQ(g_conf().get_val<uint64_t>("bluefs_alloc_size"), 1024 * 1024); size_t block_size = 0x10000; @@ -6536,7 +6536,7 @@ TEST_P(StoreTestSpecificAUSize, ExcessiveFragmentation) { } auto to_sleep = 5 * - (int)g_conf->get_val<double>("bluestore_bluefs_balance_interval"); + (int)g_conf().get_val<double>("bluestore_bluefs_balance_interval"); std::cout<<"sleeping... " << std::endl; sleep(to_sleep); @@ -6599,11 +6599,11 @@ TEST_P(StoreTest, KVDBStatsTest) { if (string(GetParam()) != "bluestore") return; - SetVal(g_conf, "rocksdb_perf", "true"); - SetVal(g_conf, "rocksdb_collect_compaction_stats", "true"); - SetVal(g_conf, "rocksdb_collect_extended_stats","true"); - SetVal(g_conf, "rocksdb_collect_memory_stats","true"); - g_ceph_context->_conf->apply_changes(NULL); + SetVal(g_conf(), "rocksdb_perf", "true"); + SetVal(g_conf(), "rocksdb_collect_compaction_stats", "true"); + SetVal(g_conf(), "rocksdb_collect_extended_stats","true"); + SetVal(g_conf(), "rocksdb_collect_memory_stats","true"); + g_ceph_context->_conf.apply_changes(nullptr); int r = store->umount(); ASSERT_EQ(r, 0); r = store->mount(); //to force rocksdb stats @@ -6665,10 +6665,10 @@ TEST_P(StoreTestSpecificAUSize, garbageCollection) { StartDeferred(65536); - SetVal(g_conf, "bluestore_compression_max_blob_size", "524288"); - SetVal(g_conf, "bluestore_compression_min_blob_size", "262144"); - SetVal(g_conf, "bluestore_compression_mode", "force"); - g_conf->apply_changes(NULL); + SetVal(g_conf(), "bluestore_compression_max_blob_size", "524288"); + SetVal(g_conf(), "bluestore_compression_min_blob_size", "262144"); + SetVal(g_conf(), "bluestore_compression_mode", "force"); + g_conf().apply_changes(nullptr); auto ch = store->create_new_collection(cid); @@ -6772,7 +6772,7 @@ TEST_P(StoreTestSpecificAUSize, garbageCollection) { const PerfCounters* counters = store->get_perf_counters(); ASSERT_EQ(counters->get(l_bluestore_gc_merged), 0x40001u); } - SetVal(g_conf, "bluestore_gc_enable_total_threshold", "1"); //forbid GC when saving = 0 + SetVal(g_conf(), "bluestore_gc_enable_total_threshold", "1"); //forbid GC when saving = 0 { struct store_statfs_t statfs; WRITE_AT(1, overlap_offset-2); @@ -6806,10 +6806,10 @@ TEST_P(StoreTestSpecificAUSize, fsckOnUnalignedDevice) { if (string(GetParam()) != "bluestore") return; - SetVal(g_conf, "bluestore_block_size", + SetVal(g_conf(), "bluestore_block_size", stringify(0x280005000).c_str()); //10 Gb + 4K - SetVal(g_conf, "bluestore_fsck_on_mount", "false"); - SetVal(g_conf, "bluestore_fsck_on_umount", "false"); + SetVal(g_conf(), "bluestore_fsck_on_mount", "false"); + SetVal(g_conf(), "bluestore_fsck_on_umount", "false"); StartDeferred(0x4000); store->umount(); ASSERT_EQ(store->fsck(false), 0); // do fsck explicitly @@ -6821,10 +6821,10 @@ TEST_P(StoreTestSpecificAUSize, fsckOnUnalignedDevice2) { if (string(GetParam()) != "bluestore") return; - SetVal(g_conf, "bluestore_block_size", + SetVal(g_conf(), "bluestore_block_size", stringify(0x280005000).c_str()); //10 Gb + 20K - SetVal(g_conf, "bluestore_fsck_on_mount", "false"); - SetVal(g_conf, "bluestore_fsck_on_umount", "false"); + SetVal(g_conf(), "bluestore_fsck_on_mount", "false"); + SetVal(g_conf(), "bluestore_fsck_on_umount", "false"); StartDeferred(0x1000); store->umount(); ASSERT_EQ(store->fsck(false), 0); // do fsck explicitly @@ -6836,12 +6836,12 @@ TEST_P(StoreTest, BluestoreRepairTest) { return; const size_t offs_base = 65536 / 2; - SetVal(g_conf, "bluestore_fsck_on_mount", "false"); - SetVal(g_conf, "bluestore_fsck_on_umount", "false"); - SetVal(g_conf, "bluestore_max_blob_size", + SetVal(g_conf(), "bluestore_fsck_on_mount", "false"); + SetVal(g_conf(), "bluestore_fsck_on_umount", "false"); + SetVal(g_conf(), "bluestore_max_blob_size", stringify(2 * offs_base).c_str()); - SetVal(g_conf, "bluestore_extent_map_shard_max_size", "12000"); - g_ceph_context->_conf->apply_changes(NULL); + SetVal(g_conf(), "bluestore_extent_map_shard_max_size", "12000"); + g_ceph_context->_conf.apply_changes(nullptr); BlueStore* bstore = dynamic_cast<BlueStore*> (store.get()); @@ -6947,8 +6947,8 @@ TEST_P(StoreTest, BluestoreRepairTest) { ASSERT_EQ(bstore->fsck(true), 0); // reproducing issues #21040 & 20983 - SetVal(g_conf, "bluestore_debug_inject_bug21040", "true"); - g_ceph_context->_conf->apply_changes(NULL); + SetVal(g_conf(), "bluestore_debug_inject_bug21040", "true"); + g_ceph_context->_conf.apply_changes(nullptr); bstore->mount(); cerr << "repro bug #21040" << std::endl; @@ -6976,8 +6976,8 @@ TEST_P(StoreTest, BluestoreRepairTest) { ASSERT_EQ(bstore->fsck(false), 3); ASSERT_LE(bstore->repair(false), 0); ASSERT_EQ(bstore->fsck(false), 0); - SetVal(g_conf, "bluestore_debug_inject_bug21040", "true"); - g_ceph_context->_conf->apply_changes(NULL); + SetVal(g_conf(), "bluestore_debug_inject_bug21040", "true"); + g_ceph_context->_conf.apply_changes(nullptr); } @@ -6988,16 +6988,16 @@ TEST_P(StoreTest, BluestoreStatistics) { if (string(GetParam()) != "bluestore") return; - SetVal(g_conf, "rocksdb_perf", "true"); - SetVal(g_conf, "rocksdb_collect_compaction_stats", "true"); - SetVal(g_conf, "rocksdb_collect_extended_stats","true"); - SetVal(g_conf, "rocksdb_collect_memory_stats","true"); + SetVal(g_conf(), "rocksdb_perf", "true"); + SetVal(g_conf(), "rocksdb_collect_compaction_stats", "true"); + SetVal(g_conf(), "rocksdb_collect_extended_stats","true"); + SetVal(g_conf(), "rocksdb_collect_memory_stats","true"); // disable cache - SetVal(g_conf, "bluestore_cache_size_ssd", "0"); - SetVal(g_conf, "bluestore_cache_size_hdd", "0"); - SetVal(g_conf, "bluestore_cache_size", "0"); - g_ceph_context->_conf->apply_changes(NULL); + SetVal(g_conf(), "bluestore_cache_size_ssd", "0"); + SetVal(g_conf(), "bluestore_cache_size_hdd", "0"); + SetVal(g_conf(), "bluestore_cache_size", "0"); + g_ceph_context->_conf.apply_changes(nullptr); int r = store->umount(); ASSERT_EQ(r, 0); @@ -7044,41 +7044,41 @@ int main(int argc, char **argv) { common_init_finish(g_ceph_context); // make sure we can adjust any config settings - g_ceph_context->_conf->_clear_safe_to_start_threads(); - - g_ceph_context->_conf->set_val_or_die("osd_journal_size", "400"); - g_ceph_context->_conf->set_val_or_die("filestore_index_retry_probability", "0.5"); - g_ceph_context->_conf->set_val_or_die("filestore_op_thread_timeout", "1000"); - g_ceph_context->_conf->set_val_or_die("filestore_op_thread_suicide_timeout", "10000"); - //g_ceph_context->_conf->set_val_or_die("filestore_fiemap", "true"); - g_ceph_context->_conf->set_val_or_die("bluestore_fsck_on_mkfs", "false"); - g_ceph_context->_conf->set_val_or_die("bluestore_fsck_on_mount", "false"); - g_ceph_context->_conf->set_val_or_die("bluestore_fsck_on_umount", "false"); - g_ceph_context->_conf->set_val_or_die("bluestore_debug_misc", "true"); - g_ceph_context->_conf->set_val_or_die("bluestore_debug_small_allocations", "4"); - g_ceph_context->_conf->set_val_or_die("bluestore_debug_freelist", "true"); - g_ceph_context->_conf->set_val_or_die("bluestore_clone_cow", "true"); - g_ceph_context->_conf->set_val_or_die("bluestore_max_alloc_size", "196608"); + g_ceph_context->_conf._clear_safe_to_start_threads(); + + g_ceph_context->_conf.set_val_or_die("osd_journal_size", "400"); + g_ceph_context->_conf.set_val_or_die("filestore_index_retry_probability", "0.5"); + g_ceph_context->_conf.set_val_or_die("filestore_op_thread_timeout", "1000"); + g_ceph_context->_conf.set_val_or_die("filestore_op_thread_suicide_timeout", "10000"); + //g_ceph_context->_conf.set_val_or_die("filestore_fiemap", "true"); + g_ceph_context->_conf.set_val_or_die("bluestore_fsck_on_mkfs", "false"); + g_ceph_context->_conf.set_val_or_die("bluestore_fsck_on_mount", "false"); + g_ceph_context->_conf.set_val_or_die("bluestore_fsck_on_umount", "false"); + g_ceph_context->_conf.set_val_or_die("bluestore_debug_misc", "true"); + g_ceph_context->_conf.set_val_or_die("bluestore_debug_small_allocations", "4"); + g_ceph_context->_conf.set_val_or_die("bluestore_debug_freelist", "true"); + g_ceph_context->_conf.set_val_or_die("bluestore_clone_cow", "true"); + g_ceph_context->_conf.set_val_or_die("bluestore_max_alloc_size", "196608"); // set small cache sizes so we see trimming during Synthetic tests - g_ceph_context->_conf->set_val_or_die("bluestore_cache_size_hdd", "4000000"); - g_ceph_context->_conf->set_val_or_die("bluestore_cache_size_ssd", "4000000"); + g_ceph_context->_conf.set_val_or_die("bluestore_cache_size_hdd", "4000000"); + g_ceph_context->_conf.set_val_or_die("bluestore_cache_size_ssd", "4000000"); // very short *_max prealloc so that we fall back to async submits - g_ceph_context->_conf->set_val_or_die("bluestore_blobid_prealloc", "10"); - g_ceph_context->_conf->set_val_or_die("bluestore_nid_prealloc", "10"); - g_ceph_context->_conf->set_val_or_die("bluestore_debug_randomize_serial_transaction", + g_ceph_context->_conf.set_val_or_die("bluestore_blobid_prealloc", "10"); + g_ceph_context->_conf.set_val_or_die("bluestore_nid_prealloc", "10"); + g_ceph_context->_conf.set_val_or_die("bluestore_debug_randomize_serial_transaction", "10"); - g_ceph_context->_conf->set_val_or_die("bdev_debug_aio", "true"); + g_ceph_context->_conf.set_val_or_die("bdev_debug_aio", "true"); // specify device size - g_ceph_context->_conf->set_val_or_die("bluestore_block_size", + g_ceph_context->_conf.set_val_or_die("bluestore_block_size", stringify(DEF_STORE_TEST_BLOCKDEV_SIZE)); - g_ceph_context->_conf->set_val_or_die( + g_ceph_context->_conf.set_val_or_die( "enable_experimental_unrecoverable_data_corrupting_features", "*"); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.apply_changes(nullptr); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); diff --git a/src/test/objectstore/store_test_fixture.cc b/src/test/objectstore/store_test_fixture.cc index 11a3760c242..0e590c9b3fa 100644 --- a/src/test/objectstore/store_test_fixture.cc +++ b/src/test/objectstore/store_test_fixture.cc @@ -77,10 +77,10 @@ void StoreTestFixture::TearDown() } } -void StoreTestFixture::SetVal(md_config_t* _conf, const char* key, const char* val) +void StoreTestFixture::SetVal(ConfigProxy& _conf, const char* key, const char* val) { - assert(!conf || conf == _conf); - conf = _conf; + assert(!conf || conf == &_conf); + conf = &_conf; std::string skey(key); std::string prev_val; conf->get_val(skey, &prev_val); diff --git a/src/test/objectstore/store_test_fixture.h b/src/test/objectstore/store_test_fixture.h index 97b27d9d1f1..d816dbdf49d 100644 --- a/src/test/objectstore/store_test_fixture.h +++ b/src/test/objectstore/store_test_fixture.h @@ -11,7 +11,7 @@ class StoreTestFixture : virtual public ::testing::Test { const std::string data_dir; std::stack<std::pair<std::string, std::string>> saved_settings; - md_config_t* conf = nullptr; + ConfigProxy* conf = nullptr; public: boost::scoped_ptr<ObjectStore> store; @@ -23,7 +23,7 @@ public: void SetUp() override; void TearDown() override; - void SetVal(md_config_t* conf, const char* key, const char* val); + void SetVal(ConfigProxy& conf, const char* key, const char* val); struct SettingsBookmark { StoreTestFixture& s; size_t pos; diff --git a/src/test/objectstore/test_bluefs.cc b/src/test/objectstore/test_bluefs.cc index 80435b3c228..aa6cd571374 100644 --- a/src/test/objectstore/test_bluefs.cc +++ b/src/test/objectstore/test_bluefs.cc @@ -164,9 +164,9 @@ void write_data(BlueFS &fs, uint64_t rationed_bytes) if (r < 0) { break; } - written_bytes += g_conf->bluefs_alloc_size; + written_bytes += g_conf()->bluefs_alloc_size; j++; - if ((rationed_bytes - written_bytes) <= g_conf->bluefs_alloc_size) { + if ((rationed_bytes - written_bytes) <= g_conf()->bluefs_alloc_size) { break; } } @@ -210,8 +210,8 @@ void write_single_file(BlueFS &fs, uint64_t rationed_bytes) if (r < 0) { break; } - written_bytes += g_conf->bluefs_alloc_size; - if ((rationed_bytes - written_bytes) <= g_conf->bluefs_alloc_size) { + written_bytes += g_conf()->bluefs_alloc_size; + if ((rationed_bytes - written_bytes) <= g_conf()->bluefs_alloc_size) { break; } } @@ -249,10 +249,10 @@ void join_all(std::vector<std::thread>& v) TEST(BlueFS, test_flush_1) { uint64_t size = 1048576 * 128; string fn = get_temp_bdev(size); - g_ceph_context->_conf->set_val( + g_ceph_context->_conf.set_val( "bluefs_alloc_size", "65536"); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.apply_changes(nullptr); BlueFS fs(g_ceph_context); ASSERT_EQ(0, fs.add_block_device(BlueFS::BDEV_DB, fn, false)); @@ -284,10 +284,10 @@ TEST(BlueFS, test_flush_1) { TEST(BlueFS, test_flush_2) { uint64_t size = 1048576 * 256; string fn = get_temp_bdev(size); - g_ceph_context->_conf->set_val( + g_ceph_context->_conf.set_val( "bluefs_alloc_size", "65536"); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.apply_changes(nullptr); BlueFS fs(g_ceph_context); ASSERT_EQ(0, fs.add_block_device(BlueFS::BDEV_DB, fn, false)); @@ -312,10 +312,10 @@ TEST(BlueFS, test_flush_2) { TEST(BlueFS, test_flush_3) { uint64_t size = 1048576 * 256; string fn = get_temp_bdev(size); - g_ceph_context->_conf->set_val( + g_ceph_context->_conf.set_val( "bluefs_alloc_size", "65536"); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.apply_changes(nullptr); BlueFS fs(g_ceph_context); ASSERT_EQ(0, fs.add_block_device(BlueFS::BDEV_DB, fn, false)); @@ -345,7 +345,7 @@ TEST(BlueFS, test_flush_3) { } TEST(BlueFS, test_simple_compaction_sync) { - g_ceph_context->_conf->set_val( + g_ceph_context->_conf.set_val( "bluefs_compact_log_sync", "true"); uint64_t size = 1048576 * 128; @@ -398,7 +398,7 @@ TEST(BlueFS, test_simple_compaction_sync) { } TEST(BlueFS, test_simple_compaction_async) { - g_ceph_context->_conf->set_val( + g_ceph_context->_conf.set_val( "bluefs_compact_log_sync", "false"); uint64_t size = 1048576 * 128; @@ -453,10 +453,10 @@ TEST(BlueFS, test_simple_compaction_async) { TEST(BlueFS, test_compaction_sync) { uint64_t size = 1048576 * 128; string fn = get_temp_bdev(size); - g_ceph_context->_conf->set_val( + g_ceph_context->_conf.set_val( "bluefs_alloc_size", "65536"); - g_ceph_context->_conf->set_val( + g_ceph_context->_conf.set_val( "bluefs_compact_log_sync", "true"); @@ -491,10 +491,10 @@ TEST(BlueFS, test_compaction_sync) { TEST(BlueFS, test_compaction_async) { uint64_t size = 1048576 * 128; string fn = get_temp_bdev(size); - g_ceph_context->_conf->set_val( + g_ceph_context->_conf.set_val( "bluefs_alloc_size", "65536"); - g_ceph_context->_conf->set_val( + g_ceph_context->_conf.set_val( "bluefs_compact_log_sync", "false"); @@ -529,10 +529,10 @@ TEST(BlueFS, test_compaction_async) { TEST(BlueFS, test_replay) { uint64_t size = 1048576 * 128; string fn = get_temp_bdev(size); - g_ceph_context->_conf->set_val( + g_ceph_context->_conf.set_val( "bluefs_alloc_size", "65536"); - g_ceph_context->_conf->set_val( + g_ceph_context->_conf.set_val( "bluefs_compact_log_sync", "false"); @@ -580,10 +580,10 @@ int main(int argc, char **argv) { CODE_ENVIRONMENT_UTILITY, CINIT_FLAG_NO_DEFAULT_CONFIG_FILE); common_init_finish(g_ceph_context); - g_ceph_context->_conf->set_val( + g_ceph_context->_conf.set_val( "enable_experimental_unrecoverable_data_corrupting_features", "*"); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.apply_changes(nullptr); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); diff --git a/src/test/objectstore/test_idempotent.cc b/src/test/objectstore/test_idempotent.cc index 78cdb9879e3..a9ef77c8530 100644 --- a/src/test/objectstore/test_idempotent.cc +++ b/src/test/objectstore/test_idempotent.cc @@ -49,7 +49,7 @@ int main(int argc, char **argv) { CODE_ENVIRONMENT_UTILITY, CINIT_FLAG_NO_DEFAULT_CONFIG_FILE); common_init_finish(g_ceph_context); - g_ceph_context->_conf->apply_changes(NULL); + cct->_conf.apply_changes(nullptr); std::cerr << "args: " << args << std::endl; if (args.size() < 4) { diff --git a/src/test/objectstore/test_idempotent_sequence.cc b/src/test/objectstore/test_idempotent_sequence.cc index 052db64915f..33608c2bb3f 100644 --- a/src/test/objectstore/test_idempotent_sequence.cc +++ b/src/test/objectstore/test_idempotent_sequence.cc @@ -218,7 +218,7 @@ int main(int argc, const char *argv[]) CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, CINIT_FLAG_NO_DEFAULT_CONFIG_FILE); common_init_finish(g_ceph_context); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.apply_changes(nullptr); std::string command; std::vector<std::string> command_args; diff --git a/src/test/objectstore/test_kv.cc b/src/test/objectstore/test_kv.cc index cf5948f8c13..407cee5d929 100644 --- a/src/test/objectstore/test_kv.cc +++ b/src/test/objectstore/test_kv.cc @@ -319,7 +319,7 @@ TEST_P(KVTest, RocksDBColumnFamilyTest) { std::vector<KeyValueDB::ColumnFamily> cfs; cfs.push_back(KeyValueDB::ColumnFamily("cf1", "")); cfs.push_back(KeyValueDB::ColumnFamily("cf2", "")); - ASSERT_EQ(0, db->init(g_conf->bluestore_rocksdb_options)); + ASSERT_EQ(0, db->init(g_conf()->bluestore_rocksdb_options)); cout << "creating two column families and opening them" << std::endl; ASSERT_EQ(0, db->create_and_open(cout, cfs)); { @@ -374,7 +374,7 @@ TEST_P(KVTest, RocksDBIteratorTest) { std::vector<KeyValueDB::ColumnFamily> cfs; cfs.push_back(KeyValueDB::ColumnFamily("cf1", "")); - ASSERT_EQ(0, db->init(g_conf->bluestore_rocksdb_options)); + ASSERT_EQ(0, db->init(g_conf()->bluestore_rocksdb_options)); cout << "creating one column family and opening it" << std::endl; ASSERT_EQ(0, db->create_and_open(cout, cfs)); { @@ -427,7 +427,7 @@ TEST_P(KVTest, RocksDBCFMerge) { return; // No merge operators for this database type std::vector<KeyValueDB::ColumnFamily> cfs; cfs.push_back(KeyValueDB::ColumnFamily("cf1", "")); - ASSERT_EQ(0, db->init(g_conf->bluestore_rocksdb_options)); + ASSERT_EQ(0, db->init(g_conf()->bluestore_rocksdb_options)); cout << "creating one column family and opening it" << std::endl; ASSERT_EQ(0, db->create_and_open(cout, cfs)); @@ -492,10 +492,10 @@ int main(int argc, char **argv) { CODE_ENVIRONMENT_UTILITY, CINIT_FLAG_NO_DEFAULT_CONFIG_FILE); common_init_finish(g_ceph_context); - g_ceph_context->_conf->set_val( + g_ceph_context->_conf.set_val( "enable_experimental_unrecoverable_data_corrupting_features", "rocksdb, memdb"); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.apply_changes(nullptr); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); diff --git a/src/test/objectstore_bench.cc b/src/test/objectstore_bench.cc index 2c41d8af53c..294679dfa30 100644 --- a/src/test/objectstore_bench.cc +++ b/src/test/objectstore_bench.cc @@ -199,9 +199,9 @@ int main(int argc, const char *argv[]) common_init_finish(g_ceph_context); // create object store - dout(0) << "objectstore " << g_conf->osd_objectstore << dendl; - dout(0) << "data " << g_conf->osd_data << dendl; - dout(0) << "journal " << g_conf->osd_journal << dendl; + dout(0) << "objectstore " << g_conf()->osd_objectstore << dendl; + dout(0) << "data " << g_conf()->osd_data << dendl; + dout(0) << "journal " << g_conf()->osd_journal << dendl; dout(0) << "size " << cfg.size << dendl; dout(0) << "block-size " << cfg.block_size << dendl; dout(0) << "repeats " << cfg.repeats << dendl; @@ -209,15 +209,15 @@ int main(int argc, const char *argv[]) auto os = std::unique_ptr<ObjectStore>( ObjectStore::create(g_ceph_context, - g_conf->osd_objectstore, - g_conf->osd_data, - g_conf->osd_journal)); + g_conf()->osd_objectstore, + g_conf()->osd_data, + g_conf()->osd_journal)); //Checking data folder: create if needed or error if it's not empty - DIR *dir = ::opendir(g_conf->osd_data.c_str()); + DIR *dir = ::opendir(g_conf()->osd_data.c_str()); if (!dir) { std::string cmd("mkdir -p "); - cmd+=g_conf->osd_data; + cmd+=g_conf()->osd_data; int r = ::system( cmd.c_str() ); if( r<0 ){ derr << "Failed to create data directory, ret = " << r << dendl; @@ -227,14 +227,14 @@ int main(int argc, const char *argv[]) else { bool non_empty = readdir(dir) != NULL && readdir(dir) != NULL && readdir(dir) != NULL; if( non_empty ){ - derr << "Data directory '"<<g_conf->osd_data<<"' isn't empty, please clean it first."<< dendl; + derr << "Data directory '"<<g_conf()->osd_data<<"' isn't empty, please clean it first."<< dendl; return 1; } } ::closedir(dir); //Create folders for journal if needed - string journal_base = g_conf->osd_journal.substr(0, g_conf->osd_journal.rfind('/')); + string journal_base = g_conf()->osd_journal.substr(0, g_conf()->osd_journal.rfind('/')); struct stat sb; if (stat(journal_base.c_str(), &sb) != 0 ){ std::string cmd("mkdir -p "); @@ -247,7 +247,7 @@ int main(int argc, const char *argv[]) } if (!os) { - derr << "bad objectstore type " << g_conf->osd_objectstore << dendl; + derr << "bad objectstore type " << g_conf()->osd_objectstore << dendl; return 1; } if (os->mkfs() < 0) { diff --git a/src/test/osd/TestOSDMap.cc b/src/test/osd/TestOSDMap.cc index 45fed3458ac..7e9c2bcddd1 100644 --- a/src/test/osd/TestOSDMap.cc +++ b/src/test/osd/TestOSDMap.cc @@ -19,9 +19,9 @@ int main(int argc, char **argv) { CINIT_FLAG_NO_DEFAULT_CONFIG_FILE); common_init_finish(g_ceph_context); // make sure we have 3 copies, or some tests won't work - g_ceph_context->_conf->set_val("osd_pool_default_size", "3"); + g_ceph_context->_conf.set_val("osd_pool_default_size", "3"); // our map is flat, so just try and split across OSDs, not hosts or whatever - g_ceph_context->_conf->set_val("osd_crush_chooseleaf_type", "0"); + g_ceph_context->_conf.set_val("osd_crush_chooseleaf_type", "0"); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/src/test/osd/TestOSDScrub.cc b/src/test/osd/TestOSDScrub.cc index b1f22b7716e..34a3b8d81af 100644 --- a/src/test/osd/TestOSDScrub.cc +++ b/src/test/osd/TestOSDScrub.cc @@ -53,88 +53,88 @@ public: TEST(TestOSDScrub, scrub_time_permit) { ObjectStore *store = ObjectStore::create(g_ceph_context, - g_conf->osd_objectstore, - g_conf->osd_data, - g_conf->osd_journal); - std::string cluster_msgr_type = g_conf->ms_cluster_type.empty() ? g_conf->get_val<std::string>("ms_type") : g_conf->ms_cluster_type; + g_conf()->osd_objectstore, + g_conf()->osd_data, + g_conf()->osd_journal); + std::string cluster_msgr_type = g_conf()->ms_cluster_type.empty() ? g_conf().get_val<std::string>("ms_type") : g_conf()->ms_cluster_type; Messenger *ms = Messenger::create(g_ceph_context, cluster_msgr_type, entity_name_t::OSD(0), "make_checker", getpid(), 0); ms->set_cluster_protocol(CEPH_OSD_PROTOCOL); ms->set_default_policy(Messenger::Policy::stateless_server(0)); - ms->bind(g_conf->public_addr); + ms->bind(g_conf()->public_addr); MonClient mc(g_ceph_context); mc.build_initial_monmap(); TestOSDScrub* osd = new TestOSDScrub(g_ceph_context, store, 0, ms, ms, ms, ms, ms, ms, ms, &mc, "", ""); - g_ceph_context->_conf->set_val("osd_scrub_begin_hour", "0"); - g_ceph_context->_conf->set_val("osd_scrub_end_hour", "24"); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.set_val("osd_scrub_begin_hour", "0"); + g_ceph_context->_conf.set_val("osd_scrub_end_hour", "24"); + g_ceph_context->_conf.apply_changes(nullptr); tm tm; strptime("2015-01-16 12:05:13", "%Y-%m-%d %H:%M:%S", &tm); utime_t now = utime_t(mktime(&tm), 0); bool ret = osd->scrub_time_permit(now); ASSERT_TRUE(ret); - g_ceph_context->_conf->set_val("osd_scrub_begin_hour", "24"); - g_ceph_context->_conf->set_val("osd_scrub_end_hour", "0"); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.set_val("osd_scrub_begin_hour", "24"); + g_ceph_context->_conf.set_val("osd_scrub_end_hour", "0"); + g_ceph_context->_conf.apply_changes(nullptr); strptime("2015-01-16 12:05:13", "%Y-%m-%d %H:%M:%S", &tm); now = utime_t(mktime(&tm), 0); ret = osd->scrub_time_permit(now); ASSERT_FALSE(ret); - g_ceph_context->_conf->set_val("osd_scrub_begin_hour", "0"); - g_ceph_context->_conf->set_val("osd_scrub_end_hour", "0"); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.set_val("osd_scrub_begin_hour", "0"); + g_ceph_context->_conf.set_val("osd_scrub_end_hour", "0"); + g_ceph_context->_conf.apply_changes(nullptr); strptime("2015-01-16 12:05:13", "%Y-%m-%d %H:%M:%S", &tm); now = utime_t(mktime(&tm), 0); ret = osd->scrub_time_permit(now); ASSERT_TRUE(ret); - g_ceph_context->_conf->set_val("osd_scrub_begin_hour", "20"); - g_ceph_context->_conf->set_val("osd_scrub_end_hour", "07"); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.set_val("osd_scrub_begin_hour", "20"); + g_ceph_context->_conf.set_val("osd_scrub_end_hour", "07"); + g_ceph_context->_conf.apply_changes(nullptr); strptime("2015-01-16 01:05:13", "%Y-%m-%d %H:%M:%S", &tm); now = utime_t(mktime(&tm), 0); ret = osd->scrub_time_permit(now); ASSERT_TRUE(ret); - g_ceph_context->_conf->set_val("osd_scrub_begin_hour", "20"); - g_ceph_context->_conf->set_val("osd_scrub_end_hour", "07"); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.set_val("osd_scrub_begin_hour", "20"); + g_ceph_context->_conf.set_val("osd_scrub_end_hour", "07"); + g_ceph_context->_conf.apply_changes(nullptr); strptime("2015-01-16 20:05:13", "%Y-%m-%d %H:%M:%S", &tm); now = utime_t(mktime(&tm), 0); ret = osd->scrub_time_permit(now); ASSERT_TRUE(ret); - g_ceph_context->_conf->set_val("osd_scrub_begin_hour", "20"); - g_ceph_context->_conf->set_val("osd_scrub_end_hour", "07"); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.set_val("osd_scrub_begin_hour", "20"); + g_ceph_context->_conf.set_val("osd_scrub_end_hour", "07"); + g_ceph_context->_conf.apply_changes(nullptr); strptime("2015-01-16 08:05:13", "%Y-%m-%d %H:%M:%S", &tm); now = utime_t(mktime(&tm), 0); ret = osd->scrub_time_permit(now); ASSERT_FALSE(ret); - g_ceph_context->_conf->set_val("osd_scrub_begin_hour", "01"); - g_ceph_context->_conf->set_val("osd_scrub_end_hour", "07"); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.set_val("osd_scrub_begin_hour", "01"); + g_ceph_context->_conf.set_val("osd_scrub_end_hour", "07"); + g_ceph_context->_conf.apply_changes(nullptr); strptime("2015-01-16 20:05:13", "%Y-%m-%d %H:%M:%S", &tm); now = utime_t(mktime(&tm), 0); ret = osd->scrub_time_permit(now); ASSERT_FALSE(ret); - g_ceph_context->_conf->set_val("osd_scrub_begin_hour", "01"); - g_ceph_context->_conf->set_val("osd_scrub_end_hour", "07"); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.set_val("osd_scrub_begin_hour", "01"); + g_ceph_context->_conf.set_val("osd_scrub_end_hour", "07"); + g_ceph_context->_conf.apply_changes(nullptr); strptime("2015-01-16 00:05:13", "%Y-%m-%d %H:%M:%S", &tm); now = utime_t(mktime(&tm), 0); ret = osd->scrub_time_permit(now); ASSERT_FALSE(ret); - g_ceph_context->_conf->set_val("osd_scrub_begin_hour", "01"); - g_ceph_context->_conf->set_val("osd_scrub_end_hour", "07"); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.set_val("osd_scrub_begin_hour", "01"); + g_ceph_context->_conf.set_val("osd_scrub_end_hour", "07"); + g_ceph_context->_conf.apply_changes(nullptr); strptime("2015-01-16 04:05:13", "%Y-%m-%d %H:%M:%S", &tm); now = utime_t(mktime(&tm), 0); ret = osd->scrub_time_permit(now); diff --git a/src/test/osd/TestPGLog.cc b/src/test/osd/TestPGLog.cc index dfe457c6980..b923dda8f78 100644 --- a/src/test/osd/TestPGLog.cc +++ b/src/test/osd/TestPGLog.cc @@ -2691,9 +2691,9 @@ struct PGLogTrimTest : snprintf(max_entries_s, size, "%u", max_entries); snprintf(dup_track_s, size, "%u", dup_track); - cct->_conf->set_val_or_die("osd_min_pg_log_entries", min_entries_s); - cct->_conf->set_val_or_die("osd_max_pg_log_entries", max_entries_s); - cct->_conf->set_val_or_die("osd_pg_log_dups_tracked", dup_track_s); + cct->_conf.set_val_or_die("osd_min_pg_log_entries", min_entries_s); + cct->_conf.set_val_or_die("osd_max_pg_log_entries", max_entries_s); + cct->_conf.set_val_or_die("osd_pg_log_dups_tracked", dup_track_s); } }; // struct PGLogTrimTest diff --git a/src/test/osdc/object_cacher_stress.cc b/src/test/osdc/object_cacher_stress.cc index 4e7971153f2..214d62599f6 100644 --- a/src/test/osdc/object_cacher_stress.cc +++ b/src/test/osdc/object_cacher_stress.cc @@ -60,11 +60,11 @@ int stress_test(uint64_t num_ops, uint64_t num_objs, FakeWriteback writeback(g_ceph_context, &lock, delay_ns); ObjectCacher obc(g_ceph_context, "test", writeback, lock, NULL, NULL, - g_conf->client_oc_size, - g_conf->client_oc_max_objects, - g_conf->client_oc_max_dirty, - g_conf->client_oc_target_dirty, - g_conf->client_oc_max_dirty_age, + g_conf()->client_oc_size, + g_conf()->client_oc_max_objects, + g_conf()->client_oc_max_dirty, + g_conf()->client_oc_target_dirty, + g_conf()->client_oc_max_dirty_age, true); obc.start(); @@ -186,7 +186,7 @@ int correctness_test(uint64_t delay_ns) 1, // max objects, just one 1<<18, // max dirty, 256KB 1<<17, // target dirty, 128KB - g_conf->client_oc_max_dirty_age, + g_conf()->client_oc_max_dirty_age, true); obc.start(); std::cerr << "just start()ed ObjectCacher" << std::endl; diff --git a/src/test/rbd_mirror/test_mock_ImageMap.cc b/src/test/rbd_mirror/test_mock_ImageMap.cc index e6a705bb683..50ef3c7a615 100644 --- a/src/test/rbd_mirror/test_mock_ImageMap.cc +++ b/src/test/rbd_mirror/test_mock_ImageMap.cc @@ -205,7 +205,7 @@ public: .WillOnce(DoAll(WithArg<1>(Invoke([this](Context *ctx) { // disable rebalance so as to not reschedule it again CephContext *cct = reinterpret_cast<CephContext *>(m_local_io_ctx.cct()); - cct->_conf->set_val("rbd_mirror_image_policy_rebalance_timeout", "0"); + cct->_conf.set_val("rbd_mirror_image_policy_rebalance_timeout", "0"); auto wrapped_ctx = new FunctionContext([this, ctx](int r) { Mutex::Locker timer_locker(m_threads->timer_lock); @@ -1563,7 +1563,7 @@ TEST_F(TestMockImageMap, RebalanceImageMap) { // set rebalance interval CephContext *cct = reinterpret_cast<CephContext *>(m_local_io_ctx.cct()); - cct->_conf->set_val("rbd_mirror_image_policy_rebalance_timeout", "5"); + cct->_conf.set_val("rbd_mirror_image_policy_rebalance_timeout", "5"); remote_peer_ack_nowait(mock_image_map.get(), new_global_image_ids_ack, 0, &peer_ack_ctxs); diff --git a/src/test/rbd_mirror/test_mock_LeaderWatcher.cc b/src/test/rbd_mirror/test_mock_LeaderWatcher.cc index 0ece2c080aa..c2d497fabc6 100644 --- a/src/test/rbd_mirror/test_mock_LeaderWatcher.cc +++ b/src/test/rbd_mirror/test_mock_LeaderWatcher.cc @@ -626,7 +626,7 @@ TEST_F(TestMockLeaderWatcher, Break) { EXPECT_EQ(0, _rados->conf_set("rbd_mirror_leader_max_missed_heartbeats", "1")); CephContext *cct = reinterpret_cast<CephContext *>(m_local_io_ctx.cct()); - int max_acquire_attempts = cct->_conf->get_val<int64_t>( + int max_acquire_attempts = cct->_conf.get_val<int64_t>( "rbd_mirror_leader_max_acquire_attempts_before_break"); MockManagedLock mock_managed_lock; diff --git a/src/test/rgw/test_rgw_iam_policy.cc b/src/test/rgw/test_rgw_iam_policy.cc index 164e9bbcde7..bd058c33fe6 100644 --- a/src/test/rgw/test_rgw_iam_policy.cc +++ b/src/test/rgw/test_rgw_iam_policy.cc @@ -594,7 +594,7 @@ TEST_F(IPPolicyTest, IPEnvironment) { ASSERT_NE(ip, iam_env.end()); EXPECT_EQ(ip->second, "192.168.1.1"); - ASSERT_EQ(cct.get()->_conf->set_val("rgw_remote_addr_param", "SOME_VAR"), 0); + ASSERT_EQ(cct.get()->_conf.set_val("rgw_remote_addr_param", "SOME_VAR"), 0); EXPECT_EQ(cct.get()->_conf->rgw_remote_addr_param, "SOME_VAR"); iam_env = rgw_build_iam_environment(&rgw_rados, &rgw_req_state); ip = iam_env.find("aws:SourceIp"); @@ -606,7 +606,7 @@ TEST_F(IPPolicyTest, IPEnvironment) { ASSERT_NE(ip, iam_env.end()); EXPECT_EQ(ip->second, "192.168.1.2"); - ASSERT_EQ(cct.get()->_conf->set_val("rgw_remote_addr_param", "HTTP_X_FORWARDED_FOR"), 0); + ASSERT_EQ(cct.get()->_conf.set_val("rgw_remote_addr_param", "HTTP_X_FORWARDED_FOR"), 0); rgw_env.set("HTTP_X_FORWARDED_FOR", "192.168.1.3"); iam_env = rgw_build_iam_environment(&rgw_rados, &rgw_req_state); ip = iam_env.find("aws:SourceIp"); diff --git a/src/test/test_filejournal.cc b/src/test/test_filejournal.cc index c48f9bec619..5883be76456 100644 --- a/src/test/test_filejournal.cc +++ b/src/test/test_filejournal.cc @@ -77,8 +77,8 @@ int main(int argc, char **argv) { char mb[10]; sprintf(mb, "%u", size_mb); - g_ceph_context->_conf->set_val("osd_journal_size", mb); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.set_val("osd_journal_size", mb); + g_ceph_context->_conf.apply_changes(nullptr); finisher = new Finisher(g_ceph_context); @@ -114,9 +114,9 @@ int main(int argc, char **argv) { } TEST(TestFileJournal, Create) { - g_ceph_context->_conf->set_val("journal_ignore_corruption", "false"); - g_ceph_context->_conf->set_val("journal_write_header_frequency", "0"); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.set_val("journal_ignore_corruption", "false"); + g_ceph_context->_conf.set_val("journal_write_header_frequency", "0"); + g_ceph_context->_conf.apply_changes(nullptr); for (unsigned i = 0 ; i < 3; ++i) { SCOPED_TRACE(subtests[i].description); @@ -128,9 +128,9 @@ TEST(TestFileJournal, Create) { } TEST(TestFileJournal, WriteSmall) { - g_ceph_context->_conf->set_val("journal_ignore_corruption", "false"); - g_ceph_context->_conf->set_val("journal_write_header_frequency", "0"); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.set_val("journal_ignore_corruption", "false"); + g_ceph_context->_conf.set_val("journal_write_header_frequency", "0"); + g_ceph_context->_conf.apply_changes(nullptr); for (unsigned i = 0 ; i < 3; ++i) { SCOPED_TRACE(subtests[i].description); @@ -153,9 +153,9 @@ TEST(TestFileJournal, WriteSmall) { } TEST(TestFileJournal, WriteBig) { - g_ceph_context->_conf->set_val("journal_ignore_corruption", "false"); - g_ceph_context->_conf->set_val("journal_write_header_frequency", "0"); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.set_val("journal_ignore_corruption", "false"); + g_ceph_context->_conf.set_val("journal_write_header_frequency", "0"); + g_ceph_context->_conf.apply_changes(nullptr); for (unsigned i = 0 ; i < 3; ++i) { SCOPED_TRACE(subtests[i].description); @@ -181,9 +181,9 @@ TEST(TestFileJournal, WriteBig) { } TEST(TestFileJournal, WriteMany) { - g_ceph_context->_conf->set_val("journal_ignore_corruption", "false"); - g_ceph_context->_conf->set_val("journal_write_header_frequency", "0"); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.set_val("journal_ignore_corruption", "false"); + g_ceph_context->_conf.set_val("journal_write_header_frequency", "0"); + g_ceph_context->_conf.apply_changes(nullptr); for (unsigned i = 0 ; i < 3; ++i) { SCOPED_TRACE(subtests[i].description); @@ -214,9 +214,9 @@ TEST(TestFileJournal, WriteMany) { } TEST(TestFileJournal, WriteManyVecs) { - g_ceph_context->_conf->set_val("journal_ignore_corruption", "false"); - g_ceph_context->_conf->set_val("journal_write_header_frequency", "0"); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.set_val("journal_ignore_corruption", "false"); + g_ceph_context->_conf.set_val("journal_write_header_frequency", "0"); + g_ceph_context->_conf.apply_changes(nullptr); for (unsigned i = 0 ; i < 3; ++i) { SCOPED_TRACE(subtests[i].description); @@ -264,9 +264,9 @@ TEST(TestFileJournal, WriteManyVecs) { } TEST(TestFileJournal, ReplaySmall) { - g_ceph_context->_conf->set_val("journal_ignore_corruption", "false"); - g_ceph_context->_conf->set_val("journal_write_header_frequency", "0"); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.set_val("journal_ignore_corruption", "false"); + g_ceph_context->_conf.set_val("journal_write_header_frequency", "0"); + g_ceph_context->_conf.apply_changes(nullptr); vector<ObjectStore::Transaction> tls; @@ -325,9 +325,9 @@ TEST(TestFileJournal, ReplaySmall) { } TEST(TestFileJournal, ReplayCorrupt) { - g_ceph_context->_conf->set_val("journal_ignore_corruption", "true"); - g_ceph_context->_conf->set_val("journal_write_header_frequency", "0"); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.set_val("journal_ignore_corruption", "true"); + g_ceph_context->_conf.set_val("journal_write_header_frequency", "0"); + g_ceph_context->_conf.apply_changes(nullptr); vector<ObjectStore::Transaction> tls; for (unsigned i = 0 ; i < 3; ++i) { @@ -411,9 +411,9 @@ TEST(TestFileJournal, ReplayCorrupt) { } TEST(TestFileJournal, WriteTrim) { - g_ceph_context->_conf->set_val("journal_ignore_corruption", "false"); - g_ceph_context->_conf->set_val("journal_write_header_frequency", "0"); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.set_val("journal_ignore_corruption", "false"); + g_ceph_context->_conf.set_val("journal_write_header_frequency", "0"); + g_ceph_context->_conf.apply_changes(nullptr); for (unsigned i = 0 ; i < 3; ++i) { SCOPED_TRACE(subtests[i].description); @@ -462,9 +462,9 @@ TEST(TestFileJournal, WriteTrim) { } TEST(TestFileJournal, WriteTrimSmall) { - g_ceph_context->_conf->set_val("journal_ignore_corruption", "false"); - g_ceph_context->_conf->set_val("journal_write_header_frequency", "0"); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.set_val("journal_ignore_corruption", "false"); + g_ceph_context->_conf.set_val("journal_write_header_frequency", "0"); + g_ceph_context->_conf.apply_changes(nullptr); vector<ObjectStore::Transaction> tls; for (unsigned i = 0 ; i < 3; ++i) { @@ -512,9 +512,9 @@ TEST(TestFileJournal, WriteTrimSmall) { } TEST(TestFileJournal, ReplayDetectCorruptFooterMagic) { - g_ceph_context->_conf->set_val("journal_ignore_corruption", "true"); - g_ceph_context->_conf->set_val("journal_write_header_frequency", "1"); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.set_val("journal_ignore_corruption", "true"); + g_ceph_context->_conf.set_val("journal_write_header_frequency", "1"); + g_ceph_context->_conf.apply_changes(nullptr); vector<ObjectStore::Transaction> tls; for (unsigned i = 0 ; i < 3; ++i) { @@ -571,9 +571,9 @@ TEST(TestFileJournal, ReplayDetectCorruptFooterMagic) { } TEST(TestFileJournal, ReplayDetectCorruptPayload) { - g_ceph_context->_conf->set_val("journal_ignore_corruption", "true"); - g_ceph_context->_conf->set_val("journal_write_header_frequency", "1"); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.set_val("journal_ignore_corruption", "true"); + g_ceph_context->_conf.set_val("journal_write_header_frequency", "1"); + g_ceph_context->_conf.apply_changes(nullptr); vector<ObjectStore::Transaction> tls; for (unsigned i = 0 ; i < 3; ++i) { @@ -630,9 +630,9 @@ TEST(TestFileJournal, ReplayDetectCorruptPayload) { } TEST(TestFileJournal, ReplayDetectCorruptHeader) { - g_ceph_context->_conf->set_val("journal_ignore_corruption", "true"); - g_ceph_context->_conf->set_val("journal_write_header_frequency", "1"); - g_ceph_context->_conf->apply_changes(NULL); + g_ceph_context->_conf.set_val("journal_ignore_corruption", "true"); + g_ceph_context->_conf.set_val("journal_write_header_frequency", "1"); + g_ceph_context->_conf.apply_changes(nullptr); vector<ObjectStore::Transaction> tls; for (unsigned i = 0 ; i < 3; ++i) { diff --git a/src/test/test_ipaddr.cc b/src/test/test_ipaddr.cc index 36ff9738704..ffd7b791135 100644 --- a/src/test/test_ipaddr.cc +++ b/src/test/test_ipaddr.cc @@ -633,14 +633,14 @@ TEST(pick_address, filtering) ipv6(&a_three, "2001:1234:5678:90ab::cdef"); CephContext *cct = new CephContext(CEPH_ENTITY_TYPE_MON); - cct->_conf->_clear_safe_to_start_threads(); // so we can set configs + cct->_conf._clear_safe_to_start_threads(); // so we can set configs - cct->_conf->set_val("public_addr", ""); - cct->_conf->set_val("public_network", ""); - cct->_conf->set_val("public_network_interface", ""); - cct->_conf->set_val("cluster_addr", ""); - cct->_conf->set_val("cluster_network", ""); - cct->_conf->set_val("cluster_network_interface", ""); + cct->_conf.set_val("public_addr", ""); + cct->_conf.set_val("public_network", ""); + cct->_conf.set_val("public_network_interface", ""); + cct->_conf.set_val("cluster_addr", ""); + cct->_conf.set_val("cluster_network", ""); + cct->_conf.set_val("cluster_network_interface", ""); entity_addrvec_t av; { @@ -666,7 +666,7 @@ TEST(pick_address, filtering) ASSERT_EQ(string("[::]:0/0"), stringify(av.v[0])); } { - cct->_conf->set_val("public_network", "10.2.0.0/16"); + cct->_conf.set_val("public_network", "10.2.0.0/16"); int r = pick_addresses(cct, CEPH_PICK_ADDRESS_PUBLIC | CEPH_PICK_ADDRESS_IPV4 | @@ -676,11 +676,11 @@ TEST(pick_address, filtering) ASSERT_EQ(0, r); ASSERT_EQ(1, av.v.size()); ASSERT_EQ(string("10.2.1.123:0/0"), stringify(av.v[0])); - cct->_conf->set_val("public_network", ""); + cct->_conf.set_val("public_network", ""); } { - cct->_conf->set_val("public_network", "10.0.0.0/8"); - cct->_conf->set_val("public_network_interface", "eth1"); + cct->_conf.set_val("public_network", "10.0.0.0/8"); + cct->_conf.set_val("public_network_interface", "eth1"); int r = pick_addresses(cct, CEPH_PICK_ADDRESS_PUBLIC | CEPH_PICK_ADDRESS_IPV4 | @@ -690,12 +690,12 @@ TEST(pick_address, filtering) ASSERT_EQ(0, r); ASSERT_EQ(1, av.v.size()); ASSERT_EQ(string("10.2.1.123:0/0"), stringify(av.v[0])); - cct->_conf->set_val("public_network", ""); - cct->_conf->set_val("public_network_interface", ""); + cct->_conf.set_val("public_network", ""); + cct->_conf.set_val("public_network_interface", ""); } { - cct->_conf->set_val("public_network", "10.2.0.0/16"); - cct->_conf->set_val("cluster_network", "10.1.0.0/16"); + cct->_conf.set_val("public_network", "10.2.0.0/16"); + cct->_conf.set_val("cluster_network", "10.1.0.0/16"); int r = pick_addresses(cct, CEPH_PICK_ADDRESS_PUBLIC | CEPH_PICK_ADDRESS_IPV4 | @@ -705,12 +705,12 @@ TEST(pick_address, filtering) ASSERT_EQ(0, r); ASSERT_EQ(1, av.v.size()); ASSERT_EQ(string("10.2.1.123:0/0"), stringify(av.v[0])); - cct->_conf->set_val("public_network", ""); - cct->_conf->set_val("cluster_network", ""); + cct->_conf.set_val("public_network", ""); + cct->_conf.set_val("cluster_network", ""); } { - cct->_conf->set_val("public_network", "10.2.0.0/16"); - cct->_conf->set_val("cluster_network", "10.1.0.0/16"); + cct->_conf.set_val("public_network", "10.2.0.0/16"); + cct->_conf.set_val("cluster_network", "10.1.0.0/16"); int r = pick_addresses(cct, CEPH_PICK_ADDRESS_CLUSTER | CEPH_PICK_ADDRESS_IPV4 | @@ -720,12 +720,12 @@ TEST(pick_address, filtering) ASSERT_EQ(0, r); ASSERT_EQ(1, av.v.size()); ASSERT_EQ(string("10.1.1.2:0/0"), stringify(av.v[0])); - cct->_conf->set_val("public_network", ""); - cct->_conf->set_val("cluster_network", ""); + cct->_conf.set_val("public_network", ""); + cct->_conf.set_val("cluster_network", ""); } { - cct->_conf->set_val("public_network", "2001::/16"); + cct->_conf.set_val("public_network", "2001::/16"); int r = pick_addresses(cct, CEPH_PICK_ADDRESS_PUBLIC | CEPH_PICK_ADDRESS_IPV6 | @@ -735,11 +735,11 @@ TEST(pick_address, filtering) ASSERT_EQ(0, r); ASSERT_EQ(1, av.v.size()); ASSERT_EQ(string("[2001:1234:5678:90ab::cdef]:0/0"), stringify(av.v[0])); - cct->_conf->set_val("public_network", ""); + cct->_conf.set_val("public_network", ""); } { - cct->_conf->set_val("public_network", "2001::/16 10.0.0.0/8"); - cct->_conf->set_val("public_network_interface", "eth1"); + cct->_conf.set_val("public_network", "2001::/16 10.0.0.0/8"); + cct->_conf.set_val("public_network_interface", "eth1"); int r = pick_addresses(cct, CEPH_PICK_ADDRESS_PUBLIC | CEPH_PICK_ADDRESS_IPV4 | @@ -751,12 +751,12 @@ TEST(pick_address, filtering) ASSERT_EQ(2, av.v.size()); ASSERT_EQ(string("[2001:1234:5678:90ab::cdef]:0/0"), stringify(av.v[0])); ASSERT_EQ(string("10.2.1.123:0/0"), stringify(av.v[1])); - cct->_conf->set_val("public_network", ""); - cct->_conf->set_val("public_network_interface", ""); + cct->_conf.set_val("public_network", ""); + cct->_conf.set_val("public_network_interface", ""); } { - cct->_conf->set_val("public_network", "2001::/16 10.0.0.0/8"); - cct->_conf->set_val("public_network_interface", "eth1"); + cct->_conf.set_val("public_network", "2001::/16 10.0.0.0/8"); + cct->_conf.set_val("public_network_interface", "eth1"); int r = pick_addresses(cct, CEPH_PICK_ADDRESS_PUBLIC | CEPH_PICK_ADDRESS_IPV4 | @@ -769,12 +769,12 @@ TEST(pick_address, filtering) ASSERT_EQ(2, av.v.size()); ASSERT_EQ(string("10.2.1.123:0/0"), stringify(av.v[0])); ASSERT_EQ(string("[2001:1234:5678:90ab::cdef]:0/0"), stringify(av.v[1])); - cct->_conf->set_val("public_network", ""); - cct->_conf->set_val("public_network_interface", ""); + cct->_conf.set_val("public_network", ""); + cct->_conf.set_val("public_network_interface", ""); } { - cct->_conf->set_val("public_network", "2001::/16"); + cct->_conf.set_val("public_network", "2001::/16"); int r = pick_addresses(cct, CEPH_PICK_ADDRESS_PUBLIC | CEPH_PICK_ADDRESS_IPV6 | @@ -786,7 +786,7 @@ TEST(pick_address, filtering) ASSERT_EQ(2, av.v.size()); ASSERT_EQ(string("msgr2:[2001:1234:5678:90ab::cdef]:0/0"), stringify(av.v[0])); ASSERT_EQ(string("[2001:1234:5678:90ab::cdef]:0/0"), stringify(av.v[1])); - cct->_conf->set_val("public_network", ""); + cct->_conf.set_val("public_network", ""); } { diff --git a/src/test/test_workqueue.cc b/src/test/test_workqueue.cc index f43e267bd60..0b3daeb0555 100644 --- a/src/test/test_workqueue.cc +++ b/src/test/test_workqueue.cc @@ -25,28 +25,28 @@ TEST(WorkQueue, Resize) sleep(1); ASSERT_EQ(2, tp.get_num_threads()); - g_conf->set_val("filestore op threads", "5"); - g_conf->apply_changes(&cout); + g_conf().set_val("filestore op threads", "5"); + g_conf().apply_changes(&cout); sleep(1); ASSERT_EQ(5, tp.get_num_threads()); - g_conf->set_val("filestore op threads", "3"); - g_conf->apply_changes(&cout); + g_conf().set_val("filestore op threads", "3"); + g_conf().apply_changes(&cout); sleep(1); ASSERT_EQ(3, tp.get_num_threads()); - g_conf->set_val("filestore op threads", "0"); - g_conf->apply_changes(&cout); + g_conf().set_val("filestore op threads", "0"); + g_conf().apply_changes(&cout); sleep(1); ASSERT_EQ(0, tp.get_num_threads()); - g_conf->set_val("filestore op threads", "15"); - g_conf->apply_changes(&cout); + g_conf().set_val("filestore op threads", "15"); + g_conf().apply_changes(&cout); sleep(1); ASSERT_EQ(15, tp.get_num_threads()); - g_conf->set_val("filestore op threads", "-1"); - g_conf->apply_changes(&cout); + g_conf().set_val("filestore op threads", "-1"); + g_conf().apply_changes(&cout); sleep(1); ASSERT_EQ(15, tp.get_num_threads()); diff --git a/src/test/testmsgr.cc b/src/test/testmsgr.cc index 4765757c8e7..99640e52a83 100644 --- a/src/test/testmsgr.cc +++ b/src/test/testmsgr.cc @@ -90,9 +90,9 @@ int main(int argc, const char **argv, const char *envp[]) { ostringstream ss; ss << mc.monmap.get_addr(whoami); std::string sss(ss.str()); - g_ceph_context->_conf->set_val("public_addr", sss.c_str()); - g_ceph_context->_conf->apply_changes(NULL); - std::string public_msgr_type = g_conf->ms_public_type.empty() ? g_conf->get_val<std::string>("ms_type") : g_conf->ms_public_type; + g_ceph_context->_conf.set_val("public_addr", sss.c_str()); + g_ceph_context->_conf.apply_changes(nullptr); + std::string public_msgr_type = g_conf()->ms_public_type.empty() ? g_conf().get_val<std::string>("ms_type") : g_conf()->ms_public_type; Messenger *rank = Messenger::create(g_ceph_context, public_msgr_type, entity_name_t::MON(whoami), "tester", diff --git a/src/tools/ceph_monstore_tool.cc b/src/tools/ceph_monstore_tool.cc index 3b5edc253d1..f100b1e5017 100644 --- a/src/tools/ceph_monstore_tool.cc +++ b/src/tools/ceph_monstore_tool.cc @@ -603,7 +603,7 @@ static int update_mgrmap(MonitorDBStore& st) // mgr expects epoch > 1 map.epoch++; auto initial_modules = - get_str_vec(g_ceph_context->_conf->get_val<string>("mgr_initial_modules")); + get_str_vec(g_ceph_context->_conf.get_val<string>("mgr_initial_modules")); copy(begin(initial_modules), end(initial_modules), inserter(map.modules, end(map.modules))); @@ -840,8 +840,7 @@ int main(int argc, char **argv) { CODE_ENVIRONMENT_UTILITY, CINIT_FLAG_NO_MON_CONFIG); common_init_finish(g_ceph_context); - g_ceph_context->_conf->apply_changes(NULL); - g_conf = g_ceph_context->_conf; + cct->_conf.apply_changes(nullptr); // this is where we'll write *whatever*, on a per-command basis. // not all commands require some place to write their things. diff --git a/src/tools/ceph_objectstore_tool.cc b/src/tools/ceph_objectstore_tool.cc index be65987c6d5..6f9fcbfc601 100644 --- a/src/tools/ceph_objectstore_tool.cc +++ b/src/tools/ceph_objectstore_tool.cc @@ -3267,12 +3267,11 @@ int main(int argc, char **argv) CODE_ENVIRONMENT_UTILITY_NODOUT, 0); common_init_finish(g_ceph_context); - g_conf = g_ceph_context->_conf; if (debug) { - g_conf->set_val_or_die("log_to_stderr", "true"); - g_conf->set_val_or_die("err_to_stderr", "true"); + g_conf().set_val_or_die("log_to_stderr", "true"); + g_conf().set_val_or_die("err_to_stderr", "true"); } - g_conf->apply_changes(NULL); + g_conf().apply_changes(nullptr); // Special list handling. Treating pretty_format as human readable, // with one object per line and not an enclosing array. @@ -3290,7 +3289,7 @@ int main(int argc, char **argv) // Special handling for filestore journal, so we can dump it without mounting if (op == "dump-journal" && type == "filestore") { - int ret = mydump_journal(formatter, jpath, g_conf->journal_dio); + int ret = mydump_journal(formatter, jpath, g_conf()->journal_dio); if (ret < 0) { cerr << "journal-path: " << jpath << ": " << cpp_strerror(ret) << std::endl; diff --git a/src/tools/ceph_osdomap_tool.cc b/src/tools/ceph_osdomap_tool.cc index b377aa163aa..59746b5c855 100644 --- a/src/tools/ceph_osdomap_tool.cc +++ b/src/tools/ceph_osdomap_tool.cc @@ -79,13 +79,12 @@ int main(int argc, char **argv) { NULL, ceph_options, CEPH_ENTITY_TYPE_OSD, CODE_ENVIRONMENT_UTILITY_NODOUT, 0); common_init_finish(g_ceph_context); - g_ceph_context->_conf->apply_changes(NULL); - g_conf = g_ceph_context->_conf; + cct->_conf.apply_changes(nullptr); if (debug) { - g_conf->set_val_or_die("log_to_stderr", "true"); - g_conf->set_val_or_die("err_to_stderr", "true"); + g_conf().set_val_or_die("log_to_stderr", "true"); + g_conf().set_val_or_die("err_to_stderr", "true"); } - g_conf->apply_changes(NULL); + g_conf().apply_changes(nullptr); if (vm.count("omap-path") == 0) { std::cerr << "Required argument --omap-path" << std::endl; diff --git a/src/tools/cephfs/DataScan.cc b/src/tools/cephfs/DataScan.cc index 9b8b6d15bbe..3a4babd27dd 100644 --- a/src/tools/cephfs/DataScan.cc +++ b/src/tools/cephfs/DataScan.cc @@ -351,14 +351,14 @@ int MetadataDriver::inject_unlinked_inode( inode.inode.nlink = 1; inode.inode.truncate_size = -1ull; inode.inode.truncate_seq = 1; - inode.inode.uid = g_conf->mds_root_ino_uid; - inode.inode.gid = g_conf->mds_root_ino_gid; + inode.inode.uid = g_conf()->mds_root_ino_uid; + inode.inode.gid = g_conf()->mds_root_ino_gid; // Force layout to default: should we let users override this so that // they don't have to mount the filesystem to correct it? inode.inode.layout = file_layout_t::get_default(); inode.inode.layout.pool_id = data_pool_id; - inode.inode.dir_layout.dl_dir_hash = g_conf->mds_default_dir_hash; + inode.inode.dir_layout.dl_dir_hash = g_conf()->mds_default_dir_hash; // Assume that we will get our stats wrong, and that we may // be ignoring dirfrags that exist @@ -1644,12 +1644,12 @@ int MetadataDriver::inject_with_backtrace( ancestor_dentry.inode.dirstat.nfiles = 1; ancestor_dentry.inode.dir_layout.dl_dir_hash = - g_conf->mds_default_dir_hash; + g_conf()->mds_default_dir_hash; ancestor_dentry.inode.nlink = 1; ancestor_dentry.inode.ino = ino; - ancestor_dentry.inode.uid = g_conf->mds_root_ino_uid; - ancestor_dentry.inode.gid = g_conf->mds_root_ino_gid; + ancestor_dentry.inode.uid = g_conf()->mds_root_ino_uid; + ancestor_dentry.inode.gid = g_conf()->mds_root_ino_gid; ancestor_dentry.inode.version = 1; ancestor_dentry.inode.backtrace_version = 1; r = inject_linkage(parent_ino, dname, fragment, ancestor_dentry); @@ -1974,8 +1974,8 @@ void MetadataTool::build_file_dentry( out->inode.ino = ino; out->inode.version = 1; out->inode.backtrace_version = 1; - out->inode.uid = g_conf->mds_root_ino_uid; - out->inode.gid = g_conf->mds_root_ino_gid; + out->inode.uid = g_conf()->mds_root_ino_uid; + out->inode.gid = g_conf()->mds_root_ino_gid; } void MetadataTool::build_dir_dentry( @@ -1991,7 +1991,7 @@ void MetadataTool::build_dir_dentry( out->inode.ctime.tv.tv_sec = fragstat.mtime; out->inode.layout = layout; - out->inode.dir_layout.dl_dir_hash = g_conf->mds_default_dir_hash; + out->inode.dir_layout.dl_dir_hash = g_conf()->mds_default_dir_hash; out->inode.truncate_seq = 1; out->inode.truncate_size = -1ull; @@ -2002,7 +2002,7 @@ void MetadataTool::build_dir_dentry( out->inode.ino = ino; out->inode.version = 1; out->inode.backtrace_version = 1; - out->inode.uid = g_conf->mds_root_ino_uid; - out->inode.gid = g_conf->mds_root_ino_gid; + out->inode.uid = g_conf()->mds_root_ino_uid; + out->inode.gid = g_conf()->mds_root_ino_gid; } diff --git a/src/tools/cephfs/JournalScanner.cc b/src/tools/cephfs/JournalScanner.cc index a68c8844126..a2e36f03832 100644 --- a/src/tools/cephfs/JournalScanner.cc +++ b/src/tools/cephfs/JournalScanner.cc @@ -152,7 +152,7 @@ int JournalScanner::scan_header() int JournalScanner::scan_events() { - uint64_t object_size = g_conf->mds_log_segment_size; + uint64_t object_size = g_conf()->mds_log_segment_size; if (object_size == 0) { // Default layout object size object_size = file_layout_t::get_default().object_size; diff --git a/src/tools/cephfs/JournalTool.cc b/src/tools/cephfs/JournalTool.cc index 0bbb832ed59..18f7a8183dd 100644 --- a/src/tools/cephfs/JournalTool.cc +++ b/src/tools/cephfs/JournalTool.cc @@ -1071,7 +1071,7 @@ int JournalTool::erase_region(JournalScanner const &js, uint64_t const pos, uint // Write log stream region to RADOS // FIXME: get object size somewhere common to scan_events - uint32_t object_size = g_conf->mds_log_segment_size; + uint32_t object_size = g_conf()->mds_log_segment_size; if (object_size == 0) { // Default layout object size object_size = file_layout_t::get_default().object_size; diff --git a/src/tools/cephfs/MDSUtility.cc b/src/tools/cephfs/MDSUtility.cc index 80ce3c34934..e9af80897b7 100644 --- a/src/tools/cephfs/MDSUtility.cc +++ b/src/tools/cephfs/MDSUtility.cc @@ -49,7 +49,7 @@ MDSUtility::~MDSUtility() int MDSUtility::init() { // Initialize Messenger - int r = messenger->bind(g_conf->public_addr); + int r = messenger->bind(g_conf()->public_addr); if (r < 0) return r; diff --git a/src/tools/cephfs/Resetter.cc b/src/tools/cephfs/Resetter.cc index 9573e6a6239..b1d3658a05e 100644 --- a/src/tools/cephfs/Resetter.cc +++ b/src/tools/cephfs/Resetter.cc @@ -159,7 +159,7 @@ int Resetter::reset_hard() file_layout_t default_log_layout = MDCache::gen_default_log_layout( fsmap->get_filesystem(role.fscid)->mds_map); - journaler.create(&default_log_layout, g_conf->mds_journal_format); + journaler.create(&default_log_layout, g_conf()->mds_journal_format); C_SaferCond cond; { diff --git a/src/tools/cephfs/TableTool.cc b/src/tools/cephfs/TableTool.cc index 60616c38e12..ed768d37ee6 100644 --- a/src/tools/cephfs/TableTool.cc +++ b/src/tools/cephfs/TableTool.cc @@ -227,7 +227,7 @@ public: while(true) { std::map<std::string, bufferlist> values; int r = io->omap_get_vals(object_name, last_key, - g_conf->mds_sessionmap_keys_per_op, &values); + g_conf()->mds_sessionmap_keys_per_op, &values); if (r != 0) { derr << "error reading values: " << cpp_strerror(r) << dendl; diff --git a/src/tools/rbd/ArgumentTypes.cc b/src/tools/rbd/ArgumentTypes.cc index ca87bfea0ef..6b4ea3af674 100644 --- a/src/tools/rbd/ArgumentTypes.cc +++ b/src/tools/rbd/ArgumentTypes.cc @@ -5,7 +5,7 @@ #include "tools/rbd/Shell.h" #include "tools/rbd/Utils.h" #include "include/rbd/features.h" -#include "common/config.h" +#include "common/config_proxy.h" #include "common/strtol.h" #include "common/Formatter.h" #include "global/global_context.h" @@ -507,7 +507,7 @@ void validate(boost::any& v, const std::vector<std::string>& values, po::validators::check_first_occurrence(v); const std::string &s = po::validators::get_single_string(values); - g_conf->set_val_or_die("keyfile", s.c_str()); + g_conf().set_val_or_die("keyfile", s.c_str()); v = boost::any(s); } diff --git a/src/tools/rbd/Utils.cc b/src/tools/rbd/Utils.cc index 6aedfb34670..e436a876ab6 100644 --- a/src/tools/rbd/Utils.cc +++ b/src/tools/rbd/Utils.cc @@ -84,7 +84,7 @@ int read_string(int fd, unsigned max, std::string *out) { int extract_spec(const std::string &spec, std::string *pool_name, std::string *namespace_name, std::string *name, std::string *snap_name, SpecValidation spec_validation) { - if (!g_ceph_context->_conf->get_val<bool>("rbd_validate_names")) { + if (!g_ceph_context->_conf.get_val<bool>("rbd_validate_names")) { spec_validation = SPEC_VALIDATION_NONE; } @@ -165,7 +165,7 @@ std::string get_positional_argument(const po::variables_map &vm, size_t index) { } std::string get_default_pool_name() { - return g_ceph_context->_conf->get_val<std::string>("rbd_default_pool"); + return g_ceph_context->_conf.get_val<std::string>("rbd_default_pool"); } std::string get_pool_name(const po::variables_map &vm, size_t *arg_index) { @@ -538,14 +538,14 @@ int get_journal_options(const boost::program_options::variables_map &vm, } opts->set(RBD_IMAGE_OPTION_JOURNAL_ORDER, order); - int r = g_conf->set_val("rbd_journal_order", stringify(order)); + int r = g_conf().set_val("rbd_journal_order", stringify(order)); assert(r == 0); } if (vm.count(at::JOURNAL_SPLAY_WIDTH)) { opts->set(RBD_IMAGE_OPTION_JOURNAL_SPLAY_WIDTH, vm[at::JOURNAL_SPLAY_WIDTH].as<uint64_t>()); - int r = g_conf->set_val("rbd_journal_splay_width", + int r = g_conf().set_val("rbd_journal_splay_width", stringify( vm[at::JOURNAL_SPLAY_WIDTH].as<uint64_t>())); assert(r == 0); @@ -554,7 +554,7 @@ int get_journal_options(const boost::program_options::variables_map &vm, opts->set(RBD_IMAGE_OPTION_JOURNAL_POOL, vm[at::JOURNAL_POOL].as<std::string>()); - int r = g_conf->set_val("rbd_journal_pool", + int r = g_conf().set_val("rbd_journal_pool", vm[at::JOURNAL_POOL].as<std::string>()); assert(r == 0); } @@ -621,8 +621,8 @@ int get_formatter(const po::variables_map &vm, } void init_context() { - g_conf->set_val_or_die("rbd_cache_writethrough_until_flush", "false"); - g_conf->apply_changes(NULL); + g_conf().set_val_or_die("rbd_cache_writethrough_until_flush", "false"); + g_conf().apply_changes(nullptr); common_init_finish(g_ceph_context); } @@ -670,7 +670,7 @@ int init_io_ctx(librados::Rados &rados, const std::string &pool_name, } void disable_cache() { - g_conf->set_val_or_die("rbd_cache", "false"); + g_conf().set_val_or_die("rbd_cache", "false"); } int open_image(librados::IoCtx &io_ctx, const std::string &image_name, @@ -844,7 +844,7 @@ std::string timestr(time_t t) { } uint64_t get_rbd_default_features(CephContext* cct) { - auto features = cct->_conf->get_val<std::string>("rbd_default_features"); + auto features = cct->_conf.get_val<std::string>("rbd_default_features"); return boost::lexical_cast<uint64_t>(features); } diff --git a/src/tools/rbd/action/Create.cc b/src/tools/rbd/action/Create.cc index daae502df97..dd259f4ad40 100644 --- a/src/tools/rbd/action/Create.cc +++ b/src/tools/rbd/action/Create.cc @@ -64,7 +64,7 @@ struct thick_provision_writer { assert(r >= 0); uint64_t order; if (info.order == 0) { - order = g_conf->get_val<int64_t>("rbd_default_order"); + order = g_conf().get_val<int64_t>("rbd_default_order"); } else { order = info.order; } @@ -73,7 +73,7 @@ struct thick_provision_writer { chunk_size = image->get_stripe_unit(); } - concurr = g_conf->get_val<int64_t>("rbd_concurrent_management_ops"); + concurr = g_conf().get_val<int64_t>("rbd_concurrent_management_ops"); io_status.in_flight = 0; io_status.io_error = 0; } @@ -181,7 +181,7 @@ int thick_write(const std::string &image_name,librados::IoCtx &io_ctx, // To prevent writesame from discarding data, thick_write sets // the rbd_discard_on_zeroed_write_same option to false. assert(g_conf != nullptr); - r = g_conf->set_val("rbd_discard_on_zeroed_write_same", "false"); + r = g_conf().set_val("rbd_discard_on_zeroed_write_same", "false"); assert(r == 0); r = utils::open_image(io_ctx, image_name, false, &image); if (r < 0) { diff --git a/src/tools/rbd/action/Export.cc b/src/tools/rbd/action/Export.cc index 53dfa9c6aaf..8e9f80306c0 100644 --- a/src/tools/rbd/action/Export.cc +++ b/src/tools/rbd/action/Export.cc @@ -190,7 +190,7 @@ int do_export_diff_fd(librbd::Image& image, const char *fromsnapname, } } ExportDiffContext edc(&image, fd, info.size, - g_conf->get_val<int64_t>("rbd_concurrent_management_ops"), + g_conf().get_val<int64_t>("rbd_concurrent_management_ops"), no_progress, export_format); r = image.diff_iterate2(fromsnapname, 0, info.size, true, whole_object, &C_ExportDiff::export_diff_cb, (void *)&edc); @@ -565,7 +565,7 @@ static int do_export(librbd::Image& image, const char *path, bool no_progress, i fd = STDOUT_FILENO; max_concurrent_ops = 1; } else { - max_concurrent_ops = g_conf->get_val<int64_t>("rbd_concurrent_management_ops"); + max_concurrent_ops = g_conf().get_val<int64_t>("rbd_concurrent_management_ops"); fd = open(path, O_WRONLY | O_CREAT | O_EXCL, 0644); if (fd < 0) { return -errno; diff --git a/src/tools/rbd/action/Import.cc b/src/tools/rbd/action/Import.cc index 6b8a29459ca..8f1f6078538 100644 --- a/src/tools/rbd/action/Import.cc +++ b/src/tools/rbd/action/Import.cc @@ -37,7 +37,7 @@ struct ImportDiffContext { ImportDiffContext(librbd::Image *image, int fd, size_t size, bool no_progress) : image(image), fd(fd), size(size), pc("Importing image diff", no_progress), throttle((fd == STDIN_FILENO) ? 1 : - g_conf->get_val<int64_t>("rbd_concurrent_management_ops"), + g_conf().get_val<int64_t>("rbd_concurrent_management_ops"), false), last_offset(0) { } @@ -744,7 +744,7 @@ static int do_import_v1(int fd, librbd::Image &image, uint64_t size, throttle.reset(new SimpleThrottle(1, false)); } else { throttle.reset(new SimpleThrottle( - g_conf->get_val<int64_t>("rbd_concurrent_management_ops"), false)); + g_conf().get_val<int64_t>("rbd_concurrent_management_ops"), false)); } reqlen = min<uint64_t>(reqlen, size); @@ -838,7 +838,7 @@ static int do_import(librados::Rados &rados, librbd::RBD &rbd, uint64_t order; if (opts.get(RBD_IMAGE_OPTION_ORDER, &order) != 0) { - order = g_conf->get_val<int64_t>("rbd_default_order"); + order = g_conf().get_val<int64_t>("rbd_default_order"); } // try to fill whole imgblklen blocks for sparsification diff --git a/src/tools/rbd/action/Kernel.cc b/src/tools/rbd/action/Kernel.cc index 7e01cf1dac8..ef2c8f30ff0 100644 --- a/src/tools/rbd/action/Kernel.cc +++ b/src/tools/rbd/action/Kernel.cc @@ -8,7 +8,7 @@ #include "include/krbd.h" #include "include/stringify.h" #include "include/uuid.h" -#include "common/config.h" +#include "common/config_proxy.h" #include "common/errno.h" #include "common/safe_io.h" #include "common/strtol.h" @@ -430,7 +430,7 @@ int execute_map(const po::variables_map &vm, // parse default options first so they can be overwritten by cli options r = parse_map_options( - g_conf->get_val<std::string>("rbd_default_map_options")); + g_conf().get_val<std::string>("rbd_default_map_options")); if (r < 0) { std::cerr << "rbd: couldn't parse default map options" << std::endl; return r; diff --git a/src/tools/rbd/action/List.cc b/src/tools/rbd/action/List.cc index 65380f8987a..f6b26c032ca 100644 --- a/src/tools/rbd/action/List.cc +++ b/src/tools/rbd/action/List.cc @@ -297,7 +297,7 @@ int execute(const po::variables_map &vm, } r = do_list(pool_name, namespace_name, vm["long"].as<bool>(), - g_conf->get_val<int64_t>("rbd_concurrent_management_ops"), + g_conf().get_val<int64_t>("rbd_concurrent_management_ops"), formatter.get()); if (r < 0) { std::cerr << "rbd: list: " << cpp_strerror(r) << std::endl; diff --git a/src/tools/rbd/action/MirrorPool.cc b/src/tools/rbd/action/MirrorPool.cc index 01f1c990517..6f4443d140c 100644 --- a/src/tools/rbd/action/MirrorPool.cc +++ b/src/tools/rbd/action/MirrorPool.cc @@ -481,7 +481,7 @@ public: m_factory(std::bind(ImageRequestAllocator<RequestT>(), std::ref(m_io_ctx), std::ref(m_throttle), std::placeholders::_1, std::forward<Args>(args)...)), - m_throttle(g_conf->get_val<int64_t>("rbd_concurrent_management_ops"), + m_throttle(g_conf().get_val<int64_t>("rbd_concurrent_management_ops"), true) { } diff --git a/src/tools/rbd_ggate/main.cc b/src/tools/rbd_ggate/main.cc index 44a075237f1..23096957bf1 100644 --- a/src/tools/rbd_ggate/main.cc +++ b/src/tools/rbd_ggate/main.cc @@ -93,7 +93,7 @@ static int do_map(int argc, const char *argv[]) auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_DAEMON, CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS); - g_ceph_context->_conf->set_val_or_die("pid_file", ""); + g_ceph_context->_conf.set_val_or_die("pid_file", ""); if (global_init_prefork(g_ceph_context) >= 0) { std::string err; @@ -116,7 +116,7 @@ static int do_map(int argc, const char *argv[]) global_init_chdir(g_ceph_context); if (poolname.empty()) { - poolname = g_ceph_context->_conf->get_val<std::string>("rbd_default_pool"); + poolname = g_ceph_context->_conf.get_val<std::string>("rbd_default_pool"); } std::string devname = boost::starts_with(devpath, "/dev/") ? @@ -200,7 +200,7 @@ static int do_map(int argc, const char *argv[]) std::cout << "/dev/" << drv->get_devname() << std::endl; - if (g_conf->daemonize) { + if (g_conf()->daemonize) { forker.daemonize(); global_init_postfork_start(g_ceph_context); global_init_postfork_finish(g_ceph_context); diff --git a/src/tools/rbd_mirror/ImageSyncThrottler.cc b/src/tools/rbd_mirror/ImageSyncThrottler.cc index cb9474394d9..271a913c4de 100644 --- a/src/tools/rbd_mirror/ImageSyncThrottler.cc +++ b/src/tools/rbd_mirror/ImageSyncThrottler.cc @@ -202,10 +202,10 @@ const char** ImageSyncThrottler<I>::get_tracked_conf_keys() const { } template <typename I> -void ImageSyncThrottler<I>::handle_conf_change(const md_config_t *conf, +void ImageSyncThrottler<I>::handle_conf_change(const ConfigProxy& conf, const set<string> &changed) { if (changed.count("rbd_mirror_concurrent_image_syncs")) { - set_max_concurrent_syncs(conf->get_val<uint64_t>("rbd_mirror_concurrent_image_syncs")); + set_max_concurrent_syncs(conf.get_val<uint64_t>("rbd_mirror_concurrent_image_syncs")); } } diff --git a/src/tools/rbd_mirror/ImageSyncThrottler.h b/src/tools/rbd_mirror/ImageSyncThrottler.h index b5711472a2b..8f965bf7b7e 100644 --- a/src/tools/rbd_mirror/ImageSyncThrottler.h +++ b/src/tools/rbd_mirror/ImageSyncThrottler.h @@ -49,7 +49,7 @@ private: std::set<std::string> m_inflight_ops; const char **get_tracked_conf_keys() const override; - void handle_conf_change(const md_config_t *conf, + void handle_conf_change(const ConfigProxy& conf, const std::set<std::string> &changed) override; }; diff --git a/src/tools/rbd_mirror/main.cc b/src/tools/rbd_mirror/main.cc index 84d7a9de6a4..e93db4c4f8f 100644 --- a/src/tools/rbd_mirror/main.cc +++ b/src/tools/rbd_mirror/main.cc @@ -46,7 +46,7 @@ int main(int argc, const char **argv) CODE_ENVIRONMENT_DAEMON, CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS); - if (g_conf->daemonize) { + if (g_conf()->daemonize) { global_init_daemonize(g_ceph_context); } g_ceph_context->enable_perf_counter(); @@ -62,7 +62,7 @@ int main(int argc, const char **argv) argv_to_vec(argc, argv, cmd_args); // disable unnecessary librbd cache - g_ceph_context->_conf->set_val_or_die("rbd_cache", "false"); + g_ceph_context->_conf.set_val_or_die("rbd_cache", "false"); mirror = new rbd::mirror::Mirror(g_ceph_context, cmd_args); int r = mirror->init(); diff --git a/src/tools/rbd_nbd/rbd-nbd.cc b/src/tools/rbd_nbd/rbd-nbd.cc index 97a46f3caf7..64f13a69133 100644 --- a/src/tools/rbd_nbd/rbd-nbd.cc +++ b/src/tools/rbd_nbd/rbd-nbd.cc @@ -677,7 +677,7 @@ static int do_map(int argc, const char *argv[], Config *cfg) auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_DAEMON, CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS); - g_ceph_context->_conf->set_val_or_die("pid_file", ""); + g_ceph_context->_conf.set_val_or_die("pid_file", ""); if (global_init_prefork(g_ceph_context) >= 0) { std::string err; @@ -860,7 +860,7 @@ static int do_map(int argc, const char *argv[], Config *cfg) cout << cfg->devpath << std::endl; - if (g_conf->daemonize) { + if (g_conf()->daemonize) { global_init_postfork_finish(g_ceph_context); forker.daemonize(); } |