]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/rbm: fix stat_deivce() to return correct device size
authormyoungwon oh <ohmyoungwon@gmail.com>
Mon, 13 Feb 2023 01:31:01 +0000 (10:31 +0900)
committermyoungwon oh <ohmyoungwon@gmail.com>
Sat, 25 Feb 2023 03:08:29 +0000 (12:08 +0900)
Signed-off-by: Myoungwon Oh <myoungwon.oh@samsung.com>
src/crimson/os/seastore/random_block_manager/nvme_block_device.cc
src/crimson/os/seastore/random_block_manager/nvme_block_device.h

index 8af9e7b0060941ab8a45d07aff0b5323f3cc4918..d74cd20041263aabbf36305ab057351f4b2c3915 100644 (file)
@@ -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;
index 118d6fe14cbb482fecab4f4f4a62a74ffe1ff587..fb0b30a46694fb823fceed7870df868b66dab4d8 100644 (file)
@@ -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
+           );
+         });
+       });
+      });
     });
   }