]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: support pool and image level overrides for rbd_default_map_options
authorChristopher Hoffman <choffman@redhat.com>
Fri, 4 Feb 2022 21:25:53 +0000 (21:25 +0000)
committerIlya Dryomov <idryomov@gmail.com>
Fri, 18 Feb 2022 16:19:45 +0000 (17:19 +0100)
Fixes: https://tracker.ceph.com/issues/52850
Signed-off-by: Christopher Hoffman <choffman@redhat.com>
src/librbd/api/Config.cc
src/tools/rbd/action/Kernel.cc

index 07e37162b4340476b71fe98fdb8b321e1de39a22..8148607e39ff217ef48620a62689cb5058f7cf8d 100644 (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",
index aa67eaa6cbb51b19099e63ca32a6408bc9b0dc1d..117f9492d0918b86e6fee7ee31c15247cd85d336 100644 (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) {
+    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<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;