Commit Graph

1914 Commits

Author SHA1 Message Date
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
Yifan Hong 91ffe19c4e snapshotctl don't auto-merge.
update_engine is now responsible for initiating the merge. snapshotctl
becomes a debugging tool for libsnapshot now.

Bug: 147696014
Test: libsnapshot_test

Change-Id: Ia2527a35e0c0f0789dbe5c477e174663ef406903
Merged-In: Ia2527a35e0c0f0789dbe5c477e174663ef406903
2020-03-05 08:41:42 -08:00
Alessio Balsini c6411c2d37 snapshotctl: init reports merge statistics
Enable the --report flag in init rc script to collect and send snapshot
merge statistics after OTA.

Bug: 138817833
Test: statsd_testdrive
Change-Id: Ie32a2c6d7d1671ca2b1846c6a8d33cea2ab22a4c
Signed-off-by: Alessio Balsini <balsini@google.com>
Merged-In: Ie32a2c6d7d1671ca2b1846c6a8d33cea2ab22a4c
2020-03-05 08:41:42 -08:00
Alessio Balsini 65ceecfec6 libsnapshot/test: Re-enable the failing tests
Some tests were temporarily disabled due to errors in Cuttlefish.
Now that the issues were fixed, the tests can be put back in presubmit.

Bug: 148889015
Test: vts_libsnapshot_test (Cuttlefish + Pixel 4)
Signed-off-by: Alessio Balsini <balsini@google.com>
Change-Id: Idcb2b7831b2183b2d734bdf8821fd34746f2beee
Merged-In: Idcb2b7831b2183b2d734bdf8821fd34746f2beee
2020-03-05 08:41:41 -08:00
Jaegeuk Kim 9e1bcc25f9 Merge "fs_mgr: remain elapsed time of fsck in prop" into rvc-dev 2020-03-03 00:37:17 +00:00
Jaegeuk Kim 34da2061d4 fs_mgr: remain elapsed time of fsck in prop
Bug: 149595111
Bug: 149844577
Bug: 138909685
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: I8f11ca2680558dc54efd6788ee0dd56e5d65a356
Merged-In: I8f11ca2680558dc54efd6788ee0dd56e5d65a356
2020-03-03 00:35:04 +00:00
TreeHugger Robot 552729b9d6 Merge "fsck.f2fs: enable cache" into rvc-dev 2020-03-03 00:21:32 +00:00
David Anderson acb49fd07d Merge changes Iac986bca,I0f40b1f2 into rvc-dev
* changes:
  snapshotctl: Not necessary to link to libdm.
  libdm: Make static std::string inline for DmTargetDefaultKey.
2020-03-02 20:31:56 +00:00
Jaegeuk Kim ba446ce785 fsck.f2fs: enable cache
Bug: 149418646
Bug: 149844577
Bug: 111241572
Bug: 134988435
Change-Id: I8f5a9701442302339f7b5880133a960e89114b55
Merged-In: I8f5a9701442302339f7b5880133a960e89114b55
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2020-03-02 19:19:16 +00:00
David Anderson c4bf521d09 snapshotctl: Not necessary to link to libdm.
The symbols are provided by libfs_mgr_binder.

Bug: 149942628
Test: snapshotctl builds
Merged-In: Ie4313c7add5c71bb9614a4d97eec41329425f23d
Change-Id: Iac986bcaaf4a8738b2938c6f95569eb8f5154805
2020-02-28 22:00:11 -08:00
David Anderson e4f24b6d9d libdm: Make static std::string inline for DmTargetDefaultKey.
Bug: 149942628
Test: snapshotctl w/ ASAN build
Change-Id: I0f40b1f29e46bc9afaf19d8c21d62280e2c01074
Merged-In: I0f40b1f29e46bc9afaf19d8c21d62280e2c01074
2020-02-28 22:00:05 -08:00
TreeHugger Robot 21302df932 Merge "Mark fs-verity support for ext4 userdata if first_api_level >= R" into rvc-dev 2020-02-27 22:44:41 +00:00
Victor Hsieh 4674b5593a Mark fs-verity support for ext4 userdata if first_api_level >= R
fs-verity is required for new devices launched with R. This change
remove a manual setup for vendors going forward. The original fs mgr
flag still allows old devices to opt in, which can only to be done
manually because of kernel dependency.

Test: build
Bug: 150034150
Change-Id: I152b63d7889153d41f29677f72074afb1881b65d
Merged-In: I152b63d7889153d41f29677f72074afb1881b65d
2020-02-27 09:44:43 -08:00
Eric Biggers b2bac7f051 fs_mgr: fix checking for casefold feature already enabled
EXT4_FEATURE_INCOMPAT_CASEFOLD is a flag in s_feature_incompat, not in
s_feature_ro_compat.

Bug: 138322712
Test: Treehugger
Change-Id: I07bb1d2b818d423196d8ceebda8900a8adbb19e9
Merged-In: I07bb1d2b818d423196d8ceebda8900a8adbb19e9
2020-02-26 15:43:05 -08:00
Automerger Merge Worker 8cdbcde51a Merge "fs_mgr: support metadata_csum for ext4 partition" am: 04bf79dcb4 am: cfb05f56eb am: 72b365df47
Change-Id: Ib43fb3f967e2a0d03fbd293815befeb3de139b4d
2020-02-21 06:05:03 +00:00
Jaegeuk Kim 04bf79dcb4 Merge "fs_mgr: support metadata_csum for ext4 partition" 2020-02-21 05:40:48 +00:00
Automerger Merge Worker 2d99a504a3 Merge "libsnapshot: fix stats write in Resume()" am: 20d9d6a630 am: b568c330dc am: 692cdf94ef
Change-Id: Id81ce411f63c7f16b0d4765f8acad94fd493a0ad
2020-02-20 20:49:54 +00:00
Alessio Balsini 91da9dfeef libsnapshot: fix stats write in Resume()
The Resume() operation is supposed to increment the resume counter, but
the updated counter value was not written to the device.
Fix by adding the write operation and refactoring the code.

Bug: none
Test: m
Change-Id: I3fffd61cc779c59e2780900809f0ce0b84258e78
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-02-20 15:05:13 +00:00
Alessio Balsini 4eb783b3d9 Merge "snapshotctl: send snapshot merge report metrics" 2020-02-20 01:12:03 +00:00
Automerger Merge Worker 1cbb9071da Merge "Add wrapped key support for metadata encryption" am: 5ed0698b41 am: ca03b68e12 am: 1427fe5c6f
Change-Id: I162a366af66396f022eb3df2462fd4311b7e9099
2020-02-19 22:19:26 +00:00
Paul Crowley 5ed0698b41 Merge "Add wrapped key support for metadata encryption" 2020-02-18 23:17:06 +00:00
Automerger Merge Worker da7ff346a5 Merge "libsnapshot: Temporarily disable flaky ImageManagerTest" am: cf4f56df9f am: 95c67d0cda am: 4a505420b7
Change-Id: I766615b567ac0687969dfdb5830f19de4d51fde4
2020-02-18 21:08:06 +00:00
Barani Muthukumaran 2ca1d83ddb Add wrapped key support for metadata encryption
Change metadata_cipher fstab option to metadata_encryption
that includes encryption flags in addition to the cipher.
wrappedkey_v0 encryption flag is used to denote that the
inline encryption hardware supports wrapped keys. dm-default-key
device is created and a wrappedkey is provided along with the
optional wrappedkey_v0 argument.

Bug: 147733587

Test: FBE validation with Fscrypt v2 + inline crypt + wrapped
key changes kernel and metadata encryption with wrapped key.

Change-Id: Id1a18db175680dd6b0adb4594d06566eb1285785
2020-02-18 12:44:40 -08:00
Alessio Balsini 41b00ca46e libsnapshot: Temporarily disable flaky ImageManagerTest
This test was causing the failure of vts_libsnapshot_test.
Disable until a fix is found and tests are stable again.

Bug: 149738928
Test: atests vts_libsnapshot_test
Change-Id: Ibbe5cd72aad93d9ade4ac1542f08dec9cd926a3b
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-02-18 15:53:45 +00:00
Alessio Balsini 6a8a7c2e20 snapshotctl: send snapshot merge report metrics
Add the --report flag to spshotctl to submit Android metrics on the final state
of the snapshot merge operation, the duration if the merge is completed in a
single session, or the number of reboots that happened before completing the
merge.

Bug: 138817833
Bug: 148138124
Test: m + OTA + statsd_testdrive
Change-Id: Id657f33963bb9926553fa6eeb1721a5229f11e87
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-02-18 15:21:56 +00:00
Alessio Balsini 43ae37ba1f Merge "SnaspshotManager uses SnapshotMergeStats" am: beb3125d3d am: c16d61d661 am: 80ce91a5be
Change-Id: I1eab478e557cf675ed700b7041d4faa052288106
2020-02-18 11:35:32 +00:00
Treehugger Robot d15f1fc063 Merge "Utility class to measure snapshot merge duration" am: e87527faa3 am: e6060c927c am: 5a88ff5e18
Change-Id: Ie2f86222e09bdaf1976f10fd996912d550b47e7d
2020-02-18 02:55:13 +00:00
Alessio Balsini adfa9fddd9 SnaspshotManager uses SnapshotMergeStats
The SnapshotMergeStats class is issued by SnapshotManager to track the
merge duration and possible reboots during the merge process.

Bug: 138817833
Test: m
Change-Id: I04e53bb8f6aa9e740c0dcc77c3a9566383954fba
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-02-17 16:38:21 +00:00
Alessio Balsini cd3915d2e7 Utility class to measure snapshot merge duration
With the Virtual A/B feature, when the device successfully boots after an OTA
update, a dm-snapshot merge operation is performed, which consolidates the
updated images to the base devices.  This merge operation depends on the OTA
size and may affect the device performance until completed.
Create the SnapshotMergeStats class that takes care of measuring the duration
of a merge operation and manages the merge state file to continue tracking the
merge in the case of an interruption due to a reboot.

Bug: 138817833
Test: m
Change-Id: I9dcf1423716c89d8f9b4a0feb4e75bb7b9d18935
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-02-17 16:36:36 +00:00
Treehugger Robot 470d50854e Merge "snapshot: helper to get access snapshot_state path" am: 34ad19f4c4 am: 054e278ab1 am: f9b8446205
Change-Id: I0609f33a5d13fea8fff8689db2c32c5386c90bda
2020-02-17 13:11:51 +00:00
Treehugger Robot 34ad19f4c4 Merge "snapshot: helper to get access snapshot_state path" 2020-02-17 12:31:49 +00:00
Wei Wang f21f71bdbc Merge "fsmgr: print unabbreviated log when exec child commands" am: 71fcaf5726 am: a7a1a9690e am: 96114740a3
Change-Id: I42fb007fb13e703eb57e185d1df780a4a9372c3a
2020-02-17 10:12:59 +00:00
Wei Wang 02e89ecdb5 fsmgr: print unabbreviated log when exec child commands
logs need to be printed at time when it is generated by the child
process which is very useful to understand the boottime impact of
those blocking commands.

Bug: 149418646
Test: boot
Change-Id: Ibee343af6088d57b2976bceb812abb58f3b3f610
2020-02-14 23:34:39 +00:00
Alessio Balsini be0e44d0f1 snapshot: helper to get access snapshot_state path
/metadata/ota/snapshot_state is a temporary file that keeps track of
snapshot merge operations across reboots.

Bug: 138817833
Test: m
Change-Id: I9785db3f73e1575b8ac8a522d938d09f8948e1b0
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-02-14 20:49:08 +00:00
Mark Salyzyn cc7cf4fa5a Merge changes I5b4a87d6,I131315d4 am: 48c0de4907 am: 0bfe8df121 am: cf044e0f1c
Change-Id: Id86b51c063544d6f65eb1c2a88d5646f4f2ab856
2020-02-14 20:12:28 +00:00
Mark Salyzyn f7aa5403c5 fs_mgr: overlayfs: test: if wait_for_screen times out, skip later
To improve the test period for adb-remount-test.sh, if the device
fails to get to the launcher on the first try when wait_for_screen,
then print a warning to skip all later wait_for_screen conditions.

The wait_for_screen testing is really there to deal with first
confirming that the device is capable of getting to the launcher,
and that later tests that influence corners of adb remount behavior
do not result in a failure to get to the launcher screen.  The
developer should look into ways to fix the failure to get to the
launcher on the first try, but failure to do so should have no
bearing on the remaining tests, so dropping the wait_for_screen
functionality is not an issue.

Signed-off-by: Mark Salyzyn <salyzyn@google.com>
Test: adb-remount-test.sh
Bug: 148881519
Change-Id: I5b4a87d6e1f545a304eb74f2114aadd1128f25b3
2020-02-14 11:19:35 -08:00
Mark Salyzyn ba2449b6ca fs_mgr: remount: add -v option
By default print only ERROR message, or messages without a source
(eg: [fs_mgr]) library.  Print all messages to stderr if the -v
option is added.  Always log all messages to the Android logger.

Signed-off-by: Mark Salyzyn <salyzyn@google.com>
Test: adb-remount-test.sh
Change-Id: I131315d4bae6ed29991043033811cf22e6032f8b
2020-02-14 11:19:35 -08:00
Jaegeuk Kim 78f040c6d6 fs_mgr: support metadata_csum for ext4 partition
The metadata_csum can enhance ext4 stability, so this patch adds a way to
enable it.

Requiring "metadata_csum" in fsmgr flag of fstab.

Bug: 149039306
Change-Id: I618a65d7afc63a617f5f2582c93002af7f8e7234
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2020-02-14 09:50:36 -08:00
Automerger Merge Worker 3f8ee8991d Merge "fs_mgr: fstab: Fix parse warning typo" am: 4ddb495354 am: 1b378271f4 am: e18e48b18a
Change-Id: I02f2924417a8627135c559113b868ea2e8e40ca4
2020-02-12 18:51:56 +00:00
Automerger Merge Worker c367388849 Merge changes from topic "snapshotctl_log" am: da8a404473 am: 6d3c0ef08c am: 9345bfb0b2
Change-Id: I0cb4d5a42e43cee95614cc9397faff9b9ad34a84
2020-02-12 18:51:48 +00:00
Automerger Merge Worker 09bbf6478a Merge "fs_mgr: overlayfs: CreateDynamicScratch for *partition_exists" am: 684122a264 am: 066cfa3726 am: 47afe8f609
Change-Id: I3d0567affeb31c92a3370585c9b0959a50392d3a
2020-02-12 18:51:38 +00:00
Treehugger Robot 4ddb495354 Merge "fs_mgr: fstab: Fix parse warning typo" 2020-02-12 18:20:49 +00:00