Merge "libsnapshot: chunk iov writes" into main am: 6bee318285
am: 5044d3fd01
Original change: https://android-review.googlesource.com/c/platform/system/core/+/3001513 Change-Id: Ibd60633bc1f89ac3dda6fe87d6738c1ee16fb036 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
a4f8ee1f45
1 changed files with 17 additions and 3 deletions
|
@ -717,13 +717,27 @@ bool CowWriterV3::WriteOperation(std::span<const CowOperationV3> ops,
|
|||
return false;
|
||||
}
|
||||
if (!data.empty()) {
|
||||
const auto ret = pwritev(fd_, data.data(), data.size(), next_data_pos_);
|
||||
if (ret != total_data_size) {
|
||||
int total_written = 0;
|
||||
int i = 0;
|
||||
while (i < data.size()) {
|
||||
int chunk = std::min(static_cast<int>(data.size() - i), IOV_MAX);
|
||||
|
||||
const auto ret = pwritev(fd_, data.data() + i, chunk, next_data_pos_ + total_written);
|
||||
if (ret < 0) {
|
||||
PLOG(ERROR) << "write failed chunk size of: " << chunk
|
||||
<< " at offset: " << next_data_pos_ + total_written << " " << errno;
|
||||
return false;
|
||||
}
|
||||
total_written += ret;
|
||||
i += chunk;
|
||||
}
|
||||
if (total_written != total_data_size) {
|
||||
PLOG(ERROR) << "write failed for data of size: " << data.size()
|
||||
<< " at offset: " << next_data_pos_ << " " << ret;
|
||||
<< " at offset: " << next_data_pos_ << " " << errno;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
header_.op_count += ops.size();
|
||||
next_data_pos_ += total_data_size;
|
||||
|
||||
|
|
Loading…
Reference in a new issue