rbd: support pool and image level overrides for rbd_default_map_options

Fixes: https://tracker.ceph.com/issues/52850
Signed-off-by: Christopher Hoffman <choffman@redhat.com>
This commit is contained in:
Christopher Hoffman 2022-02-04 21:25:53 +00:00 committed by Ilya Dryomov
parent d11d2e72da
commit 9afc971282
2 changed files with 24 additions and 6 deletions

View File

@ -28,7 +28,6 @@ typedef std::map<std::string_view, std::pair<std::string, config_source_t>> Pare
static std::set<std::string_view> 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",

View File

@ -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<std::string>("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) {
std::cerr << "rbd: couldn't parse default map options" << std::endl;
return r;
}
r = utils::open_image(ioctx, image_name, true, &image);
if (r < 0) {
return r;
}
MapOptions default_map_options;
std::vector<librbd::config_option_t> 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;