summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSen Jiang <senj@google.com>2018-04-23 13:56:27 -0700
committerandroid-build-merger <android-build-merger@google.com>2018-04-23 13:56:27 -0700
commit494bc872ce0743a167dba9d304ce29a17e818fb6 (patch)
treedad0a3a6fc26c4ecbb51d4f54dc98031dceb3a12
parent4e3618b69725c73551f70b7ed318c46cb650a115 (diff)
parent84975ec7313f3e1f8855ded361737f3cb66a31c8 (diff)
Produce ZERO operations directly for zero blocks. am: 2560c5430a am: c0da40b2df
am: 84975ec731 Change-Id: I72161513928205b7b09bcc247ee537e473a27a35
-rw-r--r--payload_generator/delta_diff_utils.cc42
1 files changed, 28 insertions, 14 deletions
diff --git a/payload_generator/delta_diff_utils.cc b/payload_generator/delta_diff_utils.cc
index c0962bf9..4ee1024f 100644
--- a/payload_generator/delta_diff_utils.cc
+++ b/payload_generator/delta_diff_utils.cc
@@ -493,30 +493,44 @@ bool DeltaMovedAndZeroBlocks(vector<AnnotatedOperation>* aops,
old_blocks_map_it->second.pop_back();
}
+ if (chunk_blocks == -1)
+ chunk_blocks = new_num_blocks;
+
// Produce operations for the zero blocks split per output extent.
- // TODO(deymo): Produce ZERO operations instead of calling DeltaReadFile().
size_t num_ops = aops->size();
new_visited_blocks->AddExtents(new_zeros);
for (const Extent& extent : new_zeros) {
- TEST_AND_RETURN_FALSE(DeltaReadFile(aops,
- "",
- new_part,
- vector<Extent>(), // old_extents
- vector<Extent>{extent}, // new_extents
- {}, // old_deflates
- {}, // new_deflates
- "<zeros>",
- chunk_blocks,
- version,
- blob_file));
+ if (version.OperationAllowed(InstallOperation::ZERO)) {
+ for (uint64_t offset = 0; offset < extent.num_blocks();
+ offset += chunk_blocks) {
+ uint64_t num_blocks =
+ std::min(static_cast<uint64_t>(extent.num_blocks()) - offset,
+ static_cast<uint64_t>(chunk_blocks));
+ InstallOperation operation;
+ operation.set_type(InstallOperation::ZERO);
+ *(operation.add_dst_extents()) =
+ ExtentForRange(extent.start_block() + offset, num_blocks);
+ aops->push_back({.name = "<zeros>", .op = operation});
+ }
+ } else {
+ TEST_AND_RETURN_FALSE(DeltaReadFile(aops,
+ "",
+ new_part,
+ {}, // old_extents
+ {extent}, // new_extents
+ {}, // old_deflates
+ {}, // new_deflates
+ "<zeros>",
+ chunk_blocks,
+ version,
+ blob_file));
+ }
}
LOG(INFO) << "Produced " << (aops->size() - num_ops) << " operations for "
<< utils::BlocksInExtents(new_zeros) << " zeroed blocks";
// Produce MOVE/SOURCE_COPY operations for the moved blocks.
num_ops = aops->size();
- if (chunk_blocks == -1)
- chunk_blocks = new_num_blocks;
uint64_t used_blocks = 0;
old_visited_blocks->AddExtents(old_identical_blocks);
new_visited_blocks->AddExtents(new_identical_blocks);