platform_system_core/fs_mgr/libdm
David Anderson 5312c466b9 libsnapshot: Implement merge flow.
This implements InitiateMerge() and WaitForMerge(). InitiateMerge() is
meant to be called after an update has been marked successful.
WaitForMerge() is designed to be called either: immediately after
InitiateMerge, or during each subsequent boot where merging has not
completed.

InitiateMerge converts each snapshot device to a snapshot-merge device.

WaitForMerge polls each snapshot-merge device until no device reports a
"merging" state. One of the following states can result from this:
 - MergeFailed. This will happen if any device failed to merge, or we
   were unable to poll, or any other system-level failure occurred.
 - MergeNeedsReboot. This will happen if a snapshot-merge device has
   completed merging, but we were unable to clean it up due to something
   holding a resource open.
 - MergeCompleted. This indicates that all snapshots completed merging
   and were cleaned up.

If WaitForMerge() returns MergeCompleted, then all snapshots have been
removed and a new update can begin. GetUpdateState() will return None.

MergeFailed and MergeNeedsReboot, on the other hand, are "sticky". They
indicate a merge is still pending. When called again, WaitForMerge()
will poll again to attempt to make more progress in the merge. For
NeedsReboot, a single reboot will ensure all resources are released and
the next WaitForMerge() will successfully finish cleanup. In the failure
case, it is unlikely the next WaitForMerge will succeed, but we always
retry anyway (there is no harm in doing so, and if we get lucky, the
device can take more OTAs).

Bug: 136678799
Test: libsnapshot_test gtests
Change-Id: I5e93fcbffee1973da5ff76363df12d6317a7a7c7
2019-08-07 18:42:23 -07:00
..
include/libdm libsnapshot: Implement merge flow. 2019-08-07 18:42:23 -07:00
Android.bp libdm: Fix race conditions in LoopControl::Attach. 2019-07-11 15:39:53 -07:00
Android.mk Allow makefiles to be parsed in a trimmed down manifest. 2019-03-25 09:14:33 +00:00
AndroidTest.xml Make VTS run libdm_test 2019-03-22 15:11:49 -07:00
dm.cpp libdm: fetch and present device status flags 2019-07-31 00:14:30 +01:00
dm_table.cpp libdm: Add DmTargetVerity and use it in fs_mgr_avb. 2018-06-25 17:56:12 -07:00
dm_target.cpp Merge "Implement basic libsnapshot functionality." 2019-08-03 01:30:49 +00:00
dm_test.cpp libdm: compute percentage of snapshot-merge 2019-08-01 02:22:24 +01:00
loop_control.cpp libdm: Fix race conditions in LoopControl::Attach. 2019-07-11 15:39:53 -07:00
loop_control_test.cpp libdm: Fix race conditions in LoopControl::Attach. 2019-07-11 15:39:53 -07:00
test_util.cpp libdm: Add unit tests for dm-linear. 2018-06-25 12:56:14 -07:00
test_util.h libdm: Add unit tests for dm-linear. 2018-06-25 12:56:14 -07:00
utility.cpp libdm: Fix race conditions in LoopControl::Attach. 2019-07-11 15:39:53 -07:00
utility.h libdm: Fix race conditions in LoopControl::Attach. 2019-07-11 15:39:53 -07:00