From 36e11a360e47d70f4e7efc4779c9eb26c3706aac Mon Sep 17 00:00:00 2001 From: Zhang Song Date: Mon, 19 Sep 2022 15:43:53 +0800 Subject: [PATCH] crimson/os/seastore: introduce backend_type_t Signed-off-by: Zhang Song --- src/crimson/os/seastore/seastore_types.cc | 41 ++++++++++++++++------- src/crimson/os/seastore/seastore_types.h | 31 +++++++++++++---- 2 files changed, 53 insertions(+), 19 deletions(-) diff --git a/src/crimson/os/seastore/seastore_types.cc b/src/crimson/os/seastore/seastore_types.cc index 18d7be8ade1..7464eed7895 100644 --- a/src/crimson/os/seastore/seastore_types.cc +++ b/src/crimson/os/seastore/seastore_types.cc @@ -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(" diff --git a/src/crimson/os/seastore/seastore_types.h b/src/crimson/os/seastore/seastore_types.h index 51ed6621663..72b75f19a56 100644 --- a/src/crimson/os/seastore/seastore_types.h +++ b/src/crimson/os/seastore/seastore_types.h @@ -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. -- 2.39.5