]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: fix default pool handling for krbd map/unmap
authorIlya Dryomov <idryomov@gmail.com>
Wed, 26 Aug 2020 12:12:29 +0000 (14:12 +0200)
committerMykola Golub <mgolub@suse.com>
Mon, 19 Jul 2021 09:47:24 +0000 (12:47 +0300)
The default pool name does not get passed to the kernel since commit
96f05a7956b3 ("rbd: delay determination of default pool name").  The
kernel ends up interpreting the image name as the pool name (and the
snapshot name as the image name).

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
(cherry picked from commit c06338f33c9c8535562c99b6f2b779fbedbba058)

src/tools/rbd/action/Kernel.cc

index 80b7ad4e30285bab7b964e5351e5b06a8df15754..23bc3231ae8031c1e9fa0a750b69071a2cb68f11 100644 (file)
@@ -533,15 +533,16 @@ int execute_map(const po::variables_map &vm,
     put_map_option("exclusive", "exclusive", &map_options);
   }
 
+  // connect to the cluster to get the default pool and the default map
+  // options
   librados::Rados rados;
-  librados::IoCtx ioctx;
-  r = utils::init(pool_name, nspace_name, &rados, &ioctx);
+  r = utils::init_rados(&rados);
   if (r < 0) {
     return r;
   }
 
-  // delay processing default options until after global option overrides have
-  // been received
+  utils::normalize_pool_name(&pool_name);
+
   MapOptions default_map_options;
   r = parse_map_options(
       g_conf().get_val<std::string>("rbd_default_map_options"),
@@ -550,7 +551,6 @@ int execute_map(const po::variables_map &vm,
     std::cerr << "rbd: couldn't parse default map options" << std::endl;
     return r;
   }
-
   for (auto& [key, value] : default_map_options) {
     if (map_options.count(key) == 0) {
       map_options[key] = value;
@@ -607,7 +607,16 @@ int execute_unmap(const po::variables_map &vm,
     }
   }
 
-  utils::init_context();
+  if (device_name.empty() && pool_name.empty()) {
+    // connect to the cluster to get the default pool
+    librados::Rados rados;
+    r = utils::init_rados(&rados);
+    if (r < 0) {
+      return r;
+    }
+
+    utils::normalize_pool_name(&pool_name);
+  }
 
   r = do_kernel_unmap(device_name.empty() ? nullptr : device_name.c_str(),
                       pool_name.c_str(), nspace_name.c_str(),