From 2e4ab7fdba997557fa7e93d3fbfb44862ec9a859 Mon Sep 17 00:00:00 2001 From: myoungwon oh Date: Mon, 13 Feb 2023 10:17:58 +0900 Subject: [PATCH] crimson/os/seastore: create random_block_device using make_device at startup time Signed-off-by: Myoungwon Oh --- src/common/options/crimson.yaml.in | 5 +++++ src/crimson/os/seastore/CMakeLists.txt | 1 + src/crimson/os/seastore/device.cc | 13 +++++++++--- .../os/seastore/random_block_manager.cc | 21 +++++++++++++++++++ .../os/seastore/random_block_manager.h | 8 +++++++ src/crimson/os/seastore/seastore.cc | 20 +++++++++++++++--- 6 files changed, 62 insertions(+), 6 deletions(-) create mode 100644 src/crimson/os/seastore/random_block_manager.cc diff --git a/src/common/options/crimson.yaml.in b/src/common/options/crimson.yaml.in index 1f3cfd1bce1f9..a92084e39d94d 100644 --- a/src/common/options/crimson.yaml.in +++ b/src/common/options/crimson.yaml.in @@ -92,3 +92,8 @@ options: level: advanced desc: maximum concurrent transactions that seastore allows default: 8 +- name: seastore_main_device_type + type: str + level: dev + desc: The main device type seastore uses (SSD or RANDOM_BLOCK_SSD) + default: SSD diff --git a/src/crimson/os/seastore/CMakeLists.txt b/src/crimson/os/seastore/CMakeLists.txt index 464e44d970c8a..ad43b4c4e196d 100644 --- a/src/crimson/os/seastore/CMakeLists.txt +++ b/src/crimson/os/seastore/CMakeLists.txt @@ -36,6 +36,7 @@ set(crimson_seastore_srcs extent_placement_manager.cc object_data_handler.cc seastore.cc + random_block_manager.cc random_block_manager/block_rb_manager.cc random_block_manager/nvme_block_device.cc random_block_manager/avlallocator.cc diff --git a/src/crimson/os/seastore/device.cc b/src/crimson/os/seastore/device.cc index e28673dd06c69..fcc3a59aa29d4 100644 --- a/src/crimson/os/seastore/device.cc +++ b/src/crimson/os/seastore/device.cc @@ -4,6 +4,8 @@ #include "device.h" #include "segment_manager.h" +#include "random_block_manager.h" +#include "random_block_manager/rbm_device.h" namespace crimson::os::seastore { @@ -33,9 +35,14 @@ std::ostream& operator<<(std::ostream& out, const device_config_t& conf) seastar::future Device::make_device(const std::string& device, device_type_t dtype) { - // TODO: support other backend types - assert(get_default_backend_of_device(dtype) == backend_type_t::SEGMENTED); - return SegmentManager::get_segment_manager(device + if (get_default_backend_of_device(dtype) == backend_type_t::SEGMENTED) { + return SegmentManager::get_segment_manager(device + ).then([](DeviceRef ret) { + return ret; + }); + } + assert(get_default_backend_of_device(dtype) == backend_type_t::RANDOM_BLOCK); + return get_rb_device(device ).then([](DeviceRef ret) { return ret; }); diff --git a/src/crimson/os/seastore/random_block_manager.cc b/src/crimson/os/seastore/random_block_manager.cc new file mode 100644 index 0000000000000..749edc97f7239 --- /dev/null +++ b/src/crimson/os/seastore/random_block_manager.cc @@ -0,0 +1,21 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#include "crimson/os/seastore/logging.h" +#include "crimson/os/seastore/random_block_manager.h" +#include "crimson/os/seastore/random_block_manager/nvme_block_device.h" +#include "crimson/os/seastore/random_block_manager/rbm_device.h" + +namespace crimson::os::seastore { + +seastar::future +get_rb_device( + const std::string &device) +{ + return seastar::make_ready_future( + std::make_unique< + random_block_device::nvme::NVMeBlockDevice + >(device + "/block")); +} + +} diff --git a/src/crimson/os/seastore/random_block_manager.h b/src/crimson/os/seastore/random_block_manager.h index 88c32f658832b..f94ee6e235c19 100644 --- a/src/crimson/os/seastore/random_block_manager.h +++ b/src/crimson/os/seastore/random_block_manager.h @@ -117,6 +117,14 @@ inline rbm_abs_addr convert_paddr_to_abs_addr(const paddr_t& paddr) { inline paddr_t convert_abs_addr_to_paddr(rbm_abs_addr addr, device_id_t d_id) { return paddr_t::make_blk_paddr(d_id, addr); } + +namespace random_block_device { + class RBMDevice; +} + +seastar::future> + get_rb_device(const std::string &device); + std::ostream &operator<<(std::ostream &out, const rbm_metadata_header_t &header); } diff --git a/src/crimson/os/seastore/seastore.cc b/src/crimson/os/seastore/seastore.cc index 04522f1e7ad77..218c0075fdeb3 100644 --- a/src/crimson/os/seastore/seastore.cc +++ b/src/crimson/os/seastore/seastore.cc @@ -404,13 +404,21 @@ SeaStore::mkfs_ertr::future<> SeaStore::mkfs(uuid_d new_osd_fsid) }); } return fut.then([this, &sds, new_osd_fsid] { + device_id_t id = 0; + device_type_t d_type = device->get_device_type(); + assert(d_type == device_type_t::SSD || + d_type == device_type_t::RANDOM_BLOCK_SSD); + if (d_type == device_type_t::RANDOM_BLOCK_SSD) { + id = static_cast(DEVICE_ID_RANDOM_BLOCK_MIN); + } + return device->mkfs( device_config_t{ true, device_spec_t{ (magic_t)std::rand(), - device_type_t::SSD, - 0}, + d_type, + id}, seastore_meta_t{new_osd_fsid}, sds} ); @@ -1898,8 +1906,14 @@ seastar::future> make_seastore( const std::string &device, const ConfigValues &config) { + using crimson::common::get_conf; + std::string type = get_conf("seastore_main_device_type"); + device_type_t d_type = string_to_device_type(type); + assert(d_type == device_type_t::SSD || + d_type == device_type_t::RANDOM_BLOCK_SSD); + return Device::make_device( - device, device_type_t::SSD + device, d_type ).then([&device](DeviceRef device_obj) { #ifndef NDEBUG bool is_test = true; -- 2.39.5