From: Christopher Hoffman Date: Fri, 4 Feb 2022 21:25:53 +0000 (+0000) Subject: rbd: support pool and image level overrides for rbd_default_map_options X-Git-Tag: v17.1.0~2^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=569657fa933b54cdb076cc6ef772cb61ef6964af;p=ceph.git rbd: support pool and image level overrides for rbd_default_map_options Fixes: https://tracker.ceph.com/issues/52850 Signed-off-by: Christopher Hoffman (cherry picked from commit 9afc9712824a92fd6bdb2574c5880ab835236ed1) --- diff --git a/src/librbd/api/Config.cc b/src/librbd/api/Config.cc index 07e37162b43..8148607e39f 100644 --- a/src/librbd/api/Config.cc +++ b/src/librbd/api/Config.cc @@ -28,7 +28,6 @@ typedef std::map> Pare static std::set EXCLUDE_OPTIONS { "rbd_auto_exclusive_lock_until_manual_request", "rbd_default_format", - "rbd_default_map_options", "rbd_default_pool", "rbd_discard_on_zeroed_write_same", "rbd_op_thread_timeout", diff --git a/src/tools/rbd/action/Kernel.cc b/src/tools/rbd/action/Kernel.cc index aa67eaa6cbb..117f9492d09 100644 --- a/src/tools/rbd/action/Kernel.cc +++ b/src/tools/rbd/action/Kernel.cc @@ -549,14 +549,33 @@ int execute_map(const po::variables_map &vm, utils::normalize_pool_name(&pool_name); - MapOptions default_map_options; - r = parse_map_options( - g_conf().get_val("rbd_default_map_options"), - &default_map_options); + librados::IoCtx ioctx; + librbd::Image image; + r = utils::init_io_ctx(rados, pool_name, nspace_name, &ioctx); + if (r < 0) { + return r; + } + + r = utils::open_image(ioctx, image_name, true, &image); if (r < 0) { - std::cerr << "rbd: couldn't parse default map options" << std::endl; return r; } + + MapOptions default_map_options; + std::vector options; + image.config_list(&options); + for (const auto &option : options) { + if (option.name == "rbd_default_map_options") { + r = parse_map_options(option.value, &default_map_options); + if (r < 0) { + std::cerr << "rbd: couldn't parse default map options" << std::endl; + return r; + } + + break; + } + } + for (auto& [key, value] : default_map_options) { if (map_options.count(key) == 0) { map_options[key] = value;