Merge "Update libsnapshot to handle partial update" am: 8e1b80596f
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1326217 Change-Id: I5d6658413141bc151d136293f5e37f8eefb4fecc
This commit is contained in:
commit
dd513953ac
4 changed files with 25 additions and 0 deletions
|
|
@ -2277,6 +2277,10 @@ Return SnapshotManager::CreateUpdateSnapshotsInternal(
|
||||||
auto operations_it = install_operation_map.find(target_partition->name());
|
auto operations_it = install_operation_map.find(target_partition->name());
|
||||||
if (operations_it != install_operation_map.end()) {
|
if (operations_it != install_operation_map.end()) {
|
||||||
cow_creator->operations = operations_it->second;
|
cow_creator->operations = operations_it->second;
|
||||||
|
} else {
|
||||||
|
LOG(INFO) << target_partition->name()
|
||||||
|
<< " isn't included in the payload, skipping the cow creation.";
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
cow_creator->extra_extents.clear();
|
cow_creator->extra_extents.clear();
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,8 @@ SnapshotMetadataUpdater::SnapshotMetadataUpdater(MetadataBuilder* builder, uint3
|
||||||
std::string(it->second) + target_suffix_, &p});
|
std::string(it->second) + target_suffix_, &p});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
partial_update_ = manifest.partial_update();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SnapshotMetadataUpdater::ShrinkPartitions() const {
|
bool SnapshotMetadataUpdater::ShrinkPartitions() const {
|
||||||
|
|
@ -82,6 +84,18 @@ bool SnapshotMetadataUpdater::ShrinkPartitions() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SnapshotMetadataUpdater::DeletePartitions() const {
|
bool SnapshotMetadataUpdater::DeletePartitions() const {
|
||||||
|
// For partial update, not all dynamic partitions are included in the payload.
|
||||||
|
// TODO(xunchang) delete the untouched partitions whose group is in the payload.
|
||||||
|
// e.g. Delete vendor in the following scenario
|
||||||
|
// On device:
|
||||||
|
// Group A: system, vendor
|
||||||
|
// In payload:
|
||||||
|
// Group A: system
|
||||||
|
if (partial_update_) {
|
||||||
|
LOG(INFO) << "Skip deleting partitions for partial update";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::string> partitions_to_delete;
|
std::vector<std::string> partitions_to_delete;
|
||||||
// Don't delete partitions in groups where the group name doesn't have target_suffix,
|
// Don't delete partitions in groups where the group name doesn't have target_suffix,
|
||||||
// e.g. default.
|
// e.g. default.
|
||||||
|
|
@ -139,6 +153,11 @@ bool SnapshotMetadataUpdater::ShrinkGroups() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SnapshotMetadataUpdater::DeleteGroups() const {
|
bool SnapshotMetadataUpdater::DeleteGroups() const {
|
||||||
|
if (partial_update_) {
|
||||||
|
LOG(INFO) << "Skip deleting groups for partial update";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::string> existing_groups = builder_->ListGroups();
|
std::vector<std::string> existing_groups = builder_->ListGroups();
|
||||||
for (const auto& existing_group_name : existing_groups) {
|
for (const auto& existing_group_name : existing_groups) {
|
||||||
// Don't delete groups without target suffix, e.g. default.
|
// Don't delete groups without target suffix, e.g. default.
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@ class SnapshotMetadataUpdater {
|
||||||
const std::string target_suffix_;
|
const std::string target_suffix_;
|
||||||
std::vector<Group> groups_;
|
std::vector<Group> groups_;
|
||||||
std::vector<Partition> partitions_;
|
std::vector<Partition> partitions_;
|
||||||
|
bool partial_update_{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace snapshot
|
} // namespace snapshot
|
||||||
|
|
|
||||||
|
|
@ -77,4 +77,5 @@ message DynamicPartitionMetadata {
|
||||||
message DeltaArchiveManifest {
|
message DeltaArchiveManifest {
|
||||||
repeated PartitionUpdate partitions = 13;
|
repeated PartitionUpdate partitions = 13;
|
||||||
optional DynamicPartitionMetadata dynamic_partition_metadata = 15;
|
optional DynamicPartitionMetadata dynamic_partition_metadata = 15;
|
||||||
|
optional bool partial_update = 16;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue