Commit graph

3082 commits

Author SHA1 Message Date
David Anderson
89d84e1de4 Merge "remount: Refactor partition filtering into helper functions." 2022-08-05 22:10:29 +00:00
David Anderson
0b0b2b6b5f remount: Refactor partition filtering into helper functions.
There is a small change of behavior in this patch. If "remount"
specifies a list of arguments, and one of them is invalid, it will now
error rather than try to remount the remaining partitions.

Bug: 241179247
Test: remount
Change-Id: I7a9ef41886f32ae97173796358b41844a1e42ea8
2022-08-05 11:52:24 -07:00
Akilesh Kailash
2823900efb libsnapshot: Store index of COW ops vector
Using vector + unordered_map to retrieve the index in
a COW op vector consumes significant memory; this
is a problem especially when there are hundreds
of thousands of operations.

Instead, just store the index of the COW op vector
during pre-processing.

On Pixel, peak memory usage when all the partitions
are mapped:

Without patch:
	RssAnon:	  118804 kB
With path:
	RssAnon:	   55772 kB

Additionally, post OTA reboot, memory usage further goes
down as the partition merge completes.

Bug: 238052240
Test: OTA on Pixel
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: Icc68a9688ceb89572821cee2dac689779f5e7c11
2022-08-04 17:31:03 +00:00
David Anderson
eb2d8e966e remount: Split fstab and checkpointing code into helper functions.
Bug: 241179247
Test: remount
Change-Id: I0c3ca23696b71f72cdd2d650872d1d9ab34f9de5
2022-08-03 13:36:40 -07:00
David Anderson
8ae1c5d81a libsnapshot: Improve vts_libsnapshot_test alternate configuration testing.
Change -force_config to -force_mode. Change inputs to vab-legacy
(Android R) and vabc-legacy (Android S). Default is device
configuration. There is no explicit option for Android T since it is the
default.

This also adds -compression_method which overrides the default of "gz".

Bug: 208944665
Test: vts_libsnapshot_test -compression_method lz4
      vts_libsnapshot_test -force_mode vab-legacy
      vts_libsnapshot_test -force_mode vabc-legacy
Change-Id: Iedc9461325229ccffd84478e1971f8b6b959e160
2022-07-28 13:14:20 -07:00
David Anderson
76c6c5bc2f libsnapshot: Switch to IPropertyFetcher.
vts_libsnapshot_test uses IPropertyFetcher, as does liblp, but
libsnapshot doesn't. Fix this by switching relevant cases in
utility.cpp.

This also changes SnapshotTestPropertyFetcher from a mocked class to a
pseudo-implementation. This is useful because sometimes we want the
actual device's properties and sometimes we don't, and this setup is
more flexible.

Bug: 208944665
Test: vts_libsnapshot_test
Change-Id: I58621281715b3efb045b6be6f788934fddaa1a0c
2022-07-28 11:28:29 -07:00
David Anderson
d3ecda57c4 libsnapshot: Clarify the meaning of "compression.enabled".
The compression.enabled property only refers to legacy snapuserd.
However, everywhere it's used, we almost always mean "using the new COW
format with snapuserd, whether compression is enabled or not".

This patch clarifies things by renaming "compression_enabled" fields to
"using_snapuserd".

This also simplifies the feature detection code quite a bit, by removing
some redundant checks and clarifying which cases are legacy vs userspace
snapshots.

Bug: 208944665
Test: vts_libsnapshot_test
      apply OTA, snapshotctl dump
Change-Id: Ie617ed3f92eefb8dff0a5cf13e5a2caa47b9e8e0
2022-07-27 18:32:15 -07:00
David Anderson
808078ef75 libsnapshot: Refactor WriteSnapshotAndHash.
This adds a helper around WrapSnapshotAndHash to avoid manually calling
it as most tests have to do. It also changes the signature so a
PartitionUpdate is passed rather than a name, which gives access to
partition information for debugging.

Bug: 208944665
Test: builds
Change-Id: Icd1cdf9d49c48f5a44c35ab1b86f43287e429f86
2022-07-25 16:56:33 -07:00
Akilesh Kailash
58377417e9 Flush after every 2MB merge of replace ops.
This will be in sync with incremental OTA's where the sync
is done every 2MB. This improves performance on devices
with low memory.

Merge times for full OTA may increase by couple of seconds but
that is ok given it decreases the memory footprint.

Bug: 238052097
Test: OTA
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: Ic2c8d2ffdbdb677e0c4d44e5de68ce8ccf86df34
2022-07-25 19:08:46 +00:00
Treehugger Robot
e7bc3e3764 Merge "libfiemap: Add a test case for larger block size filesystems." 2022-07-23 03:18:58 +00:00
David Anderson
d76c31ba40 libfiemap: Add a test case for larger block size filesystems.
This adds a test case for filesystems with larger than 4KiB alignment.
It creates a temporary FAT filesystem and attempts to create a backing
image. The actual size of the block device should be the requested size.

Test: fiemap_image_test
Bug: N/A
Change-Id: I8ef574b22dbf6d47f4855b7de681c927cf81f2b7
2022-07-22 17:44:12 -07:00
Yi-Yo Chiang
379be50f9c fs_mgr_overlayfs: Try "/system" and "/" when setting "/system" shared type
b/239574953 uncovers an obscure test device configuration that breaks
with aosp/2146960.

Without aosp/2146960, "/system" is not a mountpoint, because after
switch_root, the "/system" mount entry becomes "/", thus changing the
subtree propagation type of "/system" would fail.
With aosp/2146960, "/system" is bind-mounted to itself after
switch_root, ensuring "/system" being a mountpoint, thus changing the
subtree propagation type of "/system" is allowed.

Before we can re-land aosp/2146960, just try both "/system" and "/"
when changing the subtree shared propagation type of "/system", so
both scenarios are handled.

Test: Add submount under /system and adb remount
Change-Id: I4006a5c1b1987d5f6452efa069ec5c7d2ac7c8ec
2022-07-21 03:52:26 +00:00
David Anderson
2d8bc21823 remount: Ensure that scratch images are block-size aligned.
Bug: 218976943
Test: adb remount
Change-Id: I46a4592c4ba504865a633437d734ce26e5fba6a5
2022-07-20 16:20:03 +00:00
Treehugger Robot
c89e97f627 Merge "vts_fs_test: checks AVB 1.0 isn't used" 2022-07-20 03:29:26 +00:00
David Anderson
f4753d1cc5 Merge "Fix for Cannot load etc/recovery.fstab when doing OTA upgrade" 2022-07-19 21:11:55 +00:00
Bowgo Tsai
80cb505f64 vts_fs_test: checks AVB 1.0 isn't used
AVB 1.0 support in fs_mgr has been removed in commit
Ibfb46aa6c2f761dbb3a9b5f0b16336e510417620.

Adding a VTS test case to ensure the legacy 'verify' fs_mgr
flag isn't used anymore.

Also converting GetFstabPath() to a public API in the fstab.h,
so the test case can read then parse the fstab file.

Bug: 204948957
Test: atest vts_fs_test
Change-Id: Ib6ed7cb8b6ad719b19cd876acf10f4312ecb51b6
2022-07-19 16:27:59 +08:00
daren.liao
cadee353fa Fix for Cannot load etc/recovery.fstab when doing OTA upgrade
1.In ANP, the path of the executable file recovery is sbin/recovery, and in ANR it is system/bin/recovery
2.Add a judgment on whether sbin/recovery exists in fs_mgr_fstab.cpp,
Make it possible to correctly load etc/recovery.fstab in recovery mode

Bug: 237368169
Change-Id: I8df76a003bc2edbaa01d9dd173a0cba1401ef3ac
2022-07-15 17:58:09 +08:00
David Anderson
c2f95c4b79 vts_fs_test: Only require EROFS in T+ kernels.
Bug: 237765186
Test: vts_fs_test
Change-Id: I294535953bfbe0f246347487b746d3adf2fca1aa
2022-07-13 16:45:11 -07:00
David Anderson
ffda48e959 Revert "Do not enforce EROFS for android-T and below."
This reverts commit a571d4a9bc.

Reason for revert: Incorrect fix

Change-Id: I6586c8e53cc89418d1802807a1a2e108f7e825d3
2022-07-13 16:36:43 -07:00
Akilesh Kailash
58f66339ef Merge "libsnapshot: Fix vts_libsnapshot_test.SnapshotUpdateTest#FullUpdateFlow" 2022-07-12 17:53:09 +00:00
Treehugger Robot
c29f0745d5 Merge "Convert fastboot/libsnapshot to new BootControl client" 2022-07-12 17:47:20 +00:00
Sandeep Dhavale
f607e37fd0 Merge "Print OTA merge progress state in logs" 2022-07-12 17:12:23 +00:00
Akilesh Kailash
bfbd9b0e6e libsnapshot: Fix vts_libsnapshot_test.SnapshotUpdateTest#FullUpdateFlow
Check if compression feature is enabled.

Bug: 238143011
Test: OTA
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: I77663799a5371f1de8b4e29d7c777a24249d1b7b
2022-07-12 05:23:48 +00:00
Sandeep Dhavale
5bdb9dbb79 Print OTA merge progress state in logs
Currently OTA merge process prints enum values in logs in numerical
form. This patch changes the log messages from numerical enums to
more friendly names.

Test: Manual OTA

===========Logs==========
CheckTargetMergeState for vendor_dlkm_b returned: Merging
ProcessUpdateState handling state: Merging
CheckTargetMergeState for product_b returned: Merging
CheckTargetMergeState for vendor_dlkm_b returned: MergeCompleted
ProcessUpdateState handling state: Merging
CheckTargetMergeState for product_b returned: MergeCompleted
ProcessUpdateState handling state: MergeCompleted

Bug: 234518211
Change-Id: If690d3ea86e6fe37e8b3e4bd52e87b70ae92495c
2022-07-12 03:40:11 +00:00
Kelvin Zhang
6befe78c3c Convert fastboot/libsnapshot to new BootControl client
Thew new client will use AIDL if available, and fallback to HIDL
otherwise.

Test: th
Bug: 227536004
Change-Id: I9af21037a76a4a6db00144f5b2774ea23f3a5cc2
2022-07-08 10:57:53 -07:00
P.Adarsh Reddy
a571d4a9bc Do not enforce EROFS for android-T and below.
EROFS is not mandatory for android T and below,
so skip the test for those.

Bug: 237765186
Test: vts_fs_test fs#ErofsSupported
Change-Id: Iceea46f8f2d443636de504962b718a2461605591
2022-07-08 12:14:01 +00:00
Benergy Meenan Ravuri
7680c29bc9 Check userspace snapshots only for API level >= T
Skip checking for userspace snapshots enabled property
for API level < T as this feature is not applicable for
GRF targets.

Bug: 236450435
Test: vts_ota_config_test
Change-Id: Ib5083f6237cdf4962aae06f166811d67cf6c385e
2022-07-05 16:43:31 +05:30
Yi-yo Chiang
827389c9a4 Merge "fs_mgr_fstab: Refactor & cleanup DSU mounting logic" 2022-07-04 05:32:51 +00:00
Akilesh Kailash
1e46611c78 Reduce priority of merge threads
Currently, when daemon is spin up, it runs at the highest
priority with nice value set to -20. This can potetially
lead to a problem in a busy system especially after OTA
reboot when all the merge threads are running in parallel.

Now that we reduced the number of merge threads in-flight
to 2, we reduce the priority as well by setting the nice
value to -5. The other threads which serve I/O's
from dm-user (from root filesystem) still runs at higher
priority. We need this because post OTA reboot, these
threads serve I/O's until merge is completed.

Merge threads on the other hand can run at a relatively
lower priority. We need to make sure that there
is always forward progress even in a busy system
and hence set the priority to -5 as compared
to default value of 0.

No boot time regressions observed.

Output of NICE value of merge and worker threads post OTA reboot:

1 S     0   427   451     1 0  39 -20  64 2314640 dev_r+ ?      00:00:00 8
1 S     0   427   486     1 4  39 -20  64 2314640 dev_r+ ?      00:00:02 8
1 S     0   427   487     1 4  39 -20  64 2314640 dev_r+ ?      00:00:02 8
1 S     0   427   488     1 3  39 -20  64 2314640 dev_r+ ?      00:00:02 8
5 R     0   427   634     1 1  24  -5  64 2314640 0    ?        00:00:00 8
5 R     0   427   935     1 5  24  -5  64 2314640 0    ?        00:00:02 8

Bug: 237490659
Test: Full and incremental OTA
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: I6791dd72ccd8cd5bba6eff663bb3f9598bce7ed2
2022-07-01 19:11:24 +00:00
Akilesh Kailash
9df7c07e5a Tune snapshot-merge performance
Currently, there is one thread per partition
for snapshot merge. When all these threads are
run in parallel, this may stress the system
as the merge threads are both CPU and I/O bound.

Allow only two merge threads to be in-flight
at any point in time. This will ensure that there
is forward progress done with respect to snapshot-merge
and only two cores are used as against using
5-6 cores.

Additionally, system and prodcut partitions are merged
first. This is primarily because /root is mounted
of system partition and faster the merge completes
on /system partition, we can switch the dm tables
immediately. There is no change in the merge phase
from libsnapshot perspective. This prioritization
is based on each merge phase. If the system partition
merge is in second phase, then it takes priority
in that phase.

As a side benefit, this should also
reduce the memory usage when merge is in-flight
given that we now limit the threads.

There is slight delay in overall merge time as
we now throttle the merge.

No boot time regressions observed.

Full OTA:

Merge time (Without this patch): 42 seconds
Merge time (With this patch): 46 seconds

Incremental OTA:

Merge time (Without this patch): 52 seconds
Merge time (With this patch): 57 seconds

system partition merge completes in the first ~12-16 seconds.

App-launch (COLD) on Pixel:

Baseline (After snapshot-merge is completed when there is no daemon):
==========================

Chrome: 250
youtube: 631
camera: 230

==========================

Without this patch when snapshot-merge is in-progress (in ms):

Full - OTA

Chrome: 1729
youtube: 3126
camera: 1525

==========================

With this patch when snapshot-merge is in-progress (in ms):


Full - OTA

Chrome:  1061
youtube: 820
camera: 1378

Incremental - OTA (350M)

Chrome: 495
youtube: 1442
camera: 641
=====================

Bug: 237490659
Test: Full and incremental OTA
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: I887d5073dba88e9a8a85ac10c771e4ccee7c84ff
2022-07-01 19:05:09 +00:00
Yi-Yo Chiang
f8671e0fc1 fs_mgr_fstab: Refactor & cleanup DSU mounting logic
* Instead of copy-and-modify `/data` mount entry, TransformFstabForDsu()
  can just modify all `/data` mount entries in-place.
* This also stops TransformFstabForDsu() from shuffling the mount entry
  of `/data` in fstab, simplifying the testcase.
* Implement GetEntriesForMountPoint() with GetEntriesByPred().
* Remove unused method BuildDsuUserdataFstabEntry() and
  EraseFstabEntry().

Bug: 235111004
Test: atest CtsFsMgrTestCases
Test: Presubmit GSI boot test
Change-Id: I4afb443b7e527038fb42424543bb1538b01d5ec9
2022-06-30 06:46:02 +00:00
Yi-Yo Chiang
e0cd16ba41 fs_mgr_fstab: Remove legacy DSU logic for Q first_stage_init
Deprecate DSU booting support on Q first_stage_init.
Now kDsuActiveFile and kGsiLpNamesFile must be accessible for
ReadFstabFromFile() to return successfully.

Bug: 235111004
Test: Presubmit GSI boot test
Change-Id: I5760eb9aa05610085dd7b7b78940f22fba425229
2022-06-30 06:07:29 +00:00
Kelvin Zhang
5cb1b0295e Add lz4 support for VABC
Add lz4 support in CowWriter/CowReader. Lz4 should offer faster
read/write performance but slightly larger COW sizes.

Download time: Reduced from 1264s to 825s (~35% faster)
Filesystem verification time: from 69s to 59s (~15% faster)
COW Size: 2.59GB to 3.21GB, (~25% regression)
Merge time: 37046ms to 27690ms (~25% faster)
Boot time: LZ4 is 2.7% faster

Overall, LZ4 offers faster read/write performance at the cost of 25%
space regression.

Test: th
Bug: 228478555
Change-Id: Ie521852fb3c9ff8a12e55b764c1eb1838f7b2181
2022-06-29 13:10:55 -07:00
David Anderson
4a2beb8d6a Merge "EXT4_FEATURE_COMPAT_STABLE_INODES from ext4.h" 2022-06-28 18:14:28 +00:00
jiajia tang
dc07763585 EXT4_FEATURE_COMPAT_STABLE_INODES from ext4.h
Include EXT4_FEATURE_COMPAT_STABLE_INODES feature
flag from system/extra.

Test: m
Test: mmma system/core

Signed-off-by: jiajia tang <tangjiajia@xiaomi.com>
Change-Id: I85f4a1c66cdfb37246808d58ca6315861daafe83
2022-06-25 10:07:54 +00:00
Yi-Yo Chiang
c46c89228c TransformFstabForDsu: Support erofs GSI and refactor
Synthesis mount entry for erofs and ext4.
Fix the synthesis logic to always create a new entry from scratch. The
old logic of "copy an existing mount entry and edit its fs_type"
doesn't work because different fs_type would have incomptable
fs_options. For example, changing this:
  system  /system  ext4  ro,barrier=1  wait,logical,first_stage_mount
to this:
  system  /system  erofs  ro,barrier=1  wait,logical,first_stage_mount
doesn't work, because the erofs driver won't recognize the "barrier=1"
mount flag, since "barrier=1" is specific to ext4.

Bug: 235111004
Test: Boot erofs GSI.
Test: atest CtsFsMgrTestCases
Change-Id: I57132a55a089c7aae3e17c717ecd9dc1047fede8
2022-06-24 16:47:36 +08:00
Akilesh Kailash
c898925104 libsnapshot: Fix vts_libsnapshot_test for GRF with Vendor on S
If the vendor partition is on S and system partition is on T,
certain tests in vts_libsnapshot_test used to fail. This is primarily
because of inconsistent check between daemon and vts test.

vts test checks the userspace.snapshots.enabled property which is true on T
but never checks if the underlying vendor partition is on S. Hence,
vts test will enable userspace snapshots. However, daemon checks
the vendor partition and disables userspace snapshots thereby
leading to inconsistency.

This is only a problem on vts tests. The underlying OTA on devices
works fine as we have the vendor partition check.

Bug: 231401995
Test: vts_libsnapshot_test on S vendor and T system
      vts_libsnapshot_test on T vendor and T system
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: Iad4f299bd2e07c9c01f5fbee6a20e2f01bf1778a
2022-06-15 20:50:02 +00:00
David Anderson
4aaff2b264 Merge "sh_binary_host for 'adb-remount-test.sh'." 2022-06-13 18:06:11 +00:00
Akilesh Kailash
2ba3ae310e Merge "snapuserd: Update verification" 2022-06-09 22:43:32 +00:00
jiajia tang
a1c8f00e70 sh_binary_host for 'adb-remount-test.sh'.
"adb-remount-test.sh" is sh_binary,
not cc_prebuilt_binary.

Test: m
Test: cd system/core/fs_mgr; mma

Change-Id: Ie5e2446f87d38905d728e2c5a76f6f02381d10ce
Signed-off-by: jiajia tang <tangjiajia@xiaomi.com>
2022-06-08 22:05:06 +00:00
Akilesh Kailash
f790606591 snapuserd: Update verification
Initiate update verification from daemon. This will help
in two ways:

1: We avoid reading everything into page-cache. Since,
low end devices are already short on memory, we don't
want to read and populate page-cache which can slow
down boot.

2: During boot, once the selinux transition is done, daemon
is all ready to kick off the verification since verity is
already setup. Note that we are still guarded by update_verifier.
Update_verifier will still block marking new slot as
boot success until the verification is completed. So, there
is no change in the behavior.

Bug: 193863442
Test: Full and incremental OTA on Pixel 6

Incremental OTA of 500M (Monthly OTA)

Boot-time (Without this patch): 38 seconds
Boot-time (With this patch): 32 seconds

Full OTA of 2.2G:

Boot-time (Without this patch): 27 seconds
Boot-time (With this patch): 21 seconds

Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: I4f17db19bdd0dd261902c670be6212862d861fe1
2022-06-08 20:26:10 +00:00
Jaegeuk Kim
e67e570028 Add zoned device support
Format f2fs zoned device.

Bug: 172378121
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: Ic7f564ce5786c635ee1e1f6d0b33c1f4d08f780a
2022-06-08 13:12:15 -07:00
Yi Kong
ecd6ad0df7 Fix incorrect use of TEMP_FAILURE_RETRY
The return code check should be after TEMP_FAILURE_RETRY.

Discovered by the tautological-constant-compare warning.

Test: presubmit
Bug: 72331526
Change-Id: I531a9e0498ce9448facc692ddedc14434e7ab507
2022-05-30 09:18:31 +00:00
Treehugger Robot
ab2d6cdc8f Merge "vts_fs_test: Require EROFS sysfs nodes." 2022-05-27 06:56:33 +00:00
David Anderson
1652f0f39a vts_fs_test: Require EROFS sysfs nodes.
These were backported to android13-5.10 and should be present in
T-launch kernels.

Bug: 233926292
Test: vts_fs_test
Change-Id: Ifb5ff6a200b081fe8696d5803d4a128740eb8e21
2022-05-26 21:48:59 -07:00
David Anderson
1acfc08e30 Merge "libsnapshot: Add more feature flags to SnapshotMergeReport." 2022-05-26 00:23:13 +00:00
Treehugger Robot
b2e68186e5 Merge "Relax filesystem requirements in vts_fs_test." 2022-05-25 22:40:59 +00:00
David Anderson
5bbdc23837 Relax filesystem requirements in vts_fs_test.
Bug: 233926292
Test: vts_fs_test
Change-Id: I9665acebd6ebfde14e0cd76e8044e7ced9ffbeb3
2022-05-25 13:44:33 -07:00
David Anderson
93faa18bce libsnapshot: Add more feature flags to SnapshotMergeReport.
This patch also begins reducing the complexity of SnapshotMergeStats by
eliminating the indirection layer between the protobuf and
SnapshotManager.

Bug: 222117189
Test: statsd_testdrive
Change-Id: I15d740121c381da7d8311f0cbbd0da82db877555
2022-05-25 13:40:31 -07:00
Kelvin Zhang
321d47639e Merge changes from topic "snapuserd_ramdisk"
* changes:
  Prefer generic ramdisk copy of snapuserd
  Install snapuserd.ramdisk with a separate path
2022-05-25 15:39:17 +00:00