Commit graph

241 commits

Author SHA1 Message Date
Jaegeuk Kim
05ca915431 fs_mgr: add readahead_size_kb in fstab
This patch adds an option, readahead_size_kb in fstab entry option. It supports
to set a proper readahead_size per block/dm devices before using them by mount,
which is useful for low/high-end devices when addressing memory pressure issue.

Bug: 181567573
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: I549962e68f8488417d76bcfb283958bc33fd5d7a
2021-04-09 04:54:11 +00:00
Devin Moore
20b74257a6 fs_mgr: handle more bootconfig parameters
As parameters are moved from kernel cmdline to bootconfig,
fs_mgr needs to be updated to handle the new location.
/proc/bootconfig should be checked first, if not present, then check
/proc/cmdline.

Test: atest CtsFsMgrTestCases
Test: launch_cvd
Test: launch_cvd with 4.19 kernel artifacts that do not support
bootconfig
Test: Both of the above configurations with --num_instances 0 or 4
Test: Both configurations with androidboot.boot_devices or
androidboot.boot_device set
Bug: 173815685

Change-Id: I23fb07a17c25c9459833cb931ced79d5ccc3e42a
2021-03-05 09:21:19 -08:00
Tianjie
327237d13a Set hashtree algorithm for verity partitions
This is used in cts tests to verify that algorithms in blocklist aren't
used to build the hashtree. The system properties are required to perform
the check on unrooted devices.

Bug: 175236047
Test: flash, getprop; atest CtsNativeVerifiedBootTestCases

Change-Id: I2dcfdb06f85dbe92cde45e836dd68e7bd835020f
2021-01-20 19:02:34 -08:00
Jaegeuk Kim
a7635718c4 Pass wiped and fs_type to vold to format encrypted partition
Bug: 172378121
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: I358380fc47fe9d4d75337323c772ca1af122d2c6
2020-12-29 11:13:35 -08:00
Tom Cherry
a7f1a9fec8 fs_mgr: move mkdir(mount_point) to prepare_fs_for_mount()
prepare_fs_for_mount() attempts to mount() the block device at the
mount_point, so it must be created beforehand, as opposed to later in
__mount() where it is done now.

Also fix slight bugs with using fstab.mount_point instead of an
alternative specified mount_point.

Test: boot
Change-Id: I758b6a6efe2dd99433fc1974b69cb6f7ce3bc0c2
2020-11-19 11:41:09 -08:00
Qilin Tan
12d95df367 Store result of mount_all for mounted userdata by metadata encryption
When the userdata is mounted, its result will be stored and return.
But the result is not stored when the userdata is mounted with
metadata encryption. Store the result of metadata encryption mount.

Bug: 172180818
Test: run cts-on-gsi -m CtsUserspaceRebootHostSideTestCases
Change-Id: I88b1b4f6a2b1ed81773e18243cb6c46244dc1ba5
2020-11-02 05:27:11 +00:00
Yongqin Liu
c007c43335 fs_mgr.cpp: fix the problem that the casefold feature not enabled for the data partition
The value of entry.mount_point for data partition is "/data"

Fixes: 5ba5b90cd6 ("fs_mgr: try tune2fs for casefolding on /data only")

Test: got "Can't mount with encoding and encryption" problem reported
      by the db845c build with the default 5.4.38 prebuilt kernel

Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
Change-Id: I226a2275f5f2ee18503c5a3863ef5a1d2c2ed7be
2020-10-23 13:34:49 +08:00
Nikita Ioffe
4e311d69b5 Merge "Only store result of mount_all that mounted userdata" am: edc501d674
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1420053

Change-Id: I444f74692633b2bc4f5bcf03cd036b5c52b120aa
2020-09-08 23:10:11 +00:00
Nikita Ioffe
9ede7ec273 Only store result of mount_all that mounted userdata
During boot sequence there can be multiple calls to mount_all. For the
userspace reboot to correctly remount userdata, we need to store the
return code of the one that was responsible in mounting userdata.

Test: adb root
Test: adb shell setprop init.userspace_reboot.is_supported 1
Test: adb reboot userspace
Test: checked dmsg
Bug: 166353152
Change-Id: Id0ae15f3bcf65fa54e4e72b76f64716c053af7fb
2020-09-08 21:58:43 +01:00
Xin Li
0a112d52f8 Merge Android R (rvc-dev-plus-aosp-without-vendor@6692709)
Bug: 166295507
Merged-In: Id18cb0e2d2f3e776a42b566c4a1af2e250890896
Change-Id: Iba7cab32ab3aa6f47952c840ff6dc8492e8d0704
2020-08-29 01:42:13 -07:00
Paul Crowley
5350746a2b Merge "Set ro.crypto.type even on failure" 2020-08-17 20:14:25 +00:00
Jaegeuk Kim
5ba5b90cd6 fs_mgr: try tune2fs for casefolding on /data only
Bug: 163420666
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: Id646bd25d6fed0f547fb0647150acdc4845a5eec
2020-08-14 12:57:25 -07:00
Paul Crowley
9acab5a4d6 Set ro.crypto.type even on failure
Move responsibility for setting ro.crypto.type into fs_mgr_mount_all,
so that even if setting up the filesystem fails, the type is set
correctly and so errors are appropriately handled.

Bug: 162289984
Test: simulate a failure and check that it's set.
Change-Id: Ib061a454e7e21d7206c3c1fa8e88e16618099581
2020-08-14 11:36:39 -07:00
Eric Biggers
75ebdd9c7c fs_mgr: use __ANDROID_API_Q__ instead of pre_gki_level
The name "pre_gki_level" is causing some confusion because not all
devices launching with Android R are subject to the GKI requirement.
(See b/161563110#comment11.)  E.g., devices that use a 4.14-based kernel
are exempt from GKI.  However, the encryption requirements still apply.

Just use __ANDROID_API_Q__ directly instead.

No change in behavior.

Change-Id: I4242745ccc9f88e084a1adfab5796daa9bc59b6e
2020-08-10 11:43:52 -07:00
Eric Biggers
dc3e897a88 fs_mgr: Revert "Try to recover corrupted ext4 /data with backup superblock"
This reverts commit 72abd7b246
(change Ia39af3340c0e241f62557b7c2cc8b800443342f9).

When vold enables either FDE or metadata encryption, it encrypts the
filesystem in-place.  Unfortunately, due to a bug, for ext4 filesystems
it hasn't been encrypting the backup superblocks.

Also, in read_ext4_superblock(), the check for
StartsWith(blk_device, "/dev/block/dm-") can return true even if the
encryption mapping hasn't been added yet, since when a GSI image is
booted the userdata block device is a logical volume using dm-linear.

The result is that read_ext4_superblock() can recognize a backup
superblock when the encryption mapping hasn't been added yet, causing
e2fsck to run without the encryption mapping and corrupt the filesystem.

https://android-review.googlesource.com/c/platform/system/vold/+/1385029
will fix this for new or factory-reset devices.  However, there probably
are many existing devices that already have their backup superblocks
unencrypted.  Therefore, the EncryptInPlace fix isn't enough and we have
to revert the change that started using the backup superblocks too.

Bug: 161871210
Bug: 162479411
Change-Id: I279f84c072bc6c8d3e251a5e95c78f8d6c0d50ba
2020-08-04 11:34:30 -07:00
Tom Cherry
2d451663be Cleanup for #inclusivefixit.
Test: build
Change-Id: If11a32c130367560394eccf442de95d941918073
2020-07-27 11:37:19 -07:00
Paul Lawrence
e526996b31 Merge "Don't call block checkpoint functions above dm-default-key" am: 73cab78084 am: d4ddb09f6f
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1330935

Change-Id: I3743bb24e63e3e3b3425004a7dea39b4da9434da
2020-06-18 22:16:14 +00:00
Paul Lawrence
73cab78084 Merge "Don't call block checkpoint functions above dm-default-key" 2020-06-18 21:56:10 +00:00
Tom Cherry
2d66971a8e Merge "fsmgr: fix integer overflow in fs_mgr" am: be42841c61 am: 36d60f5581
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1335698

Change-Id: I983248e8cb987130f4515fcb62052deb74e62a67
2020-06-16 17:13:30 +00:00
Haoran.Wang
4a489450f4 fsmgr: fix integer overflow in fs_mgr
As the EXT4_MAX_BLOCK_SIZE defined as 65536 which reached maxium value
of unsigned int. The superblock value maybe larger than 65536. This is
found by the Integer Overflow Sanitizer.

This patch fixed below boot error when userdata is corrupted:
init: processing action (fs) from
(/vendor/etc/init/hw/init.freescale.rc:221)
init: [libfs_mgr]Invalid ext4 superblock on '/dev/block/by-name/userdata'
init: InitFatalReboot: signal 6 init: #00 pc 00000000000af7e8  /system/bin/init
(android::init::InitFatalReboot(int)+208) init: #01 pc 00000000000afbd0  /system/bin/init
(android::init::InstallRebootSignalHandlers()::$_22::__invoke(int)+32)
init: #02 pc 00000000000006bc  [vdso:0000ffff9691b000] (__kernel_rt_sigreturn)
init: #03 pc 000000000004e070  /system/lib64/bootstrap/libc.so (abort+176)
init: #04 pc 000000000003427c  /system/lib64/libfs_mgr.so
(read_ext4_superblock(std::__1::basic_string<char, std::__1::char_
traits<char>, std::__1::allocator<char> > const&,
android::fs_mgr::FstabEntry const&, ext4_super_block*, int*)+1804)

Test: boot with corrupted ext4 superblock

Change-Id: I58ed723afa9975d0e93f96fad7c55465e68b3edd
Signed-off-by: Haoran.Wang <elven.wang@nxp.com>
2020-06-16 15:54:37 +08:00
Paul Lawrence
2055364f83 Don't call block checkpoint functions above dm-default-key
Bug: 156225476
Test: Build for f2fs and ext4 device, make sure checkpoints roll back
and commit

Change-Id: I7a772ff712dec9e69df175de840d69d296c65923
2020-06-12 16:15:18 +00:00
Randall Huang
f7228a8565 Merge "Try to recover corrupted ext4 /data with backup superblock" am: 78e0d064c7 am: 86ee5c700f
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1318221

Change-Id: Ieb89e7274d772962fe37927dcd62567dd5aa4657
2020-06-12 00:07:53 +00:00
Randall Huang
72abd7b246 Try to recover corrupted ext4 /data with backup superblock
If the superblock of /data is corrupted, fs_mgr would skip check_fs.
But, e2fsck actually may reference backup superblock to recover
the filesystem. This fix gives fs_mgr second chance to fix corrupted
ext4 /data.

Bug: 156200421
Test: boot with corrupted ext4 superblock

Signed-off-by: Randall Huang <huangrandall@google.com>
Change-Id: Ia39af3340c0e241f62557b7c2cc8b800443342f9
2020-06-11 14:04:47 +08:00
Tom Cherry
3980045200 Merge "Adding wait for a device file before mount" am: bd742a15ab am: d5401ddf61
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1322740

Change-Id: I4b9bc13ed99479c44142fad933d697a980c64484
2020-06-09 17:02:40 +00:00
Tom Cherry
bd742a15ab Merge "Adding wait for a device file before mount" 2020-06-09 16:36:42 +00:00
Paul Lawrence
1f777797bc Merge "Set block size in dm-bow" am: 2709331f90 am: 2ecb203992
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1322011

Change-Id: I3b35a082f346c26e53930fd30470d4045e116d49
2020-06-08 17:41:11 +00:00
Paul Lawrence
2709331f90 Merge "Set block size in dm-bow" 2020-06-08 17:07:36 +00:00
Paul Lawrence
2f0c6cb0f7 Set block size in dm-bow
Fix block-level checkpointing to work correctly when used in combination with
512 byte hardware sectors and metadata encryption with dm-default-key v2.

Bug: 153512828
Test: Parameter is passed to dm-bow based on first_api_level
Change-Id: Ic0a071221559271db20b06b2f17459b5b041e02d
2020-06-05 07:47:45 -07:00
Will Shiu
589b7dfd83 Adding wait for a device file before mount
Adding the function, fs_mgr_wait_for_file(), to ensure the
device file exists before to mount

Bug: 154278078
Change-Id: I74a68224073932773be18a79f9334d83ea5b6947
2020-06-04 11:32:33 +08:00
Treehugger Robot
46ace3b399 Merge "emmc_optimized means stable_inodes" am: eb3be2e28f am: 04c09d39cf
Change-Id: Ibe6ce706d256424eb3aae260c6ce7c38da124450
2020-05-21 20:25:19 +00:00
Paul Crowley
c2f37683bc emmc_optimized means stable_inodes
If the emmc_optimized filesystem flag is set, then like
inlinecrypt_optimized, we have to ensure that stable_inodes is set
on the filesystem.

Bug: 144046242
Test: Cuttlefish, ext4: set the flag in fstab, check for the
    stable_inodes flag using tunefs -l
Change-Id: Id7f906564457c240ddf6677dd536698881385385
2020-05-21 11:14:05 -07:00
Nikita Ioffe
59709d441f Merge "PrepareZramBackingDevice: use loop_control.h" into rvc-dev am: f42f972130
Change-Id: I3d07a0a0fc4e870ad261234815f3d38b9834d808
2020-04-20 20:21:27 +00:00
Nikita Ioffe
bcaeb70d80 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
Merged-In: If80f18c8c337210030a6caf2aec6f7a47472b6fb
(cherry picked from commit c8313adf88)
2020-04-20 21:08:25 +01: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
Martijn Coenen
633735fca6 Merge "Rename external storage properties." am: f0122aa14d am: 7dcfb7eaaa
Change-Id: Ibb3965268743cfd21317bc75967688f40e0c97af
2020-04-16 08:35:08 +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
Martijn Coenen
ea751d94dd Rename external storage properties.
According to property naming guidelines.

Bug: 152170470
Bug: 153525566
Test: N/A
Change-Id: Ia5ce2a95e43724f8d0a7abf6782bc177dedb18a8
2020-04-15 17:32:28 +02: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
Nikita Ioffe
7dcdb5797b Merge "get_mounted_entry_for_userdata: Realpath block devices from fstabs" am: 74429fc121 am: 2b45a4ef85
Change-Id: Ie3b02e6cf06f47cd49d39f65b972235b8ee921d2
2020-04-07 12:27:45 +00:00
Nikita Ioffe
7aa37f1f21 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
2020-04-07 00:39:19 +01: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
Nikita Ioffe
574b3f94d0 Merge "Use properties for various userspace reboot timeouts" am: fc51af215b am: 196ec23ffe
Change-Id: Id6bfbc232ccb2fb7e3059425ca419549c1b114da
2020-03-25 20:44:12 +00:00
Nikita Ioffe
7b41a1558d Use properties for various userspace reboot timeouts
Test: adb reboot userspace
Bug: 146560409
Change-Id: I435e4f93a8769ff7d30cf781e0b48fa3e96121ef
2020-03-25 17:46:13 +00:00
Automerger Merge Worker
5377188a43 Merge "Set GC threshold when mounting with checkpointing" into rvc-dev am: 9cfc622cb2
Change-Id: I0de0e72cb4ae834c28f54f21f1f8a7fa73ab3833
2020-03-14 00:25:44 +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
Automerger Merge Worker
5eb1d36d87 Merge "fs_mgr_get_mounted_entry_for_userdata: handle logical partitions" into rvc-dev am: ccb0608a32
Change-Id: I3db58f6e096b934c7d5e9b05959e40a29451c46e
2020-03-11 20:08:57 +00:00
Nikita Ioffe
17824f0590 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
Merged-In: I1bb3e64ae92d56de905b4f7f1997b7499b101b0f
(cherry picked from commit f495fe798b)
2020-03-11 19:21:37 +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
Automerger Merge Worker
525602c45c Merge "Move GetMountedEntryForUserdata to fs_mgr.h" into rvc-dev am: bbbd1a8e41
Change-Id: I7e16a12e06656526d40b21c500dc7e6f5f9b0ae2
2020-03-06 19:58:35 +00:00
Nikita Ioffe
30b0c01dd8 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
Merged-In: If0f8a765dba63adb0e6a711eb81fffdcabea3480
(cherry picked from commit 8f50cfc28d)
2020-03-06 19:50:10 +00:00