]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore: introduce backend_type_t
authorZhang Song <zhangsong325@gmail.com>
Mon, 19 Sep 2022 07:43:53 +0000 (15:43 +0800)
committerZhang Song <zhangsong325@gmail.com>
Thu, 22 Sep 2022 05:45:52 +0000 (13:45 +0800)
Signed-off-by: Zhang Song <zhangsong325@gmail.com>
src/crimson/os/seastore/seastore_types.cc
src/crimson/os/seastore/seastore_types.h

index 18d7be8ade1c5c90b79a8ce9ab5d424dc3f64345..7464eed7895ef6390fe5df58cfabd58ad1e86fed 100644 (file)
@@ -771,14 +771,17 @@ bool can_delay_allocation(device_type_t type) {
 }
 
 device_type_t string_to_device_type(std::string type) {
-  if (type == "segmented") {
-    return device_type_t::SEGMENTED;
+  if (type == "HDD") {
+    return device_type_t::HDD;
   }
-  if (type == "random_block") {
-    return device_type_t::RANDOM_BLOCK;
+  if (type == "SSD") {
+    return device_type_t::SSD;
   }
-  if (type == "pmem") {
-    return device_type_t::PMEM;
+  if (type == "ZNS") {
+    return device_type_t::ZNS;
+  }
+  if (type == "RANDOM_BLOCK_SSD") {
+    return device_type_t::RANDOM_BLOCK_SSD;
   }
   return device_type_t::NONE;
 }
@@ -788,17 +791,31 @@ std::ostream& operator<<(std::ostream& out, device_type_t t)
   switch (t) {
   case device_type_t::NONE:
     return out << "NONE";
-  case device_type_t::SEGMENTED:
-    return out << "SEGMENTED";
-  case device_type_t::RANDOM_BLOCK:
-    return out << "RANDOM_BLOCK";
-  case device_type_t::PMEM:
-    return out << "PMEM";
+  case device_type_t::HDD:
+    return out << "HDD";
+  case device_type_t::SSD:
+    return out << "SSD";
+  case device_type_t::ZNS:
+    return out << "ZNS";
+  case device_type_t::SEGMENTED_EPHEMERAL:
+    return out << "SEGMENTED_EPHEMERAL";
+  case device_type_t::RANDOM_BLOCK_SSD:
+    return out << "RANDOM_BLOCK_SSD";
+  case device_type_t::RANDOM_BLOCK_EPHEMERAL:
+    return out << "RANDOM_BLOCK_EPHEMERAL";
   default:
     return out << "INVALID_DEVICE_TYPE!";
   }
 }
 
+std::ostream& operator<<(std::ostream& out, backend_type_t btype) {
+  if (btype == backend_type_t::SEGMENTED) {
+    return out << "SEGMENTED";
+  } else {
+    return out << "RANDOM_BLOCK";
+  }
+}
+
 std::ostream& operator<<(std::ostream& out, const write_result_t& w)
 {
   return out << "write_result_t("
index 51ed662166336a98e1f671e696e789bcb47ab881..72b75f19a568ddf9ecff6a472f12866774203e4d 100644 (file)
@@ -857,11 +857,14 @@ constexpr auto PLACEMENT_HINT_NULL = placement_hint_t::NUM_HINTS;
 
 std::ostream& operator<<(std::ostream& out, placement_hint_t h);
 
-enum alignas(4) device_type_t : uint_fast8_t {
+enum class alignas(4) device_type_t : uint_fast8_t {
   NONE = 0,
-  SEGMENTED, // i.e. Hard_Disk, SATA_SSD, NAND_NVME
-  RANDOM_BLOCK, // i.e. RANDOM_BD
-  PMEM, // i.e. NVDIMM, PMEM
+  HDD,
+  SSD,
+  ZNS,
+  SEGMENTED_EPHEMERAL,
+  RANDOM_BLOCK_SSD,
+  RANDOM_BLOCK_EPHEMERAL,
   NUM_TYPES
 };
 
@@ -870,11 +873,25 @@ std::ostream& operator<<(std::ostream& out, device_type_t t);
 bool can_delay_allocation(device_type_t type);
 device_type_t string_to_device_type(std::string type);
 
-enum class journal_type_t {
-  SEGMENTED,
-  CIRCULAR
+enum class backend_type_t {
+  SEGMENTED,    // SegmentManager: SSD, ZNS, HDD
+  RANDOM_BLOCK  // RBMDevice:      RANDOM_BLOCK_SSD
 };
 
+std::ostream& operator<<(std::ostream& out, backend_type_t);
+using journal_type_t = backend_type_t;
+
+constexpr backend_type_t get_default_backend_of_device(device_type_t dtype) {
+  assert(dtype != device_type_t::NONE &&
+        dtype != device_type_t::NUM_TYPES);
+  if (dtype >= device_type_t::HDD &&
+      dtype <= device_type_t::SEGMENTED_EPHEMERAL) {
+    return backend_type_t::SEGMENTED;
+  } else {
+    return backend_type_t::RANDOM_BLOCK;
+  }
+}
+
 /**
  * Monotonically increasing identifier for the location of a
  * journal_record.