diff options
-rw-r--r-- | src/crimson/osd/ops_executer.cc | 12 | ||||
-rw-r--r-- | src/crimson/osd/pg_backend.cc | 49 | ||||
-rw-r--r-- | src/crimson/osd/pg_backend.h | 10 |
3 files changed, 29 insertions, 42 deletions
diff --git a/src/crimson/osd/ops_executer.cc b/src/crimson/osd/ops_executer.cc index bf7ea33feb9..6547b1530e2 100644 --- a/src/crimson/osd/ops_executer.cc +++ b/src/crimson/osd/ops_executer.cc @@ -435,17 +435,7 @@ OpsExecuter::execute_op(OSDOp& osd_op) [[fallthrough]]; case CEPH_OSD_OP_READ: return do_read_op([&osd_op] (auto& backend, const auto& os) { - return backend.read(os.oi, - osd_op.op.extent.offset, - osd_op.op.extent.length, - osd_op.op.extent.truncate_size, - osd_op.op.extent.truncate_seq, - osd_op.op.flags).safe_then( - [&osd_op](ceph::bufferlist&& bl) { - osd_op.rval = bl.length(); - osd_op.outdata = std::move(bl); - return osd_op_errorator::now(); - }); + return backend.read(os, osd_op); }); case CEPH_OSD_OP_SPARSE_READ: return do_read_op([&osd_op] (auto& backend, const auto& os) { diff --git a/src/crimson/osd/pg_backend.cc b/src/crimson/osd/pg_backend.cc index 38ac951a3e1..1bd15a52bf3 100644 --- a/src/crimson/osd/pg_backend.cc +++ b/src/crimson/osd/pg_backend.cc @@ -181,39 +181,40 @@ static inline bool _read_verify_data( return true; } -PGBackend::read_errorator::future<ceph::bufferlist> -PGBackend::read(const object_info_t& oi, - const size_t offset, - size_t length, - const size_t truncate_size, - const uint32_t truncate_seq, - const uint32_t flags) +PGBackend::read_errorator::future<> +PGBackend::read(const ObjectState& os, OSDOp& osd_op) { + const auto& oi = os.oi; + const ceph_osd_op& op = osd_op.op; + const uint64_t offset = op.extent.offset; + uint64_t length = op.extent.length; logger().trace("read: {} {}~{}", oi.soid, offset, length); + // are we beyond truncate_size? size_t size = oi.size; - if ((truncate_seq > oi.truncate_seq) && - (truncate_size < offset + length) && - (truncate_size < size)) { - size = truncate_size; + if ((op.extent.truncate_seq > oi.truncate_seq) && + (op.extent.truncate_size < offset + length) && + (op.extent.truncate_size < size)) { + size = op.extent.truncate_size; + } + if (offset >= size) { + // read size was trimmed to zero and it is expected to do nothing, + return read_errorator::now(); } if (!length) { // read the whole object if length is 0 length = size; } - if (offset >= size) { - // read size was trimmed to zero and it is expected to do nothing, - return read_errorator::make_ready_future<bufferlist>(); - } - return _read(oi.soid, offset, length, flags).safe_then( - [&oi](auto&& bl) -> read_errorator::future<ceph::bufferlist> { - if (const bool is_fine = _read_verify_data(oi, bl); is_fine) { - logger().debug("read: data length: {}", bl.length()); - return read_errorator::make_ready_future<bufferlist>(std::move(bl)); - } else { - return crimson::ct_error::object_corrupted::make(); - } - }); + return _read(oi.soid, offset, length, op.flags).safe_then( + [&oi, &osd_op](auto&& bl) -> read_errorator::future<> { + if (!_read_verify_data(oi, bl)) { + return crimson::ct_error::object_corrupted::make(); + } + logger().debug("read: data length: {}", bl.length()); + osd_op.rval = bl.length(); + osd_op.outdata = std::move(bl); + return read_errorator::now(); + }); } PGBackend::read_errorator::future<> diff --git a/src/crimson/osd/pg_backend.h b/src/crimson/osd/pg_backend.h index 8efb012e515..accfd260db8 100644 --- a/src/crimson/osd/pg_backend.h +++ b/src/crimson/osd/pg_backend.h @@ -55,13 +55,9 @@ public: std::map<std::string, ceph::bufferptr, std::less<>>; using read_errorator = ll_read_errorator::extend< crimson::ct_error::object_corrupted>; - read_errorator::future<ceph::bufferlist> read( - const object_info_t& oi, - uint64_t off, - uint64_t len, - size_t truncate_size, - uint32_t truncate_seq, - uint32_t flags); + read_errorator::future<> read( + const ObjectState& os, + OSDOp& osd_op); read_errorator::future<> sparse_read( const ObjectState& os, OSDOp& osd_op); |