Commit graph

1769 commits

Author SHA1 Message Date
Jaegeuk Kim
04bf79dcb4 Merge "fs_mgr: support metadata_csum for ext4 partition" 2020-02-21 05:40:48 +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
Paul Crowley
5ed0698b41 Merge "Add wrapped key support for metadata encryption" 2020-02-18 23:17: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
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
34ad19f4c4 Merge "snapshot: helper to get access snapshot_state path" 2020-02-17 12:31:49 +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
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
Treehugger Robot
4ddb495354 Merge "fs_mgr: fstab: Fix parse warning typo" 2020-02-12 18:20:49 +00:00
Yifan Hong
da8a404473 Merge changes from topic "snapshotctl_log"
* changes:
  libsnapshot callstack files readable by dumpstate
  snapshotctl logs readable by dumpstate
  snapshotctl_log dir readable by dumpstate
2020-02-12 18:18:59 +00:00
Felix
92ed423711 fs_mgr: fstab: Fix parse warning typo
Looks like a copy-paste omission.

Change-Id: Ib8ad3a938654786747540690f4bba93d6573d74d
Signed-off-by: Felix <google@ix5.org>
2020-02-12 17:30:28 +01:00
Yifan Hong
faa49d1d00 libsnapshot callstack files readable by dumpstate
Set callstack logs as 0644 so that they are readable
by dumpstate.

Test: take OTA, cancel, delete /data/misc/update_engine/prefs/*
manually, retrigger OTA (so that callstack is logged), then re-take bug report
Bug: 148818798

Change-Id: I598e484b57dcd3ce6ed7bb483aee57ce2ba881e7
2020-02-11 10:57:51 -08:00
Yifan Hong
bdf93248a3 snapshotctl logs readable by dumpstate
Set persistent logs for snapshotctl to 0644
so that they are readable by dumpstate.

Not using mode field in open() because it is masked
by umask. Directly use fchmod instead.

Test: reboot and take bugreport
Bug: 148818798

Change-Id: I515f8fd1345fcfb82aa2a1ec0c95da4b6921c039
2020-02-11 10:57:51 -08:00
Mark Salyzyn
5ced7600d1 fs_mgr: overlayfs: CreateDynamicScratch for *partition_exists
Commit 69def12f08
("overlayfs: Refactor how the scratch device is deduced, again.")
introduced a regression which dropped a call to
dm.GetDmDevicePathByName.  The call was formerly done to check if
a partition existed and shortcuted the logic.  As a result when
the partition exists and is already instantiated, CreateDynamicScratch
function fails to fill out *scratch_device return value.

The bandaid is to call GetBootScratchDevice() to leverage its own
GetDmDevicePathByName call to fill out if it is detected as an empty
value in CreateDynamicScratch, only called under this condition.

Signed-off-by: Mark Salyzyn <salyzyn@google.com>
Test: adb-remount-test.sh
Bug: 148881519
Change-Id: I40464e8dd17d25a292a275d0b9df5f9519b794fb
2020-02-11 09:41:09 -08:00
Howard Chen
cd8b982e40 Merge "Add a switch to enforce avb for DSU in userdebug" 2020-02-11 06:21:38 +00:00
Howard Chen
f4d345c5ee Add a switch to enforce avb for DSU in userdebug
Bug: 148997664
Test: adb root && adb shell touch /metadata/gsi/dsu/avb_enforce
Change-Id: I5308fa1ae3ca32ee49575fdc52475ad67d51c176
2020-02-10 18:39:57 +00:00
Bernie Innocenti
ba9b73ef8f Convert system/core/fs_mgr to Result::ok()
No functionality changes.

Test: m checkbuild
Change-Id: I96b2adfe7aaea2b2e67307a3ce308455bc1d7a0a
2020-02-10 08:20:25 +09:00
Treehugger Robot
86e13d79cc Merge "rm libbinderthreadstate" 2020-02-07 11:18:51 +00:00
Steven Moreland
f5f9e3594c rm libbinderthreadstate
This library is empty, and its functionality has moved
into libbinder/libhwbinder.

Bug: 148692216
Test: N/A
Change-Id: I306a2c18ec7770cfb6c3939b5e3d42a55c3165fb
2020-02-06 13:25:34 -08:00
Bernie Innocenti
cecebbbacc Convert system/core to Result::ok()
No functionality changes, this is a mechanical cleanup.

Test: m
Test: cd system/core && atest
Change-Id: Ifdaa3ce1947ed578f656d5a446978726eb416c36
2020-02-06 17:04:27 +00:00
Treehugger Robot
a6bc86aae7 Merge "Add libsnapshot_test to presubmit" 2020-02-06 16:58:43 +00:00
David Anderson
24c70ea7ba Merge "libsnapshot: Restrict when snapshots can be deleted." 2020-02-06 16:46:58 +00:00
Alessio Balsini
9ab7fe2768 Add libsnapshot_test to presubmit
Add libsnapshot test to the TEST_MAPPING's presubmit of fs_mgr to run
the test on TH whenever changes are applied to the fs_mgr contents.
Some of the tests are temporarily disabled due to a WIP bug.

Test: TH
Bug: 142513589
Change-Id: I2a283645b433ed1fd2b08d1c4919cac26d19cf16
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-02-06 14:58:25 +00:00
David Anderson
367cca3937 libsnapshot: Restrict when snapshots can be deleted.
Do not delete snapshots for any reason other than merge-complete or a
cancel request from update_engine. Additionally, create a rollback
indicator file if booting into the source slot, so update_engine can
attempt to cancel the update.

Bug: 147819418
Bug: 147347110
Test: libsnapshot_test gtest
Change-Id: Id357a91cec467a60246c7c3d133f6c54ccb3fc93
2020-02-05 17:16:17 -08:00
Alessio Balsini
c352179e10 fiemap: add image_test and writer_test tests to presubmit
Add fiemap_image_test and fiemap_writer_test to TEST_MAPPING to be run
by TH as presubmits.
Because of a bug under investigation, the actual
fiemap_image_test_presubmit is used instead of the original, that has
one test case disabled.

Bug: none
Test: TH, fiemap_image_test, fiemap_writer_test
Change-Id: I63b5e69b5c245a18eceb1e5896df7bd0577f289b
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-02-05 22:08:29 +00:00
Alessio Balsini
f6034544c0 fiemap: fix fiemap size and log message when last extent
Fix the total fiemap struct plus extents size allocation.
Fix also the logging in IsLastExtent, that was printing error messages
every time.

Bug: none
Test: fiemap_*_test
Change-Id: I85c6af63ba3a75b993a5e8ad7d7170dc7af59582
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-02-05 18:27:40 +00:00
Bowgo Tsai
e0f5c10691 first_stage_mount: reading all avb_keys before chroot
Avb keys used to verify a partition are stored in the first-stage
ramdisk. However, after /system is mounted, init will chroot into it.
This makes those keys inaccessible for later mounts, e.g., /vendor or
/product.

This change retains avb keys by reading all of them before chroot
into /system.

Note that it is intentional to perform public matching for both
preload_avb_key_blobs and fstab_entry.avb_keys in libfs_avb.
As some keys might only be availble before init chroots into /system,
e.g., /avb/key1 in the first-stage ramdisk, while other keys might
only be available after the chroot, e.g., /system/etc/avb/key2.

Bug: 147585411
Test: specify avb_keys for a partition and checks the keys are preloaded
Test: atest libfs_avb_test
Test: atest libfs_avb_internal_test
Change-Id: I6bd490c4215480db2937cdfc3fea0d616e224a91
2020-02-05 15:51:41 +08:00
Treehugger Robot
3cbb753b0d Merge "liblp: add test to presubmit" 2020-02-05 01:20:36 +00:00
Yifan Hong
e8cd50a7a0 Merge "libsnapshot::RemoveAllUpdateState log stack" 2020-02-04 23:31:47 +00:00
Treehugger Robot
405d26dacb Merge "Set e2freefrag and e2fsdroid as required by libfs_mgr_defaults" 2020-02-04 22:57:36 +00:00
Yifan Hong
c19b08a66a Merge "Make snapshotctl logging better." 2020-02-04 22:18:33 +00:00
Treehugger Robot
b34a729469 Merge "snapshot/test: Add delay to all the CreateLogicalAndSnapshotPartitions" 2020-02-04 22:16:52 +00:00
Yifan Hong
e8148150c3 libsnapshot::RemoveAllUpdateState log stack
Bug: 148818798
Test: apply OTA but cancel it in the middle, then
      delete /data/misc/update_engine/prefs/*, then
      reapply it again (to trigger CancelUpdate()).
      Stack is dumped.

Change-Id: I2dfb6b7f15b9d5854d0b81ed8ad260538d21c922
2020-02-04 14:01:24 -08:00
Yifan Hong
12fe03d470 Make snapshotctl logging better.
snapshotctl merge --logcat --log-to-file
- If --logcat, log to logcat
- If --log-to-file, log to /data/misc/snapshotctl_log/
- If both, log to both
- If none, log to stdout

Test: manually test these 4 cases
Bug: 148818798
Change-Id: I44b52936c0d095867acc6ee781c6bec04f6ebd6b
2020-02-04 14:01:24 -08:00
Alessio Balsini
13d2d968d9 liblp: add test to presubmit
Add liblp_test to TEST_MAPPING to be triggered as TH presubmit test.

Bug: none
Test: liblp_test
Change-Id: If4d60e816e4e1b321603e1a5ed00e21297567d38
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-02-04 21:33:56 +00:00
Alessio Balsini
272ef868f1 Extra logging for metadata errors
Increase logging in metadata image management.

Bug: none
Test: m
Change-Id: Ie49ca9ac90cd593c95d31f4651ae724d617d5695
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-02-04 20:49:59 +00:00
Alessio Balsini
841bccc1eb snapshot/test: Add delay to all the CreateLogicalAndSnapshotPartitions
In tests CreateLogicalAndSnapshotPartitions may give flaky results
because not synchronous.
Add a bounded delay that prevents this behavior defined by a single
constexpr.

Bug: none
Test: libsnapshot_test
Change-Id: Iad3c24b1d3e82e3bd695d6dbbc8af8eab75bee32
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-02-04 19:33:35 +00:00
Mark Salyzyn
3576ed043c tests: handle legacy and new bootstat complete
Regression from commit cb1a8e7fdd
("Don't retrigger bootstat during userspace reboot.")

sys.boot_completed and either sys.logbootcomplete (legacy) or
sys.bootstat.first_boot_completed set to determine if the display
has gone active for bootstat.  For adb remount test we have no
desire or need to wait for bootstat complete, reduce script
complexity.

Also solve a possible problem with no content supplied to xargs.

Signed-off-by: Mark Salyzyn <salyzyn@google.com>
Test: adb-remount-test.sh
Bug: 148804390
Bug: 135984674
Change-Id: Ieefddf583ff7422e8811d2e338a0f16c8943b0d7
2020-02-04 09:01:31 -08:00
Daniel Rosenberg
2e10d8f74f Merge "Add support for casefold and product ID to format" 2020-02-03 23:12:15 +00:00
Treehugger Robot
be074feb93 Merge "Add libdm_test to presubmit" 2020-02-03 21:55:39 +00:00
Treehugger Robot
962e3ddfd6 Merge "Missing UpdateState::Cancelled string conversions" 2020-02-03 20:03:56 +00:00
Alessio Balsini
d7cc465481 Add libdm_test to presubmit
Also add libdm_test to the TEST_MAPPING's presubmit of fs_mgr to run the
test on TH whenever changes are applied to the fs_mgr contents.

Test: TH
Bug: none
Change-Id: Icc6adeeacaefbcfeb494f37fc776eb5a886a5183
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-02-03 17:34:44 +00:00
Alessio Balsini
a60f6a35ec Missing UpdateState::Cancelled string conversions
Add the missing UpdateState::Cancelled conversions from/to string.

Bug: none
Test: build
Change-Id: I097d80e21521725fbb02f3ef37b22e95a5e83929
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-02-03 16:37:51 +00:00
Alessio Balsini
fb19ed9130 Update assertion on DmTargetDefaultKey param string
Due to some recent code updates that introduced some additional
extra_argv, the DmTargetDefaultKey::GetParameterString() test was
failing.
Update the string accordingly.

Bug: none
Test: libdm_test
Change-Id: I63fab27e32a08211a43d4804d90a6f19ea4edc06
Signed-off-by: Alessio Balsini <balsini@google.com>
2020-02-03 10:37:36 +00:00
Treehugger Robot
cb1a8e7fdd Merge changes from topics "dm-default-key-v2", "metadata_cipher"
* changes:
  Set metadata cipher in fstab
  Add support for v2 of dm-default-key
2020-02-01 16:12:30 +00:00