From: Jason Dillaman Date: Mon, 8 Oct 2018 14:45:59 +0000 (-0400) Subject: librbd: helper method to apply pool-level config overrides X-Git-Tag: v14.0.1~91^2~3 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=66f4ebbb905f097c20636858a1127b938c5e9833;p=ceph-ci.git librbd: helper method to apply pool-level config overrides Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/api/Config.cc b/src/librbd/api/Config.cc index 6b7061043e6..eec026f3191 100644 --- a/src/librbd/api/Config.cc +++ b/src/librbd/api/Config.cc @@ -207,6 +207,30 @@ int Config::list(I *image_ctx, std::vector *options) { return 0; } +template +void Config::apply_pool_overrides(librados::IoCtx& io_ctx, + ConfigProxy* config) { + CephContext *cct = reinterpret_cast(io_ctx.cct()); + + Options opts(io_ctx, false); + int r = opts.init(); + if (r < 0) { + lderr(cct) << "failed to read pool config overrides: " << cpp_strerror(r) + << dendl; + return; + } + + for (auto& pair : opts) { + if (pair.second.second == RBD_CONFIG_SOURCE_POOL) { + r = config->set_val(pair.first, pair.second.first); + if (r < 0) { + lderr(cct) << "failed to override pool config " << pair.first << "=" + << pair.second.first << ": " << cpp_strerror(r) << dendl; + } + } + } +} + } // namespace api } // namespace librbd diff --git a/src/librbd/api/Config.h b/src/librbd/api/Config.h index 9f27000966d..13213728bd4 100644 --- a/src/librbd/api/Config.h +++ b/src/librbd/api/Config.h @@ -6,6 +6,8 @@ #include "include/rbd/librbd.hpp" +struct ConfigProxy; + namespace librados { class IoCtx; @@ -27,6 +29,9 @@ public: static bool is_option_name(ImageCtxT *image_ctx, const std::string &name); static int list(ImageCtxT *image_ctx, std::vector *options); + + static void apply_pool_overrides(librados::IoCtx& io_ctx, + ConfigProxy* config); }; } // namespace api