summaryrefslogtreecommitdiff
path: root/common/dynamic_partition_control_stub.h
AgeCommit message (Collapse)Author
2021-03-24Make dynamic partition control android return a writable fdKelvin Zhang
We can return a FileDescriptor object, which encapsulates logic needed to write to a COW. This way, filesystem verfication action can use the turend value directly for computing verity and hash the partition. Test: th Change-Id: Iafe9699ef0cc15961641fc94f8ad2820230a56e1
2021-03-16Pass in source slot to ctor of dynamic controlKelvin Zhang
When DynamicPartitionControlAndroid is constructed, it initializes both source and target slot to -1. These values get updated during PreparePartitionsForUpdate call. And we only PreparePartitionsForUpdate() when applying an OTA or applocating space for an OTA(not when verifying OTA metadata). Which means if VerifyPayloadApplicable() is called before any call two other APIs, we could be using an "Uninitialiazed" dynamic partition control. To mitigate this problem, we pass in source_slot at ctor of DynamicPartitionControl, also make IsDynamicPartition() api take in a slot number to avoid reading uninitialized member fields. Bug: 181643302 Test: apply an OTA, abort, restart update_engine, verify a payload Change-Id: I9a8a0fe8a9aca48e91241e15bdec33a1c1228553
2021-02-16Don't list dynamic if a slot doesn't support DAPTianjie
If a slot doesn't support dynamic partitions, it's impossible to list dynamic partitions on that slot. And we should just fall back to the regular A/B in this case. Bug: 180025432 Test: apply a retrofit package Change-Id: I16c457b591e8c1d0cf1077a7be50dd9d8f61b8eb
2021-02-10Add DynamicPartitionControlInterface::UpdateUsesSnapshotCompressionYifan Hong
This function returns whether Virtual A/B compression is enabled for the ongoing update. Test: TH Bug: 178732971 Change-Id: I781802443afd1d8deac046a8da198658220f7ba0
2020-11-17Add IsDynamicPartition API to easily check if a partition is dynamicKelvin Zhang
Test: treehugger Change-Id: I655e4d6114a25c58857679985cd5e08581c0faab
2020-11-16Add OpenCowReader interface method to dynamic partition controlKelvin Zhang
Test: treehugger Change-Id: I393fc36372f9e979da1a6c7e49c7782a7372a5b9
2020-10-30Add [un]mapPartitions APIs to dynamic partition controlKelvin Zhang
During postinstall stage, update_engine needs all target partitions(system_b, vendor_b) to be mounted. We add 2 APIs to dynamic partition control, 1 for mounting all partitions, and UnmapAllPartitions for unmap all partitions. Test: Treehugger Bug: 168554689 Change-Id: I1047851f6cdae7f39f50bd1d50e6d3bfc0d9a7f5
2020-10-23Add CowWriter interface methods to DynamicPartiitonControlKelvin Zhang
Test: treehugger Change-Id: I110c65e75a4594af51e68390e570ac31b50de8b5
2020-09-26Add FeatureFlag for Virtual AB CompressionKelvin Zhang
Test: treehugger Bug: 168554689 Change-Id: I732cd1ef55c5c4362ef88a640c2ca228f472af89
2020-07-09Verify the extents for untouched dynamic partitions during partial updateTianjie
For partial updates, the metadata for untouched dynamic partitions are just copied over to the target slot. So, verifying the extents of these partitions in the target metadata should be sufficient for correctness. This saves the work to read & hash the bytes on these partitions for each resumed update. Bug: 151088567 Test: unit tests pass, apply a partial update Change-Id: I9d40ed2643e145a1546ea17b146fcdcfb91f213f
2020-06-15Implement PartitionUpdateGenerator for partial updatesTianjie
Implement the logic in PartitionUpdateGenerator. Here's the summary, 1. finds the a/b partitions (both static & dynamic) on the device For partitions not included in the payload: 2. calculates the partition hash for filesystem verification 3. generates one SOURCE_COPY operation for each static partition The order of the partitions are sorted. So the update will resume from the correct operation in case it's interruptted. Bug: 157778739 Test: run a partial OTA with boot & system_ext Change-Id: I5683b85e3c6dab813a33d5144aceb996fd8163d4
2020-03-27Allow forward merge on powerwash.Yifan Hong
If package schedules powerwash, snapshots on a Virtual A/B device will be deleted. Tell SnapshotManager to handle this case. Test: apply downgrade package Test: apply package with wipe Test: apply package then manually wipe Bug: 152094219 Change-Id: I8601b661924abcc82956788e2f33cdb70d71f778
2020-03-17ResetStatus deletes snapshots for VAB.Yifan Hong
When ResetStatus() is called, delete snapshots to free up space on VAB devices. On regular A/B, there is no need to cancel the update completely so that the update may be resumed next time. However, on VAB devices, a cancelled update should not occupy previously allocated space. Test: manually call update_engine_client --cancel when an update is in progress, then call update_engine_client --reset_status, then call snapshotctl dump to check that snapshots are deleted. Then, re-apply the update. Test: manually kill update_engine when an update is in progress, then call update_engine_client --reset_status, then call snapshotctl dump to check that snapshots are deleted. Then, re-apply the update. Test: manually apply an update until UPDATED_NEED_REBOOT, then call update_engine_client --reset_status, then call snapshotctl dump to check that snapshots are deleted. Then, re-apply the update. Test: manually apply an update until UPDATED_NEED_REBOOT, then kill update_engine, then call update_engine_client --reset_status, then call snapshotctl dump to check that snapshots are deleted. Then, re-apply the update. Bug: 147696014 Change-Id: Ic7049772091a34e0e666fd7ae361ef474d5a28aa Merged-In: Ic7049772091a34e0e666fd7ae361ef474d5a28aa
2020-03-10ShouldSkipOperation -> OptimizeOperationYifan Hong
For SOURCE_COPY operations like 563412 -> 123456 OptimizeOperation optimizes it to 5612 -> 1256 and skip writing blocks that does not need to be written for snapshot partitions. Bug: 148623880 Test: update_engine_unittests Test: apply incremental OTA Change-Id: Ifd2c3851f703f272a74c8f0e9a1c9a82dbcce3e3
2020-03-05Delete DynamicPartitionControl::CleanupSuccessfulUpdateYifan Hong
It is replaced with GetCleanupPreviousUpdateAction now. Test: builds Change-Id: I8cb281bf811052d1dfea6c14c8685a90915cafa8
2020-03-05UpdateAttempterAndroid::Init initiates mergeYifan Hong
On update_engine starts, schedule CleanupPreviousUpdateAction that calls CleanupSuccessfulUpdate to do necessary cleanup as soon as possible. In the good case, update_engine initiates merge when sys.boot_completed, and clean up snapshots. If the update is rolled back or partitions are flashed, the following happens (on a Virtual A/B device): - UpdateAttempterAndroid::CleanupSuccessfulUpdate is called - DynamicPartitionControlAndroid::CleanupSuccessfulUpdate is called - SnapshotManager::InitiateMergeAndWait is called - SnapshotManager::RemoveAllUpdateState(before_cancel) is called - before_cancel is called, DeltaPerformer::ResetUpdateProgress is called - All update states in update_engine is reset. - SnapshotManager proceeds to delete snapshots - All update states in SnapshotManager is reset. Hence, on an VAB device, when an update is rolled back or partitions are flashed, the whole update needs to be re-applied (while in A/B, it skips writing and directly start verifying hashes of the target partitions because the update markers are still there). Bug: 147696014 Test: apply OTA then reboot, inspect logs and do `snapshotctl dump` Change-Id: I0fc5e7768dfb53e4fd474f2d8d85d2a1b615a88b
2020-01-22Add DynamicPartitionControlInterface::CleanupSuccessfulUpdateYifan Hong
This is a wrapper over SnapshotManager::WaitForMerge. It waits until the previous update is merged, then return. Bug: 138808328 Test: manual with update_engine_client Change-Id: If44854810f37dd959ffdf3f62f26528867a71fc8
2020-01-16DynamicPartitionControl: Add required_size to PrepareYifan Hong
Add out parameter required_size to PreparePartitionsForUpdate to indicate the total size required on /userdata in order to apply the update. Bug: 138808058 Test: update_engine_unittests Change-Id: I2768d13671e212fd24a1a22811b50c9738834459
2019-12-04Only skip operation on snapshot partitionsYifan Hong
On Virtual A/B devices, don't skip SOURCE_COPY on static partitions. Test: update_engine_unittest Test: incremental update to self Change-Id: I5c93b501e09f50f559151eb77d83052373c90d0d
2019-11-27SkipInstallOperation placeholdersAlessio Balsini
For some devices, some InstallOperations can be skipped during the update process. An example is the SOURCE_COPY operation with same source and destination locations for Virtual A/B devices. This patch extents the DynamicPartitionControl interface with the ShouldSkipOperation() method to query if given operation should be skipped or not. Bug: 141207436 Test: build Change-Id: I94dbf1d33d531944e04cb2ffcba274106e866d5d Signed-off-by: Alessio Balsini <balsini@google.com>
2019-11-13BootControl exposes DynamicPartitionControl.Yifan Hong
Add BootControlInterface::GetDynamicPartitionControl, which exposes the internal DynamicPartitionControlInterface object. BootControlStub / FakeBootControl / BootControlChromeOS uses DynamicPartitionControlStub (all functions succeeds). BootControlAndroid uses DynamicPartitionControlAndroid. GetPartitionDevice is exposed so that BootControlAndroid can use it. Follow-up CLs delete duplicated PreparePartitionsForUpdate and Cleanup from BootControlInterface so that BootControlAndroid remains a thin wrapper of the HAL (+GetPartitionDevice, which exists before dynamic partitions.) Test: update_engine_unittests Change-Id: Ifc2aa2ee8a63ef581c8ebc562ec158794ac51dfd