From f04a6cea549ef06fabe9289024246ca2a1a99251 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sat, 16 Oct 2021 07:48:55 +0800 Subject: [PATCH] common/bl: define iov_vec_t using a dedicated struct more readable this way Signed-off-by: Kefu Chai --- src/common/buffer.cc | 18 +++++++++--------- .../os/seastore/segment_manager/block.cc | 6 +++--- src/include/buffer.h | 10 ++++++---- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/common/buffer.cc b/src/common/buffer.cc index fe9b1e09f373a..6e6bf41b11871 100644 --- a/src/common/buffer.cc +++ b/src/common/buffer.cc @@ -2037,23 +2037,23 @@ buffer::list::iov_vec_t buffer::list::prepare_iovs() size_t index = 0; uint64_t off = 0; iovs.resize(_num / IOV_MAX + 1); - iovs[iovs_i].second.resize( + iovs[iovs_i].iov.resize( std::min(_num - IOV_MAX * iovs_i, (size_t)IOV_MAX)); - iovs[iovs_i].first.first = off; - iovs[iovs_i].first.second = 0; + iovs[iovs_i].offset = off; + iovs[iovs_i].length = 0; for (auto& bp : _buffers) { if (index == IOV_MAX) { iovs_i++; index = 0; - iovs[iovs_i].first.first = off; - iovs[iovs_i].first.second = 0; - iovs[iovs_i].second.resize( + iovs[iovs_i].offset = off; + iovs[iovs_i].length = 0; + iovs[iovs_i].iov.resize( std::min(_num - IOV_MAX * iovs_i, (size_t)IOV_MAX)); } - iovs[iovs_i].second[index].iov_base = (void*)bp.c_str(); - iovs[iovs_i].second[index++].iov_len = bp.length(); + iovs[iovs_i].iov[index].iov_base = (void*)bp.c_str(); + iovs[iovs_i].iov[index++].iov_len = bp.length(); off += bp.length(); - iovs[iovs_i].first.second += bp.length(); + iovs[iovs_i].length += bp.length(); } return iovs; } diff --git a/src/crimson/os/seastore/segment_manager/block.cc b/src/crimson/os/seastore/segment_manager/block.cc index 0e71ee0ed1e86..f623cee7cbf4c 100644 --- a/src/crimson/os/seastore/segment_manager/block.cc +++ b/src/crimson/os/seastore/segment_manager/block.cc @@ -70,9 +70,9 @@ static write_ertr::future<> do_writev( return write_ertr::parallel_for_each( iovs, [&device, offset](auto& p) mutable { - auto off = offset + p.first.first; - auto len = p.first.second; - auto& iov = p.second; + auto off = offset + p.offset; + auto len = p.length; + auto& iov = p.iov; logger().debug("do_writev: dma_write to {}, length {}", off, len); return device.dma_write(off, std::move(iov)) .handle_exception([](auto e) -> write_ertr::future { diff --git a/src/include/buffer.h b/src/include/buffer.h index de9ef75b3b2bc..b0b8c440dec07 100644 --- a/src/include/buffer.h +++ b/src/include/buffer.h @@ -1197,10 +1197,12 @@ struct error_code; } } - // vector, iov> - using iov_vec_t = - std::vector, std::vector>>; - + struct iovec_t { + uint64_t offset; + uint64_t length; + std::vector iov; + }; + using iov_vec_t = std::vector; iov_vec_t prepare_iovs(); uint32_t crc32c(uint32_t crc) const; -- 2.39.5