]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
blk: add configuration to be set to select block driver
authorChangcheng Liu <changcheng.liu@aliyun.com>
Thu, 16 Jul 2020 10:24:49 +0000 (18:24 +0800)
committerChangcheng Liu <changcheng.liu@aliyun.com>
Tue, 21 Jul 2020 05:56:35 +0000 (13:56 +0800)
Besides blk's internal policy to auto select block drvier,
it need supply one configuration to let user to select the
driver for specific requirement.

Suggested-by: Kefu Chai <kefu@redhat.com>
Signed-off-by: Changcheng Liu <changcheng.liu@aliyun.com>
src/blk/BlockDevice.cc
src/blk/BlockDevice.h
src/common/options.cc

index 05e1dd24d892d7b68f2f54cb2d5a7ebe11d77831..b1a97ef7ff652153252d94730b7e2fb8fa141cca 100644 (file)
@@ -108,6 +108,32 @@ BlockDevice::detect_device_type(const std::string& path)
   return block_device_t::aio;
 }
 
+BlockDevice::block_device_t
+BlockDevice::device_type_from_name(const std::string& blk_dev_name)
+{
+#if defined(HAVE_LIBAIO) || defined(HAVE_POSIXAIO)
+  if (blk_dev_name == "aio") {
+    return block_device_t::aio;
+  }
+#endif
+#if defined(HAVE_SPDK)
+  if (blk_dev_name == "spdk") {
+    return block_device_t::spdk;
+  }
+#endif
+#if defined(HAVE_BLUESTORE_PMEM)
+  if (blk_dev_name == "pmem") {
+    return block_device_t::pmem;
+  }
+#endif
+#if (defined(HAVE_LIBAIO) || defined(HAVE_POSIXAIO)) && defined(HAVE_LIZBC)
+  if (blk_dev_name == "hm_smr") {
+    return block_device_t::hm_smr;
+  }
+#endif
+  return block_device_t::unknown;
+}
+
 BlockDevice* BlockDevice::create_with_type(block_device_t device_type,
   CephContext* cct, const std::string& path, aio_callback_t cb,
   void *cbpriv, aio_callback_t d_cb, void *d_cbpriv)
@@ -140,7 +166,13 @@ BlockDevice *BlockDevice::create(
     CephContext* cct, const string& path, aio_callback_t cb,
     void *cbpriv, aio_callback_t d_cb, void *d_cbpriv)
 {
-  block_device_t device_type = detect_device_type(path);
+  const string blk_dev_name = cct->_conf.get_val<string>("bdev_type");
+  block_device_t device_type = block_device_t::unknown;
+  if (blk_dev_name.empty()) {
+    device_type = detect_device_type(path);
+  } else {
+    device_type = device_type_from_name(blk_dev_name);
+  }
   return create_with_type(device_type, cct, path, cb, cbpriv, d_cb, d_cbpriv);
 }
 
index a24411d0329586db376e936e00354363da645bc4..3123c8aece8e4c8a405dac51ba9b62ca59c2d6e6 100644 (file)
@@ -152,6 +152,7 @@ private:
 #endif
   };
   static block_device_t detect_device_type(const std::string& path);
+  static block_device_t device_type_from_name(const std::string& blk_dev_name);
   static BlockDevice *create_with_type(block_device_t device_type,
     CephContext* cct, const std::string& path, aio_callback_t cb,
     void *cbpriv, aio_callback_t d_cb, void *d_cbpriv);
index 3ff9807aca282bb1684a0f92cdb6398eb2e84da2..4605c6eb6f9662c29cb41f86212f29e2cd48d78b 100644 (file)
@@ -5418,7 +5418,13 @@ std::vector<Option> get_global_options() {
 
     Option("crimson_osd_scheduler_concurrency", Option::TYPE_UINT, Option::LEVEL_ADVANCED)
     .set_default(0)
-    .set_description("The maximum number concurrent IO operations, 0 for unlimited")
+    .set_description("The maximum number concurrent IO operations, 0 for unlimited"),
+
+    // ----------------------------
+    // blk specific options
+    Option("bdev_type", Option::TYPE_STR, Option::LEVEL_ADVANCED)
+    .set_description("Explicitly set the device type to select the driver if it's needed")
+    .set_enum_allowed({"aio", "spdk", "pmem", "hm_smr"})
 
   });
 }