Commit graph

1956 commits

Author SHA1 Message Date
Nikita Ioffe
f42f972130 Merge "PrepareZramBackingDevice: use loop_control.h" into rvc-dev 2020-04-20 20:06:16 +00:00
Nikita Ioffe
c8313adf88 PrepareZramBackingDevice: use loop_control.h
loop_control.h already provides loop device management APIs that we need
here. In addition, this change fixes a subtle race condition between
uevented creating a loop device node in userspace and
PrepareZramBackingDevice accessing it without waiting for it to be
created.

Test: device boots
Test: adb reboot userspace
Bug: 154500256
Change-Id: If80f18c8c337210030a6caf2aec6f7a47472b6fb
2020-04-20 17:38:17 +01:00
Alessio Balsini
75be098a45 Fix liblp imported both as static and dynamic lib
In vts_libsnapshot_test, liblp was explicitly imported as static
library, but due to the importing of libsnapshot_defaults, it also
inherited the shared importing.
The import in libsnapshot_default, is not required, drop it.

Test: manual inspection with ldd
Bug: 148889015
Signed-off-by: Alessio Balsini <balsini@google.com>
Change-Id: I12ba0516a482dc917848b5f34cccc659a60a4803
Merged-in: I12ba0516a482dc917848b5f34cccc659a60a4803
2020-04-20 14:54:23 +01:00
Martijn Coenen
884c64a052 Merge "Rename external storage properties." into rvc-dev 2020-04-17 07:59:26 +00:00
Martijn Coenen
590969d140 Rename external storage properties.
According to property naming guidelines.

Bug: 152170470
Bug: 153525566
Test: N/A
Change-Id: Ia5ce2a95e43724f8d0a7abf6782bc177dedb18a8
Merged-In: Ia5ce2a95e43724f8d0a7abf6782bc177dedb18a8
2020-04-16 10:13:28 +02:00
David Anderson
a632c0c470 fs_mgr: Fix executable path in clean_scratch_files.
Bug: 154071877
Test: no error log on startup
Change-Id: I84c627011992eed6952697e7260051006b1c10d0
Merged-In: I84c627011992eed6952697e7260051006b1c10d0
2020-04-15 21:27:56 +00:00
TreeHugger Robot
1dc77eaa61 Merge "Abolish DmTargetDefaultKey::IsLegacy" into rvc-dev 2020-04-08 00:10:58 +00:00
Paul Crowley
c9c9d1288f Abolish DmTargetDefaultKey::IsLegacy
To make it easier to support disk formats created using old versions
of dm-default-key with new kernels, stop checking the kernel module
version; instead, the caller decides whether to use the old or new
options format.

Bug: 150761030
Test: crosshatch and cuttlefish boot normally; cuttlefish
    fails with "default-key: Not enough arguments" as expected when
    option is set to 1
Cherry-Picked-From: 539b98fb58
Merged-In: I810bb7e085b9b8648858de1a02165162d1fd163e
Change-Id: I810bb7e085b9b8648858de1a02165162d1fd163e
2020-04-07 07:33:05 -07:00
Nikita Ioffe
7facdac6af get_mounted_entry_for_userdata: Realpath block devices from fstabs
Use realpath as a canonical representation of block devices. This makes
it easier to reason about block devices. This also fixes a bug, in which
fs_mgr_get_mounted_entry_for_userdata didn't properly work on devices
that don't support metadata encryption.

Test: atest CtsFsMgrTestCases
Test: atest CtsUserspaceRebootHostSideTestCases
Bug: 153363818
Change-Id: I139c2be46336a632bbaee86667019c075d7de814
Merged-In: I139c2be46336a632bbaee86667019c075d7de814
(cherry picked from commit 7aa37f1f21)
2020-04-07 14:04:06 +01:00
Dan Shi
783db0d261 Merge "Rename vts-core to vts" into rvc-dev 2020-04-07 02:48:30 +00:00
TreeHugger Robot
ffe8c3a110 Merge "Remove vts10 tests from vts suite" into rvc-dev 2020-04-07 00:19:39 +00:00
Dan Shi
a7b9a2bfd2 Rename vts-core to vts
Bug: 151896491
Test: presubmit check
Exempt-From-Owner-Approval: This CL renames suite name vts-core to vts.
It won't change test logic or behavior.

Change-Id: I24779951257ce37fc18929f214d3cf5f76c23a19
2020-04-06 16:11:29 -07:00
Dan Shi
12c7aa8ace Remove vts10 tests from vts suite
The tests are only needed in vts10 suite, as they are part of CTS
package and no longer needed in vts 11.

Bug: 151896491
Test: local build
Exempt-From-Owner-Approval: This CL removes vts10 tests from vts suite.
It won't change test logic or behavior.

Change-Id: I4d468be075b54213b56c7e1aa94af94f2bdce9ff
Merged-In: I4d468be075b54213b56c7e1aa94af94f2bdce9ff
2020-04-06 14:25:10 -07:00
Yifan Hong
e94892a92e Merge "libsnapshot: Add VTS10 VtsLibsnapshotTest" into rvc-dev 2020-04-06 19:02:05 +00:00
Yifan Hong
6e285ae4a7 libsnapshot: Add VTS10 VtsLibsnapshotTest
Add VTS10 variant of vts_libsnapshot_test so that
it can be added to vts-kernel test.

Bug: 142513589

Test: vts10-tradefed run vts-kernel -m VtsLibnsapshotTest
Change-Id: I4e2516b94d84acb16f595aab87dd3c0cadad6166
(cherry picked from commit 405da5a9a6)
Merged-In: I4e2516b94d84acb16f595aab87dd3c0cadad6166
2020-04-03 16:38:39 -07:00
Bill Peckham
59f0acc146 Ignore functionfs mounts.
Vendors may add additional functionfs mounts. Since these
will never be remounted, we can safely filter these out.

Bug: 153008210
Test: Test device with previously unfiltered entries.
Change-Id: I7f384b8a0ce93dd6701fe3c4d9dd2557370b31e1
Merged-In: I7f384b8a0ce93dd6701fe3c4d9dd2557370b31e1
2020-04-03 12:10:46 -07:00
David Anderson
15e63dff21 libdm: Link libraries statically for VTS.
Bug: 152180548
Test: 32-bit libdm_test
Change-Id: I9f356c854833b5e68820e4d3d4e9709af1288381
Merged-In: I9f356c854833b5e68820e4d3d4e9709af1288381
2020-03-31 13:00:03 -07:00
Yifan Hong
47c08de2d2 libsnapshot: Allow forward merge on FDR
If forward merge indicator exists at unverified state during FDR,
we are allowed to initiate merge and finish it before wiping userdata.

Test: downgrades
Test: update with data wipe
Test: vts_libsnapshot_test
Bug: 152094219
Change-Id: I151f1af4aca446cc52e669c5c3ea2b2e55acb468
(cherry picked from commit 973b8c10d1)
Merged-In: I151f1af4aca446cc52e669c5c3ea2b2e55acb468
2020-03-27 16:11:08 -07:00
Yifan Hong
c7c7a21d2e libsnapshot: Place forward merge indicator for wipe
If the device applies a package with FDR, place forward merge indicator
so that on FDR, the snapshots aren't abandoned, and we forward merge
the update.

Test: apply downgrade
Test: apply update with data wipe
Test: vts_libsnapshot_test
Bug: 152094219
Change-Id: Id32aeca380db797cd777321837f146333ae6b33c
(cherry picked from commit 6b0251232a)
Merged-In: Id32aeca380db797cd777321837f146333ae6b33c
2020-03-27 16:11:08 -07:00
Yifan Hong
1cc4ce96ce libsnapshot: Add allow-forward-merge indicator.
The indicator signals that on factory data reset, initiating
merge is allowed.

Test: vts_libsnapshot_test
Test: apply downgrade update
Test: apply update with FDR
Bug: 152094219
Change-Id: Ieecddd198136571dd652ca62c27fe65a12b7b15f
(cherry picked from commit f9e1e16377)
Merged-In: Ieecddd198136571dd652ca62c27fe65a12b7b15f
2020-03-27 16:11:08 -07:00
Yifan Hong
d5c899e46a libsnapshot: Fix DataWipeAfterRollback test
Test: run it
Bug: 152094219
Change-Id: I06852d7a0514481cbeed3ef66192ba49a24cb54b
(cherry picked from commit a4f9b07490)
Merged-In: I06852d7a0514481cbeed3ef66192ba49a24cb54b
2020-03-27 16:11:07 -07:00
David Anderson
3c4b379cb0 libsnapshot: Fix intermittent test failure due to missing null check.
Bug: 152547190
Test: vts_snapshot_test
Change-Id: If7adc4fba61325e52d6268531ce0a15b00c0a380
(cherry picked from commit 533b2b6296)
Merged-In: If7adc4fba61325e52d6268531ce0a15b00c0a380
2020-03-27 16:11:07 -07:00
Yifan Hong
37f5bb9faa libsnapshot: dump rollback indicator
Test: snapshotctl dump
Bug: 149956852
Change-Id: Ib0308ab75d6dce4047b46d06cece95eed23620a9
(cherry picked from commit 738a94b798)
Merged-In: Ib0308ab75d6dce4047b46d06cece95eed23620a9
2020-03-27 16:11:07 -07:00
Nikita Ioffe
f0ab5b17f6 Use properties for various userspace reboot timeouts
Test: adb reboot userspace
Bug: 146560409
Change-Id: I435e4f93a8769ff7d30cf781e0b48fa3e96121ef
Merged-In: I435e4f93a8769ff7d30cf781e0b48fa3e96121ef
(cherry picked from commit 7b41a1558d)
2020-03-25 21:40:45 +00:00
Yifan Hong
c04d4a567c libsnapshot: Add RecoveryCreateSnapshotDevices(device)
... that doesn't auto mount/umount /metadata.

Test: builds
Bug: 151983957
Change-Id: If525a82c1635ddef221e7be20763bc2f27d3c417
Merged-In: If525a82c1635ddef221e7be20763bc2f27d3c417
2020-03-20 17:55:09 -07:00
PO HUNG CHEN
e3a22ca19d Merge "Convert gsid to use the dynamic AIDL service infrastructure" into rvc-dev 2020-03-16 06:56:16 +00:00
Daniel Rosenberg
7c59f1ae9d Set GC threshold when mounting with checkpointing
This steps up our garbage collection threshold over time when mounting
userdata with checkpointing=disable for f2fs. With this scheme, we step
up the percent of disk we will tolerate being unusable during
checkpointing. At 100%, the filesystem will be able to always mount.
This means we will attempt to mount at most 10 times, for a max time of
about 50 seconds.

Also logs mount time under ro.boottime.init.mount.[target]

If the device does not support checkpoint=disable:[n%], it will mount
with checkpoint=disable, which is equivalent to checkpoint=disable:0%

Test: Boot in checkpointing mode
Bug: 150506496
Change-Id: I047ff98513f4ea832e1216b91e454a57fd2e8bf6
2020-03-13 20:12:02 +00:00
Yifan Hong
5bcf6498c3 Merge "Add OptimizeSourceCopyOperation" into rvc-dev 2020-03-12 23:53:03 +00:00
Yifan Hong
d8a38e7c23 Add OptimizeSourceCopyOperation
... so that an operation can be skipped partially. For example, if
an operation contains blocks:
    563412 -> 123456
... then optimized operation is:
    5612 -> 1256

Test: update_engine_unittests
Test: apply incremental OTA
Bug: 148623880

In an experiment, this reduces CoW size of an incremental update
package by 200MB (out of 700MB).

Change-Id: I86ca23fd589ddbc84c81318283b5f4e71782a759
Merged-In: I86ca23fd589ddbc84c81318283b5f4e71782a759
2020-03-12 10:00:12 -07:00
Nikita Ioffe
ccb0608a32 Merge "fs_mgr_get_mounted_entry_for_userdata: handle logical partitions" into rvc-dev 2020-03-11 19:17:30 +00:00
Nikita Ioffe
f495fe798b fs_mgr_get_mounted_entry_for_userdata: handle logical partitions
In case of GSI on DSU, /data is mounted on the following stack:
userdata -> userdata_gsi -> actual block device, and fstab returned from
ReadDefaultFstab() function will say that /data should be
mounted onto userdata_gsi. This configuration wasn't supported.

To support it, fs_mgr_get_mounted_entry_for_userdata now unwinds the
dm-device stack /data is mounted onto, and for each entry in fstab
resolves corresponding block device (in case of logical partitions by
asking DeviceMapper to resolve name -> path, and for other cases by
reading a symlink), and then checking whenever resolved block device
belongs to the unwinded stack.

Test: on both normal boot & DSU
Test: atest CtsUserspaceRebootHostSideTestCases
Test: atest CtsFsMgrTestCases
Bug: 148612148
Change-Id: I1bb3e64ae92d56de905b4f7f1997b7499b101b0f
2020-03-11 15:10:20 +00:00
Yifan Hong
77d51eb888 Merge changes from topic "no_snapshot_callstack" into rvc-dev
* changes:
  Revert "libsnapshot::RemoveAllUpdateState log stack"
  Revert "libsnapshot callstack files readable by dumpstate"
  libsnapshot: delete InitiateMergeAndWait.
2020-03-10 19:18:48 +00:00
Howard Chen
c7e257c1e9 Convert gsid to use the dynamic AIDL service infrastructure
Replace the original on demand start mechanism with the new dynamic
AIDL service infrastructure to resolve a possible race condition.

Bug: 149130673
Test: gsi_tool status

Merged-In: Ia5f32579a8dcf62d700d974c7f4e3c65647f3b8b
Change-Id: Ia5f32579a8dcf62d700d974c7f4e3c65647f3b8b
2020-03-10 17:35:41 +08:00
Yifan Hong
21ab3adc73 Revert "libsnapshot::RemoveAllUpdateState log stack"
Revert submission snapshotctl_callstack

Reason for revert: Callstack should not be logged
Reverted Changes:
Ib80c74a9a:Temporarily add libutilscallstack dependency
I2dfb6b7f1:libsnapshot::RemoveAllUpdateState log stack

Test: none
Bug: 148818798

Change-Id: I34683e93f10971629737f6fe648b25c6066c702f
2020-03-09 16:16:33 -07:00
Yifan Hong
611c6f7d79 Revert "libsnapshot callstack files readable by dumpstate"
This reverts commit faa49d1d00.

Reason for revert: Callstack should not be logged.

Test: none
Bug: 148818798

Change-Id: Ie5506ae0c7408e255a464b2f403d0a47d272229e
2020-03-09 16:16:33 -07:00
Yifan Hong
ffd1f52c22 libsnapshot: delete InitiateMergeAndWait.
Now that update_engine is responsible for initiating the
merge, InitiateMergeAndWait function becomes useless.

Bug: 147696014
Test: libsnapshot_test
Change-Id: I5473dc543ca8ac2fd31f597720847b02d0e5e33d
2020-03-09 16:16:33 -07:00
David Anderson
114a86ebb4 Merge "libdm: Fix WaitForFile early-returning on failed accesses." into rvc-dev 2020-03-09 19:08:43 +00:00
Nikita Ioffe
bbbd1a8e41 Merge "Move GetMountedEntryForUserdata to fs_mgr.h" into rvc-dev 2020-03-06 19:45:54 +00:00
Nikita Ioffe
8f50cfc28d Move GetMountedEntryForUserdata to fs_mgr.h
Logic of unwinding dm-device stack to figure out what entry was used to
mount userdata turned out to be a little bit more involved, and it
shouldn't be part of libfstab

This CL just moves code around and cleans API a little bit, actual fix
will be in the follow-up CL.

Test: atest CtsFsMgrTest
Test: atest CtsUserspaceRebootHostSideTestCases
Bug: 148612148
Change-Id: If0f8a765dba63adb0e6a711eb81fffdcabea3480
2020-03-06 18:31:38 +00:00
Yifan Hong
dd4e7ef6ce init: restorecon libsnapshot rollback indicator
The rollback indicator is created during first stage init and
is unlabeled. Need to restorecon it properly so that it can
be properly deleted by update_engine later.

Bug: 149956852
Bug: 150907679
Test: apply OTA, reboot, look at serial console
Change-Id: Ie954023b557865691fec2ae378145596bf1973a9
2020-03-05 21:56:03 -08:00
Yifan Hong
e53129819d libsnapshot: SnapshotMergeStats::Start/Finish
Change API for SnapshotMergeStats so that it is easier
for update_engine to use.

Test: apply OTA and look at stats
Bug: 147696014
Bug: 138817833
Change-Id: Ie4036ac7382102c00f0761f443d78e00b9e585d5
Merged-In: Ie4036ac7382102c00f0761f443d78e00b9e585d5
2020-03-05 08:41:46 -08:00
Yifan Hong
2cea7249a9 libsnapshot: Expose SnapshotMergeStats
Test: builds
Bug: 147696014
Change-Id: Ia59a3f9226628558bdd1fdb0966812c2f652190c
Merged-In: Ia59a3f9226628558bdd1fdb0966812c2f652190c
2020-03-05 08:41:45 -08:00
Yifan Hong
3634255e66 libsnapshot: delete WaitForMerge.
Now that update_engine is responsible for initiating the
merge, WaitForMerge function becomes useless.

Bug: 147696014
Test: compiles
Change-Id: I3779bdf9dd8d1716238e21d09acf0499e3fc90a3
Merged-In: I3779bdf9dd8d1716238e21d09acf0499e3fc90a3
2020-03-05 08:41:45 -08:00
Yifan Hong
d5675f6728 libsnapshot: handle errors in RemoveAllUpdateState appropriately.
In CheckMergeState / HandleCancelledUpdate, if removing update state
fails, just return the previous state. It used to return Cancelled,
and the error goes unnoticed.

Test: pass
Bug: 147696014
Change-Id: I9cb3d20c5c886afa1913740c903eaad08f0cc041
Merged-In: I9cb3d20c5c886afa1913740c903eaad08f0cc041
2020-03-05 08:41:45 -08:00
Yifan Hong
7c5ae0a12e libsnapshot: remove snapshots properly after flashing
If updated then immediately flashed target slot at unverified
stage, update_engine attempts to call RemoveAllSnapshots, but
it used to fail because unmapping fails. In reality, these devices
are dm-linear targets, so unmapping them is optional.

- Introduce a GetSnapshotFlashingStatus function that expose more
information than AreAllSnapshotsCancelled. We can use the returned
map<string, bool> to determine whether a partition is flashed or
not.
- Introduce ShouldUnmapDeleteSnapshot which determines whether
unmapping / deleteting a snapshot is needed in RemoveAllSnapshots.

Test: apply OTA, flash target slot, then inspect logs
Bug: 147696014
Change-Id: I0853d1e213566af2a3401e46fac7d9586cee7aaf
Merged-In: I0853d1e213566af2a3401e46fac7d9586cee7aaf
2020-03-05 08:41:44 -08:00
Yifan Hong
ae2558d900 libsnapshot: RemoveUpdateState on rollback.
If rollback is detected in ProcessUpdateState, call
RemoveUpdateState and return UpdateState::Cancelled. Now that
update_engine is reponsible for initiating the merge, it can react to
this state and clean up markers appropriately.

Test: libsnapshot_test
Test: apply OTA, manually rollback (by setting the active slot), then
  inspect /metadata/ota as well as /data/misc/update_engine/prefs.

Bug: 147696014

Change-Id: Ibfee11fb50e4f4fb7c6cf02b4921b35e77b8f5a5
Merged-In: Ibfee11fb50e4f4fb7c6cf02b4921b35e77b8f5a5
2020-03-05 08:41:44 -08:00
Yifan Hong
1d32aa1a37 libsnapshot: NeedSnapshotsInFirstStageMount don't test for IsRecovery
Init skips first stage mount entirely in recovery, so
the check is useless. Also, __ANDROID_RECOVERY__ is always
set for first stage init.

Also add logs if rollback indicator is set.

Fixes: 149956852
Test: apply OTA, manually rollback, reboot, see rollback indicator
Change-Id: Iac967baf4b51ea5ce9f6eb962a33cb7ee5819c1d
Merged-In: Iac967baf4b51ea5ce9f6eb962a33cb7ee5819c1d
2020-03-05 08:41:43 -08:00
Yifan Hong
ef9e44ae78 Allow ProcessUpdateState to be paused.
Change callback type of ProcessUpdateState to bool() so that, when callback
returns false, immediately returns Merging.

Test: libsnapshot_test
Bug: 147696014

Change-Id: I9dcb8e1658b95216c0f1991e2e4c1ea2e7e7b2e5
Merged-In: I9dcb8e1658b95216c0f1991e2e4c1ea2e7e7b2e5
2020-03-05 08:41:43 -08:00
Yifan Hong
f6d4e74bc6 libsnapshot: Re-expose InitiateMerge and ProcessUpdateState
These functions are used directly in update_engine now that
it is responsible for initiating the merge. update_engine has
its own message loop, so WaitForMerge / InitiateMergeAndWait
becomes useless and are deprecated.

Bug: 147696014
Test: compiles

Change-Id: Id8cb14f5f18b4893e2fc3d0d2b374a867a220e6f
Merged-In: Id8cb14f5f18b4893e2fc3d0d2b374a867a220e6f
2020-03-05 08:41:43 -08:00
Yifan Hong
83fe0a3572 libsnapshot: Add prolog to RemoveAllUpdateStates.
Add an optional prolog arg (function<bool()>) that is invoked
before snapshots are deleted and update state set to none.

This allows update_engine to delete markers before deleting snapshots
to avoid depending on the erroneous markers. Otherwise, if update_engine
delete markers after libsnapshot deletes update states, the device could
technically get into a state where update_engine thinks the update has
been applied, but snapshots are gone.

Bug: 147696014
Test: libsnapshot_test

Change-Id: I71bfc04a81ea4f94b3072558be50d2f80565113e
Merged-In: I71bfc04a81ea4f94b3072558be50d2f80565113e
2020-03-05 08:41:42 -08:00