Commit graph

3052 commits

Author SHA1 Message Date
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
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
David Anderson
7397fa566f Merge "Rectify Boottime property" 2022-05-24 22:19:29 +00:00
Akilesh Kailash
fc9a48f5cb libsnapshot: Initialize merge_op_start_ to zero.
merge_op_start_ is used to set the iterator for merge operations.
Uninitialized value can potentially lead to setting up
of bad iterator.

Bug: 233246309
Test: Full OTA
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: I3cc48a66b532cfe8b2d87c8724d77ab3169a2ddb
2022-05-19 20:06:07 +00:00
liyong
ed88361e6c logwrap_fork_execvp block recovery auto reboot
Bug:231647359
Test:call ensure_path_mounted("/data") in WipeData function in recovery then factory reset

Change-Id: Ia5b669319776fae9478534484e3993c15fe4e6bf
2022-05-13 11:15:11 -07:00
Kelvin Zhang
8acf164d70 Install snapuserd.ramdisk with a separate path
Test: th
Bug: 2095786

Change-Id: Ib51713277f1b56d3dc6b2c2dac6db1b6346ef15f
2022-05-11 13:57:02 -07:00
Florian Mayer
1e7af8d975 Promote HWASan tests to presubmit.
They have been passing and do not show significant slowdown.

Change-Id: If3aea998fcf33559824cf02e9963e8a71ac80163
2022-05-06 19:14:15 +00:00
Jaegeuk Kim
3aca50cb9e Support /dev/fscklogs/log in f2fs back
We need to fix the below error happening in early stage.

[   24.835617][    T1] init: [libfs_mgr]Running /system/bin/fsck.f2fs -a -c 10000 --debug-cache /dev/block/sda1
[   24.843693][    T1] logwrapper: Cannot log to file /dev/fscklogs/log

Bug: 230637147
Bug: 230879192
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: I19bc5f7154577e29414f855de6ce72172b281975
2022-05-02 15:06:43 -07:00
Automerger Merge Worker
92c83b3d47 Merge "Merge "Merge "resolve merge conflicts of 21ef3ae3fd to android11-tests-dev" into android11-tests-dev am: bdf02cc54d" into android12-tests-dev am: fdca6ffb38" into android12L-tests-dev am: c1a6b27d21
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1726290

Change-Id: I5988f66d41af54127829baa6edb3a3217a99e583
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-21 01:12:53 +00:00
Automerger Merge Worker
6a5ac60cce Merge "Merge "resolve merge conflicts of 21ef3ae3fd to android11-tests-dev" into android11-tests-dev am: bdf02cc54d" into android12-tests-dev am: fdca6ffb38
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1726290

Change-Id: I839da4bee076444d4e679a26c0bec7e0ea74890a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-21 00:51:47 +00:00
Tim Zimmermann
496132bc99 fs_mgr: Don't assume partitions replaced by DSU are logical already
Test: Boot DSU on a device without dynamic partitions but first_stage_mount for /system

Change-Id: I07f0f40037109aaaf1bce0151d1eac26c971ba9e
2022-04-17 08:22:34 +02:00
Akilesh Kailash
f86fca236f libsnapshot: Remove invalid snapshot metadata
If there are snapshot metadata persisting in /metadata/ota/snapshots,
remove them before applying a new update. Make sure that
the snapshots are indeed invalid before removing them.

On a sidenote, add a comment in init.cpp related to
b/223076262.

Bug: 228250473
Test: 1: Apply OTA in recovery through adb sideload
2: Reboot
3: Apply OTA OTA again through update_device.py
4: Re-run Full OTA updates just from update_device.py

Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: I116bbafae09042b9c391ccd58c102704571c214e
2022-04-16 16:43:35 +00:00
Akilesh Kailash
9fc6ee050f libsnapshot: OTA upgrade when vendor partition is S
In Android S, snapuserd binary was on vendor partition.
When there is an OTA update from S -> T, it is possible
that vendor partitions are not updated. In that case,
successive OTA updates T1 -> T2 will continue to have
snapuserd from Android S as vendor partition wasn't updated
to T. All this means, we should disable user-space snapshots.

When installing OTA during runtime, check for property
ro.vendor.build.version.release_or_codename; if the property
is set to "12", then skip userspace-snapshots.

Bug: 227614163

Test: Simulate OTA test on Pixel 6 from T1 -> T2 by forcefully
setting the property to 12 and verify OTA is applied
successfully by falling back to dm-snapshot.

Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: I95f29145e5cd9ffb8d03d28ae414f0037b88be90
2022-04-05 20:23:14 +00:00
Treehugger Robot
f1df9ba5c4 Merge "vts_libsnapshot_test: Fix free space calculation." 2022-03-23 16:40:20 +00:00
Treehugger Robot
04288337c3 Merge "Rename FstabEntry::metadata_encryption to metadata_encryption_options" 2022-03-19 04:12:05 +00:00
Treehugger Robot
5d2c849c73 Merge "libsnapshot: Fix vts_libsnapshot_test" 2022-03-19 00:14:27 +00:00
Florian Mayer
92c1ef9e97 Add liblp to hwasan-postsubmit
Test: Run tests under HWASan.
Bug: 193568145
Change-Id: I6514e9f170d03ee2d2673d115a9c8337ac6941b0
2022-03-18 21:23:51 +00:00
Akilesh Kailash
44343d4416 libsnapshot: Fix vts_libsnapshot_test
Fix SnapshotUpdateTest.QueryStatusError which
was failing on targets where userspace-snapshots are not
yet enabled.

Bug: 224586316
Test: vts_libsnapshot_test -force_config dmsnap --gtest_filter=SnapshotUpdateTest.QueryStatusError
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: Ibaacff9b03eafe0bfa537d0f9cab98b7caceb37e
2022-03-18 20:11:17 +00:00
David Anderson
15433b93ff vts_libsnapshot_test: Fix free space calculation.
This should be using unreserved free space, not total free space.

Bug: 223701928
Test: vts_libsnapshot_test
Change-Id: Ic0a657fe094b57734c93958d7e5da56fbfbada7f
2022-03-17 20:39:47 -07:00
Eric Biggers
20a5f92a33 Rename FstabEntry::metadata_encryption to metadata_encryption_options
There have been two bugs where people use !metadata_encryption.empty()
to check whether metadata encryption is enabled.  It should actually be
!metadata_key_dir.empty(), since 'metadata_encryption' is the encryption
options, which can be empty if the defaults are sufficient.

Rename the field in FstabEntry appropriately.

To avoid breaking fstab files, don't rename the flag in the fstab file
itself.  So, now the fstab flags map to FstabEntry fields as follows:

    keydirectory => metadata_key_dir
    metadata_encryption => metadata_encryption_options

Change-Id: I5bf673047c99e077bd6e1ac006d80e7e16bc814b
2022-03-17 23:22:50 +00:00
Padmanabha V
ac9f33ceac Rectify Boottime property
__mount gets called multiple times. Set the read-only property only upon
success since it can't be set multiple times. Selinux disallows modifying
read-only property and therefore the property holds a wrong value, the one
when __mount was called first even in case the call failed.

Bug: 224824099
Signed-off-by: Padmanabha V <padmanabha.v@sasken.com>
Change-Id: If2900fcf988b6225bb0f96586b00b97386ca8a81
2022-03-17 11:42:56 +05:30
Akilesh Kailash
6e43216340 Revert "init: Add diagnostics for snapuserd hangs"
This reverts commit 471643a909.

Reason for revert: Given https://r.android.com/1960063, it is safe to revert this diagnostics patch

Change-Id: Ib3600c1982ee10a0204ac0fdbc3e160c2833ed07
2022-03-14 20:49:53 +00:00
Shikha Malhotra
927d9d1c68 Merge "Adding project_id ranges for internal app and cache folders." 2022-03-10 21:58:40 +00:00
David Anderson
b738b7d23a Merge "fs_mgr: Add force_super_partition bootconfig option to avoid slot suffixing alternate super partition names." 2022-03-10 04:42:20 +00:00
Akilesh Kailash
c08037b2c2 If there an error, cqe field is not allocated by io_uring_wait_cqe(); return
the error immediately.

Bug: 223308671
Test: OTA
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: Ib485bb767ad58e6a0849fb2431b563e6e7f04cfd
2022-03-08 06:14:22 +00:00
Yi-yo Chiang
fb81cf765a Merge "fs_mgr: Fix misleading comment text regarding __ANDROID_RECOVERY__" 2022-03-03 06:23:14 +00:00
David Anderson
390851dd29 Merge "fs_mgr: Restrict dt fstabs to < Q devices." 2022-03-03 05:05:19 +00:00
Treehugger Robot
d297b88e3e Merge "inspect_cow: Print OTA ops for debugging" 2022-03-03 03:35:04 +00:00
Treehugger Robot
4618fa3e2a Merge "libsnapshot: Edit OWNERS file" 2022-03-03 03:15:04 +00:00
Akilesh Kailash
d49321a6fc libsnapshot: Edit OWNERS file
Bug: 220991038
Test: Presubmit
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: If1f3529b731fb19193857e4009de42dc081edbf9
2022-03-03 01:18:07 +00:00
David Anderson
0a9c083b87 vts_fs_test: Statically link libfs_mgr.
Bug: 222065493
Test: builds
Change-Id: I9ce4aa2594a4e946c79a51f0ed3d2121c7eaee36
2022-03-01 14:12:26 -08:00
David Anderson
dac0476112 fs_mgr: Add force_super_partition bootconfig option to avoid slot suffixing alternate super partition names.
Bug: 171024225
Test: manual test
Change-Id: I279b8fc6878036b3a3bc767f8d51378a2f795e19
2022-02-28 21:44:36 -08:00