]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/os/seastore/segment_manager/block: get block device size
authorJianxin Li <jianxin1.li@intel.com>
Mon, 31 Oct 2022 08:03:01 +0000 (08:03 +0000)
committerJianxin Li <jianxin1.li@intel.com>
Wed, 2 Nov 2022 07:08:25 +0000 (07:08 +0000)
Previously the file_stat(::stat) can not get correct size for block devices.
Now call the file.size(using ::lseek) to replace it.

Signed-off-by: Jianxin Li <jianxin1.li@intel.com>
src/crimson/os/seastore/segment_manager/block.cc

index e6888ba813c16aab6f1238cc487118484ba5f3ce..d0c34f36d82ae85eec79eb4a6520f5d152d2b11e 100644 (file)
@@ -310,9 +310,13 @@ open_device_ret open_device(
     return seastar::open_file_dma(
       path,
       seastar::open_flags::rw | seastar::open_flags::dsync
-    ).then([=, &path](auto file) {
-      INFO("path={} successful, size={}", path, stat.size);
-      return std::make_pair(file, stat);
+    ).then([stat, &path, FNAME](auto file) mutable {
+      return file.size().then([stat, file, &path, FNAME](auto size) mutable {
+        stat.size = size;
+        INFO("path={} successful, size={}, block_size={}", 
+        path, stat.size, stat.block_size);
+        return std::make_pair(file, stat);
+      });
     });
   }).handle_exception([FNAME, &path](auto e) -> open_device_ret {
     ERROR("path={} got error -- {}", path, e);