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;
}
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<size_t> {
}
}
- // vector<pair<offset, length>, iov>
- using iov_vec_t =
- std::vector<std::pair<std::pair<uint64_t, uint64_t>, std::vector<iovec>>>;
-
+ struct iovec_t {
+ uint64_t offset;
+ uint64_t length;
+ std::vector<iovec> iov;
+ };
+ using iov_vec_t = std::vector<iovec_t>;
iov_vec_t prepare_iovs();
uint32_t crc32c(uint32_t crc) const;