From: myoungwon oh Date: Mon, 13 Feb 2023 01:31:01 +0000 (+0900) Subject: crimson/os/seastore/rbm: fix stat_deivce() to return correct device size X-Git-Tag: v18.1.0~271^2~12 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=1bea8348deaf669744b55f1150c0278858963fa7;p=ceph.git crimson/os/seastore/rbm: fix stat_deivce() to return correct device size 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 8af9e7b006094..d74cd20041263 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 @@ -134,7 +134,6 @@ open_ertr::future<> NVMeBlockDevice::open( seastar::open_flags mode) { return seastar::do_with(in_path, [this, mode](auto& in_path) { return seastar::file_stat(in_path).then([this, mode, in_path](auto stat) { - super.size = stat.size; super.block_size = stat.block_size; return seastar::open_file_dma(in_path, mode).then([=, this](auto file) { device = file; 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 118d6fe14cbb4..fb0b30a46694f 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 @@ -218,11 +218,24 @@ public: stat_device_ret stat_device() final { return seastar::file_stat(device_path, seastar::follow_symlink::yes - ).then([](auto stat) { - return stat_device_ret( - read_ertr::ready_future_marker{}, - stat - ); + ).handle_exception([](auto e) -> stat_device_ret { + return crimson::ct_error::input_output_error::make(); + }).then([this](auto stat) { + 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 { + stat.size = size; + return file.close( + ).then([stat] { + return stat_device_ret( + read_ertr::ready_future_marker{}, + stat + ); + }); + }); + }); }); }