libsnapshot: Add IsOrderedOp

Ordered Ops are Cow Ops with source block dependencies.
Currently this is only Copy Ops, but will extend to XOR
blocks when they're added.

Bug: 177104308
Test: Builds, does not impace cow_api_test/cow_snapuserd_test
Change-Id: I0a50dfe3316ec3a3b1d035335f094c62296649a5
This commit is contained in:
Daniel Rosenberg 2021-06-25 17:35:28 -07:00
parent f0d9beb162
commit f7001fad6f
3 changed files with 13 additions and 1 deletions

View file

@ -90,5 +90,14 @@ bool IsMetadataOp(const CowOperation& op) {
}
}
bool IsOrderedOp(const CowOperation& op) {
switch (op.type) {
case kCowCopyOp:
return true;
default:
return false;
}
}
} // namespace snapshot
} // namespace android

View file

@ -185,7 +185,10 @@ std::ostream& operator<<(std::ostream& os, CowOperation const& arg);
int64_t GetNextOpOffset(const CowOperation& op, uint32_t cluster_size);
int64_t GetNextDataOffset(const CowOperation& op, uint32_t cluster_size);
// Ops that are internal to the Cow Format and not OTA data
bool IsMetadataOp(const CowOperation& op);
// Ops that have dependencies on old blocks, and must take care in their merge order
bool IsOrderedOp(const CowOperation& op);
} // namespace snapshot
} // namespace android

View file

@ -395,7 +395,7 @@ bool Snapuserd::ReadMetadata() {
// handling of assigning chunk-id's. Furthermore, we make
// sure that replace/zero and copy ops are not batch merged; hence,
// the bump in the chunk_id before break of this loop
if (cow_op->type == kCowCopyOp) {
if (IsOrderedOp(*cow_op)) {
data_chunk_id = GetNextAllocatableChunkId(data_chunk_id);
break;
}