From 8e5a3f229df41c9b3bac86ea3428f6c89111c079 Mon Sep 17 00:00:00 2001 From: myoungwon oh Date: Mon, 13 Feb 2023 10:41:49 +0900 Subject: [PATCH] crimson/os/seastore/rbm: generalize shared logic and set cbjournal_size in mkfs() Signed-off-by: Myoungwon Oh --- src/common/options/crimson.yaml.in | 5 +++++ .../seastore/journal/circular_bounded_journal.h | 1 - .../random_block_manager/nvme_block_device.cc | 5 +++-- .../random_block_manager/nvme_block_device.h | 6 ++++++ .../seastore/random_block_manager/rbm_device.h | 16 +++++++++++----- src/test/crimson/seastore/test_cbjournal.cc | 6 +----- .../seastore/transaction_manager_test_state.h | 4 +--- 7 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/common/options/crimson.yaml.in b/src/common/options/crimson.yaml.in index a92084e39d94d..f6f771f385ea2 100644 --- a/src/common/options/crimson.yaml.in +++ b/src/common/options/crimson.yaml.in @@ -97,3 +97,8 @@ options: level: dev desc: The main device type seastore uses (SSD or RANDOM_BLOCK_SSD) default: SSD +- name: seastore_cbjournal_size + type: size + level: dev + desc: Total size to use for CircularBoundedJournal if created, it is valid only if seastore_main_device_type is RANDOM_BLOCK + default: 5_G diff --git a/src/crimson/os/seastore/journal/circular_bounded_journal.h b/src/crimson/os/seastore/journal/circular_bounded_journal.h index e6e20cca14710..b7117df504369 100644 --- a/src/crimson/os/seastore/journal/circular_bounded_journal.h +++ b/src/crimson/os/seastore/journal/circular_bounded_journal.h @@ -51,7 +51,6 @@ using RBMDevice = random_block_device::RBMDevice; * */ -constexpr uint64_t DEFAULT_TEST_CBJOURNAL_SIZE = 1 << 26; constexpr uint64_t DEFAULT_BLOCK_SIZE = 4096; class CircularBoundedJournal : public Journal { diff --git a/src/crimson/os/seastore/random_block_manager/nvme_block_device.cc b/src/crimson/os/seastore/random_block_manager/nvme_block_device.cc index adfc5e4c6f4a3..48896ccdf5e32 100644 --- a/src/crimson/os/seastore/random_block_manager/nvme_block_device.cc +++ b/src/crimson/os/seastore/random_block_manager/nvme_block_device.cc @@ -24,7 +24,7 @@ namespace crimson::os::seastore::random_block_device { #include "crimson/os/seastore/logging.h" SET_SUBSYS(seastore_device); -RBMDevice::mkfs_ret RBMDevice::mkfs(device_config_t config) { +RBMDevice::mkfs_ret RBMDevice::do_mkfs(device_config_t config) { LOG_PREFIX(RBMDevice::mkfs); return stat_device( ).handle_error( @@ -34,9 +34,10 @@ RBMDevice::mkfs_ret RBMDevice::mkfs(device_config_t config) { ).safe_then([this, FNAME, config=std::move(config)](auto st) { super.block_size = st.block_size; super.size = st.size; - super.feature |= RBM_BITMAP_BLOCK_CRC; super.config = std::move(config); + assert(super.journal_size); + assert(super.size >= super.journal_size); DEBUG("super {} ", super); // write super block return write_rbm_header( diff --git a/src/crimson/os/seastore/random_block_manager/nvme_block_device.h b/src/crimson/os/seastore/random_block_manager/nvme_block_device.h index fb0b30a46694f..689893105d357 100644 --- a/src/crimson/os/seastore/random_block_manager/nvme_block_device.h +++ b/src/crimson/os/seastore/random_block_manager/nvme_block_device.h @@ -211,6 +211,12 @@ public: return mount_ertr::now(); } + mkfs_ret mkfs(device_config_t config) final { + using crimson::common::get_conf; + super.journal_size = get_conf("seastore_cbjournal_size"); + return do_mkfs(config); + } + write_ertr::future<> writev( uint64_t offset, ceph::bufferlist bl, diff --git a/src/crimson/os/seastore/random_block_manager/rbm_device.h b/src/crimson/os/seastore/random_block_manager/rbm_device.h index 91b877e23ae38..e7efac0600ea5 100644 --- a/src/crimson/os/seastore/random_block_manager/rbm_device.h +++ b/src/crimson/os/seastore/random_block_manager/rbm_device.h @@ -150,7 +150,7 @@ public: bool is_data_protection_enabled() const { return false; } - mkfs_ret mkfs(device_config_t) final; + mkfs_ret do_mkfs(device_config_t); write_ertr::future<> write_rbm_header(); @@ -172,9 +172,6 @@ public: void set_device_id(device_id_t id) { super.config.spec.id = id; } - void set_journal_size(uint64_t size) { - super.journal_size = size; - } void set_block_size(size_t size) { super.block_size = size; @@ -182,6 +179,8 @@ public: }; using RBMDeviceRef = std::unique_ptr; +constexpr uint64_t DEFAULT_TEST_CBJOURNAL_SIZE = 1 << 26; + class EphemeralRBMDevice : public RBMDevice { public: uint64_t size = 0; @@ -213,6 +212,11 @@ public: ); } + mkfs_ret mkfs(device_config_t config) final { + super.journal_size = DEFAULT_TEST_CBJOURNAL_SIZE; + return do_mkfs(config); + } + open_ertr::future<> open( const std::string &in_path, seastar::open_flags mode) override; @@ -246,6 +250,8 @@ public: char *buf; }; using EphemeralRBMDeviceRef = std::unique_ptr; -EphemeralRBMDeviceRef create_test_ephemeral(uint64_t journal_size, uint64_t data_size); +EphemeralRBMDeviceRef create_test_ephemeral( + uint64_t journal_size = DEFAULT_TEST_CBJOURNAL_SIZE, + uint64_t data_size = DEFAULT_TEST_CBJOURNAL_SIZE); } diff --git a/src/test/crimson/seastore/test_cbjournal.cc b/src/test/crimson/seastore/test_cbjournal.cc index 23c979ab3138f..f5bff5376f03a 100644 --- a/src/test/crimson/seastore/test_cbjournal.cc +++ b/src/test/crimson/seastore/test_cbjournal.cc @@ -26,9 +26,6 @@ namespace { } } -constexpr uint64_t CBTEST_DEFAULT_TEST_SIZE = 1 << 20; - - std::optional decode_record( bufferlist& bl) { @@ -132,7 +129,7 @@ struct cbjournal_test_t : public seastar_test_suite_t, JournalTrimmer cbjournal_test_t() { device = random_block_device::create_test_ephemeral( - CBTEST_DEFAULT_TEST_SIZE, 0); + random_block_device::DEFAULT_TEST_CBJOURNAL_SIZE, 0); cbj.reset(new CircularBoundedJournal(*this, device.get(), std::string())); block_size = device->get_block_size(); cbj->set_write_pipeline(&pipeline); @@ -252,7 +249,6 @@ struct cbjournal_test_t : public seastar_test_suite_t, JournalTrimmer return device->mount( ).safe_then([this]() { device_config_t config = get_rbm_ephemeral_device_config(0, 1); - device->set_journal_size(CBTEST_DEFAULT_TEST_SIZE); return device->mkfs(config ).safe_then([this]() { return cbj->open_for_mkfs( diff --git a/src/test/crimson/seastore/transaction_manager_test_state.h b/src/test/crimson/seastore/transaction_manager_test_state.h index 8280e4b756076..d53911b8ebf47 100644 --- a/src/test/crimson/seastore/transaction_manager_test_state.h +++ b/src/test/crimson/seastore/transaction_manager_test_state.h @@ -125,12 +125,10 @@ public: } seastar::future<> setup() final { - rb_device = random_block_device::create_test_ephemeral( - journal::DEFAULT_TEST_CBJOURNAL_SIZE, journal::DEFAULT_TEST_CBJOURNAL_SIZE); + rb_device = random_block_device::create_test_ephemeral(); return rb_device->mount().handle_error(crimson::ct_error::assert_all{} ).then([this]() { device_config_t config = get_rbm_ephemeral_device_config(0, 1); - rb_device->set_journal_size(journal::DEFAULT_TEST_CBJOURNAL_SIZE); return rb_device->mkfs(config).handle_error(crimson::ct_error::assert_all{}); }); } -- 2.39.5