From 97bcfda54932f669440c81a6e6698d53be2eb2e9 Mon Sep 17 00:00:00 2001 From: Yingxin Cheng Date: Thu, 22 Jul 2021 15:28:40 +0800 Subject: [PATCH] crimson/os/seastore/segment_manager: respect len parameter of BlockSegmentManager::read() Signed-off-by: Yingxin Cheng --- src/crimson/os/seastore/segment_manager/block.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/crimson/os/seastore/segment_manager/block.cc b/src/crimson/os/seastore/segment_manager/block.cc index 26a2ed4742b..7a5a1f3b617 100644 --- a/src/crimson/os/seastore/segment_manager/block.cc +++ b/src/crimson/os/seastore/segment_manager/block.cc @@ -84,23 +84,25 @@ static write_ertr::future<> do_writev( static read_ertr::future<> do_read( seastar::file &device, uint64_t offset, + size_t len, bufferptr &bptr) { + assert(len <= bptr.length()); logger().debug( "block: do_read offset {} len {}", offset, - bptr.length()); + len); return device.dma_read( offset, bptr.c_str(), - bptr.length() + len ).handle_exception([](auto e) -> read_ertr::future { logger().error( "do_read: dma_read got error {}", e); return crimson::ct_error::input_output_error::make(); - }).then([length=bptr.length()](auto result) -> read_ertr::future<> { - if (result != length) { + }).then([len](auto result) -> read_ertr::future<> { + if (result != len) { return crimson::ct_error::input_output_error::make(); } return read_ertr::now(); @@ -123,6 +125,7 @@ SegmentStateTracker::read_in( return do_read( device, offset, + bptr.length(), bptr); } @@ -285,6 +288,7 @@ read_superblock(seastar::file &device, seastar::stat_data sd) return do_read( device, 0, + bp.length(), bp ).safe_then([=, &bp] { bufferlist bl; @@ -500,6 +504,7 @@ SegmentManager::read_ertr::future<> BlockSegmentManager::read( return do_read( device, get_offset(addr), + len, out); }