Add CowMergeOperations as a hint for snapshot write
As proposed in http://go/vabc, we want to reduce the cow size
for VAB. One nature apporach is to skip writing the idential
blocks to snapshot; instead we can read from the souce blocks.
Similiar to the non-A/B update schema, we need to compute a
sequence for snapshot merge to avoid the read after write problem.
If there is a circular dependency, we will omit some blocks in the
result sequence to break the cycles. So libsnapshot will write
the raw data of these blocks to cow.
All extents in the CowMergeOperations are subsets of a particular
OTA SOURCE_COPY InstallOperation. Also, these src & ext extents
will be contiguous to improve the libsnapshot read performance
before merge completes, as well as to simplify the sequence
generation.
Bug: 162274240
Test: unittest pass, genertes an OTA
Change-Id: I12c952593d83a8e34a0a6cff5a2066c9103a0d30
diff --git a/payload_generator/payload_file.cc b/payload_generator/payload_file.cc
index 1388f2d..49dff4e 100644
--- a/payload_generator/payload_file.cc
+++ b/payload_generator/payload_file.cc
@@ -86,10 +86,12 @@
bool PayloadFile::AddPartition(const PartitionConfig& old_conf,
const PartitionConfig& new_conf,
- vector<AnnotatedOperation> aops) {
+ vector<AnnotatedOperation> aops,
+ vector<CowMergeOperation> merge_sequence) {
Partition part;
part.name = new_conf.name;
part.aops = std::move(aops);
+ part.cow_merge_sequence = std::move(merge_sequence);
part.postinstall = new_conf.postinstall;
part.verity = new_conf.verity;
part.version = new_conf.version;
@@ -163,6 +165,10 @@
for (const AnnotatedOperation& aop : part.aops) {
*partition->add_operations() = aop.op;
}
+ for (const auto& merge_op : part.cow_merge_sequence) {
+ *partition->add_merge_operations() = merge_op;
+ }
+
if (part.old_info.has_size() || part.old_info.has_hash())
*(partition->mutable_old_partition_info()) = part.old_info;
if (part.new_info.has_size() || part.new_info.has_hash())