From: Jason Dillaman Date: Thu, 4 Oct 2018 16:48:47 +0000 (-0400) Subject: librbd: use ConfigProxy within ImageCtx to store overrides X-Git-Tag: v14.0.1~91^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f01aa56e7d11d88d50c974ca305373cd18862364;p=ceph.git librbd: use ConfigProxy within ImageCtx to store overrides Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/ImageCtx.cc b/src/librbd/ImageCtx.cc index 6ab0555fa4c..12e2f99dcb3 100644 --- a/src/librbd/ImageCtx.cc +++ b/src/librbd/ImageCtx.cc @@ -96,6 +96,7 @@ public: ImageCtx::ImageCtx(const string &image_name, const string &image_id, const char *snap, IoCtx& p, bool ro) : cct((CephContext*)p.cct()), + config(cct->_conf), perfcounter(NULL), snap_id(CEPH_NOSNAP), snap_exists(true), @@ -813,28 +814,35 @@ public: "rbd_qos_read_bps_limit", false)( "rbd_qos_write_bps_limit", false); - ConfigProxy local_config_t{false}; std::map res; + // reset settings back to global defaults + for (auto& key : config_overrides) { + std::string value; + int r = cct->_conf.get_val(key, &value); + ceph_assert(r == 0); + + config.set_val(key, value); + } + + config_overrides.clear(); _filter_metadata_confs(METADATA_CONF_PREFIX, configs, meta, &res); for (auto it : res) { std::string val(it.second.c_str(), it.second.length()); - int j = local_config_t.set_val(it.first.c_str(), val); + int j = config.set_val(it.first.c_str(), val); if (j < 0) { lderr(cct) << __func__ << " failed to set config " << it.first << " with value " << it.second.c_str() << ": " << j << dendl; } + config_overrides.insert(it.first); } #define ASSIGN_OPTION(config, type) \ do { \ string key = "rbd_"; \ key = key + #config; \ - if (configs[key]) \ - config = local_config_t.get_val("rbd_"#config); \ - else \ - config = cct->_conf.get_val("rbd_"#config); \ + config = config.get_val("rbd_"#config); \ } while (0); ASSIGN_OPTION(non_blocking_aio, bool); diff --git a/src/librbd/ImageCtx.h b/src/librbd/ImageCtx.h index 76679382320..5d6f41c0280 100644 --- a/src/librbd/ImageCtx.h +++ b/src/librbd/ImageCtx.h @@ -7,9 +7,11 @@ #include #include +#include #include #include +#include "common/config_proxy.h" #include "common/event_socket.h" #include "common/Mutex.h" #include "common/Readahead.h" @@ -62,6 +64,9 @@ namespace librbd { struct ImageCtx { CephContext *cct; + ConfigProxy config; + std::set config_overrides; + PerfCounters *perfcounter; struct rbd_obj_header_ondisk header; ::SnapContext snapc; diff --git a/src/test/librbd/mock/MockImageCtx.h b/src/test/librbd/mock/MockImageCtx.h index 028f4fba41f..d027d2dac40 100644 --- a/src/test/librbd/mock/MockImageCtx.h +++ b/src/test/librbd/mock/MockImageCtx.h @@ -118,7 +118,8 @@ struct MockImageCtx { ignore_migrating(image_ctx.ignore_migrating), mtime_update_interval(image_ctx.mtime_update_interval), atime_update_interval(image_ctx.atime_update_interval), - cache(image_ctx.cache) + cache(image_ctx.cache), + config(image_ctx.config) { md_ctx.dup(image_ctx.md_ctx); data_ctx.dup(image_ctx.data_ctx); @@ -339,6 +340,8 @@ struct MockImageCtx { uint64_t mtime_update_interval; uint64_t atime_update_interval; bool cache; + + ConfigProxy config; }; } // namespace librbd