From: myoungwon oh Date: Fri, 24 Feb 2023 09:41:11 +0000 (+0900) Subject: crimson/os/seastore/rbm: only set block_size at mkfs time X-Git-Tag: v18.1.0~271^2~2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=4dfe1a7d16263185451931f42c5ff92237631345;p=ceph-ci.git crimson/os/seastore/rbm: only set block_size at mkfs time Signed-off-by: Myoungwon Oh --- 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 19d244ddf9b..754377ba47e 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 @@ -32,18 +32,15 @@ open_ertr::future<> NVMeBlockDevice::open( logger().debug("open"); // Get SSD's features from identify_controller and namespace command. // Do identify_controller first, and then identify_namespace. - return identify_controller().safe_then([this, in_path, mode]( + return identify_controller(device).safe_then([this, in_path, mode]( auto id_controller_data) { support_multistream = id_controller_data.oacs.support_directives; if (support_multistream) { stream_id_count = WRITE_LIFE_MAX; } awupf = id_controller_data.awupf + 1; - return identify_namespace().safe_then([this, in_path, mode] ( + return identify_namespace(device).safe_then([this, in_path, mode] ( auto id_namespace_data) { - // LBA format provides LBA size which is power of 2. LBA is the - // minimum size of read and write. - super.block_size = (1 << id_namespace_data.lbaf0.lbads); atomic_write_unit = awupf * super.block_size; data_protection_type = id_namespace_data.dps.protection_type; data_protection_enabled = (data_protection_type > 0); @@ -220,17 +217,17 @@ Device::close_ertr::future<> NVMeBlockDevice::close() { } nvme_command_ertr::future -NVMeBlockDevice::identify_controller() { +NVMeBlockDevice::identify_controller(seastar::file f) { return seastar::do_with( nvme_admin_command_t(), nvme_identify_controller_data_t(), - [this](auto &admin_command, auto &data) { + [this, f](auto &admin_command, auto &data) { admin_command.common.opcode = nvme_admin_command_t::OPCODE_IDENTIFY; admin_command.common.addr = (uint64_t)&data; admin_command.common.data_len = sizeof(data); admin_command.identify.cns = nvme_identify_command_t::CNS_CONTROLLER; - return pass_admin(admin_command).safe_then([&data](auto status) { + return pass_admin(admin_command, f).safe_then([&data](auto status) { return seastar::make_ready_future( std::move(data)); }); @@ -242,19 +239,19 @@ discard_ertr::future<> NVMeBlockDevice::discard(uint64_t offset, uint64_t len) { } nvme_command_ertr::future -NVMeBlockDevice::identify_namespace() { - return get_nsid().safe_then([this](auto nsid) { +NVMeBlockDevice::identify_namespace(seastar::file f) { + return get_nsid(f).safe_then([this, f](auto nsid) { return seastar::do_with( nvme_admin_command_t(), nvme_identify_namespace_data_t(), - [this, nsid](auto &admin_command, auto &data) { + [this, nsid, f](auto &admin_command, auto &data) { admin_command.common.opcode = nvme_admin_command_t::OPCODE_IDENTIFY; admin_command.common.addr = (uint64_t)&data; admin_command.common.data_len = sizeof(data); admin_command.common.nsid = nsid; admin_command.identify.cns = nvme_identify_command_t::CNS_NAMESPACE; - return pass_admin(admin_command).safe_then([&data](auto status){ + return pass_admin(admin_command, f).safe_then([&data](auto status){ return seastar::make_ready_future( std::move(data)); }); @@ -262,13 +259,17 @@ NVMeBlockDevice::identify_namespace() { }); } -nvme_command_ertr::future NVMeBlockDevice::get_nsid() { - return device.ioctl(NVME_IOCTL_ID, nullptr); +nvme_command_ertr::future NVMeBlockDevice::get_nsid(seastar::file f) { + return f.ioctl(NVME_IOCTL_ID, nullptr).handle_exception( + [](auto e)->nvme_command_ertr::future { + logger().error("pass_admin: ioctl failed"); + return crimson::ct_error::input_output_error::make(); + }); } nvme_command_ertr::future NVMeBlockDevice::pass_admin( - nvme_admin_command_t& admin_cmd) { - return device.ioctl(NVME_IOCTL_ADMIN_CMD, &admin_cmd).handle_exception( + nvme_admin_command_t& admin_cmd, seastar::file f) { + return f.ioctl(NVME_IOCTL_ADMIN_CMD, &admin_cmd).handle_exception( [](auto e)->nvme_command_ertr::future { logger().error("pass_admin: ioctl failed"); return crimson::ct_error::input_output_error::make(); 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 0fb0245a710..4dc4de533aa 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 @@ -228,15 +228,35 @@ public: return seastar::open_file_dma( device_path, seastar::open_flags::rw | seastar::open_flags::dsync - ).then([stat](auto file) mutable { - return file.size().then([stat, file](auto size) mutable { + ).then([this, stat](auto file) mutable { + return file.size().then([this, stat, file](auto size) mutable { stat.size = size; - return file.close( - ).then([stat] { + return identify_namespace(file + ).safe_then([stat] (auto id_namespace_data) mutable { + // LBA format provides LBA size which is power of 2. LBA is the + // minimum size of read and write. + stat.block_size = (1 << id_namespace_data.lbaf0.lbads); + if (stat.block_size < RBM_SUPERBLOCK_SIZE) { + stat.block_size = RBM_SUPERBLOCK_SIZE; + } + return stat_device_ret( + read_ertr::ready_future_marker{}, + stat + ); + }).handle_error(crimson::ct_error::input_output_error::handle( + [stat]{ return stat_device_ret( read_ertr::ready_future_marker{}, stat ); + }), crimson::ct_error::pass_further_all{}); + }).safe_then([file](auto st) mutable { + return file.close( + ).then([st] { + return stat_device_ret( + read_ertr::ready_future_marker{}, + st + ); }); }); }); @@ -288,7 +308,7 @@ public: * Caller can construct and execute its own nvme command */ nvme_command_ertr::future pass_admin( - nvme_admin_command_t& admin_cmd); + nvme_admin_command_t& admin_cmd, seastar::file f); nvme_command_ertr::future pass_through_io( nvme_io_command_t& io_cmd); @@ -305,9 +325,11 @@ public: private: // identify_controller/namespace are used to get SSD internal information such // as supported features, NPWG and NPWA - nvme_command_ertr::future identify_controller(); - nvme_command_ertr::future identify_namespace(); - nvme_command_ertr::future get_nsid(); + nvme_command_ertr::future + identify_controller(seastar::file f); + nvme_command_ertr::future + identify_namespace(seastar::file f); + nvme_command_ertr::future get_nsid(seastar::file f); open_ertr::future<> open_for_io( const std::string& in_path, seastar::open_flags mode);