Commit Graph

1593 Commits

Author SHA1 Message Date
Nikita Ioffe f630d552e7 Merge "Make remount into checkpointing for ext4 userdata a no-op" am: dbee3618be am: 770d11fa2d
am: 34914680e9

Change-Id: I5dfc9348d2e67493cc0b039e15ed05590c83790b
2019-11-06 19:19:29 -08:00
Nikita Ioffe 42697d3f18 Make remount into checkpointing for ext4 userdata a no-op
We are going to teamfood userspace reboot soon, and in order to gather
as much data as possible we are fine with ignoring checkpointing for the
devices with ext4 (teamfood will be a very limited set of people that
are aware what they've signed for).

As result of this, we don't need to reset vold and kill zram backing
device. Added a TODO to restore that functionality if needed.

Since I was there, fixed yet another typo in userspace-reboot-resume -_-

Bug: 135984674
Test: adb reboot userspace
Change-Id: I2b7a93aaf738fe9bec9d606d7e11aefb325550b1
2019-11-06 20:12:08 +00:00
Yifan Hong 09fb30b761 Merge changes from topic "libsnapshot_flash" am: 50e102c51d am: a0c8b87080
am: b4df46410d

Change-Id: Ifd2aa5679f1ee374072b951a5f5539d9289c9cd7
2019-11-04 19:22:21 -08:00
Yifan Hong ace7795804 libsnapshot: Fix MergeCannotRemoveCow
The test is broken because now ProcessUpdateState
checks UPDATED flag as well, and partition "test-snapshot"
does not exist in super partition metadata.

Rewrite the test to mimic the update flow and use
as many public APIs as possible.

Test: libsnapshot_test
Bug: 143551390

Change-Id: I105bad8bb589616b304c511c64be902d4297bda7
2019-10-31 18:40:46 -07:00
Yifan Hong 46002d5c21 libsnapshot: fix re-flash after update
If device takes an update from slot A to
B, immediately flashes the B slot, and reboot
into B slot, libsnapshot incorrectly considers
the device booted into the new slot and refuses
to clear update states. Fix this by checking
the UPDATED flag in super partition metadata.

Test: libsnapshot_test
Bug: 143551390
Change-Id: I3cd7bb19b394da6399d4bf2f9d013bfaa7f186f1
2019-10-31 18:40:46 -07:00
Yifan Hong 4913d7af12 [REFACTOR] libsnapshot: Add InitiateMergeAndWait
Move snapshot_ctl's merge command to SnapshotManager::
InitiateMergeAndWait function so that tests can use
it too.

Test: libsnapshot_test
Bug: 143551390

Change-Id: I0936c262afaca7ba445ee18465dca4e16b9416ad
2019-10-31 17:06:28 -07:00
Alessio Balsini 4b8100d248 Merge "COW device initialized by zeroing the whole first chunk" am: e88b568442 am: 4b2d972365
am: 0171278c0a

Change-Id: I0e4e2e5dbd72ddcfa6122d21fa274b7b083d1a0b
2019-10-31 04:45:30 -07:00
Treehugger Robot e88b568442 Merge "COW device initialized by zeroing the whole first chunk" 2019-10-31 11:19:56 +00:00
Paul Crowley 59ac9441ec Merge "fs_mgr: Add stable_inodes flag to encrypted ext4" am: 7df60cee92 am: 955d6cbe2a
am: 271e0df140

Change-Id: I6f0a2921a6cc920776abd1a1a69cfdcb4d236daf
2019-10-30 20:44:38 -07:00
Paul Crowley 7df60cee92 Merge "fs_mgr: Add stable_inodes flag to encrypted ext4" 2019-10-31 03:17:23 +00:00
Paul Crowley 7160fc1139 fs_mgr: Add stable_inodes flag to encrypted ext4
Also put libfscrypt into fs_mgr via whole_static_libs
since it's now a dependency.

Bug: 143307095
Test: we can use the inline policy on it
Change-Id: I82d7d5330abef76ce82accea25d2663748e87a8b
2019-10-30 13:35:48 -07:00
Alessio Balsini 3ab9f1f85b COW device initialized by zeroing the whole first chunk
To be compliant with lvm, instead of just zeroing the first 32 bit of
the COW device, force to zero the whole first chunk.
Also switch to std::vector to store the zeroes, reducing the stack
growth.

Test: libsnapshot_test
Bug: 139202197
Change-Id: I2d98549528a222d6c27bb566c68477b5ec3add20
Signed-off-by: Alessio Balsini <balsini@google.com>
2019-10-30 17:50:59 +00:00
Daniel Norman e348fd24c7 Merge "Fixes typos for adb shell stop/start." am: 9786fbb9d3 am: 6c54d3cabc
am: 0e85bf7a06

Change-Id: I813f711504c1dda84ae6d8d2119c5cf4e7fad8f1
2019-10-29 19:26:17 -07:00
Treehugger Robot 9786fbb9d3 Merge "Fixes typos for adb shell stop/start." 2019-10-30 01:54:51 +00:00
Daniel Norman 7171458a30 Fixes typos for adb shell stop/start.
Test: n/a
Change-Id: Idaad0bfbf3c9d3fd7fc768940746c78528116a13
2019-10-29 11:05:45 -07:00
Alessio Balsini fce40be083 Merge "COW partition creator uses DmSnapshotCowSizeCalculator" am: ff60db1bb1 am: 30bbe85d3e am: 65febbe35c
am: 43d0656c85

Change-Id: I8bb635550d38b1661fdb79a15a8994ef5f6b336b
2019-10-29 04:14:26 -07:00
Nikita Ioffe 4d10d1521e Merge changes I7a3c181a,I72c60ec8 am: 6aa1b01316 am: 03784e1aa5 am: de3e798cc8
am: 4fa5d244f2

Change-Id: Ie10855f857244f65416e860dae05e74500346152
2019-10-29 03:43:03 -07:00
Treehugger Robot ff60db1bb1 Merge "COW partition creator uses DmSnapshotCowSizeCalculator" 2019-10-29 10:42:29 +00:00
Nikita Ioffe 6aa1b01316 Merge changes I7a3c181a,I72c60ec8
* changes:
  Add a test asserting that default fstab has /data entry
  Add fs_mgr_unit_test to CTS
2019-10-29 09:17:04 +00:00
Minchan Kim 59813afdaf Merge "fs_mgr: remove configurable zram backing file path" 2019-10-29 05:13:50 +00:00
Minchan Kim 12e96152ca fs_mgr: remove configurable zram backing file path
Bug: 142795879
Test: zram_loopback_path never change file location.
Test: Setting zram_backingdev_size on fstab turns on zram writeback.
Change-Id: If244e690405eb925270f767a22e4db95cbd8ba8a
Signed-off-by: Minchan Kim <minchan@google.com>
2019-10-28 19:21:35 -07:00
Paul Crowley 51c41e94d9 Merge "fs_mgr: Don't parse encryption options, just keep string" 2019-10-29 02:00:36 +00:00
Treehugger Robot 6b9971c55f Merge "Fixed fs_mgr#fs_mgr_read_fstab_file_proc_mounts test" 2019-10-29 01:01:23 +00:00
Yifan Hong e78ca07631 Merge "fs_mgr: retrofit VAB update after A/B calc COW space." 2019-10-29 00:35:57 +00:00
Yifan Hong 2c74292038 Merge "libsnapshot: Add EnsureMetadataMounted" 2019-10-29 00:35:44 +00:00
Treehugger Robot 85f5a4449c Merge "pragma once for header file" 2019-10-28 21:34:01 +00:00
Paul Crowley 4fa841350f fs_mgr: Don't parse encryption options, just keep string
We now defer parsing encryption options to the fscrypt library. To avoid
adding a dependency, we simply record the options string in the fstab
and defer parsing until it's needed.

Bug: 143307095
Test: cuttlefish still boots
Change-Id: Ied13ea2f731c63b0524aed11db6983a86dab9fa1
2019-10-28 13:41:00 -07:00
Alessio Balsini 14d1394a7e COW partition creator uses DmSnapshotCowSizeCalculator
Instead of using heuristics on the calculation of the COW size, use the
class representing the internal structure of the COW device as generated
by the Linux kernel.
This simplifies the forecast of the required COW device size depending
on the write operations performed on the associated snapshot device.

Created also an additional test case for the COW size calculation.

Change-Id: If147001544988716430b36a4c75dfa7f34b4c8d9
Bug: 140835698
Test: libsnapshot_test
Signed-off-by: Alessio Balsini <balsini@google.com>
2019-10-28 18:59:45 +00:00
Nikita Ioffe 3f334dcaa4 Add a test asserting that default fstab has /data entry
When aosp/1149619 is merged, userspace reboot will start to depend on
the fact that default fstab has an entry for /data, hence this test
to make sure that this is the case.

Bug: 135984674
Test: atest CtsFsMgrTestCases
Change-Id: I7a3c181a6b27a7b4dfc344ff04be712f3fe3376e
2019-10-28 16:47:47 +00:00
Alessio Balsini 70f0be3811 pragma once for header file
Add missing "#pragma once" to header file.

Bug: none
Test: build
Change-Id: I9ea248686dc2affc8ba093c58a2660505f5cc8de
Signed-off-by: Alessio Balsini <balsini@google.com>
2019-10-28 16:38:35 +00:00
Nikita Ioffe 607cbbf1e8 Add fs_mgr_unit_test to CTS
Test: atest --rebuild-module-info CtsFsMgrTestCases
Bug: 135984674
Change-Id: I72c60ec8acdcb3539da091abb4f84e0bc3c6743b
2019-10-28 16:28:02 +00:00
Nikita Ioffe e93b12847f Fixed fs_mgr#fs_mgr_read_fstab_file_proc_mounts test
It was failing with:
Expected equality of these values:
mnt_opts
Which is: { "data=ordered", "discard", "noatime", "nodev", "nosuid", "rw", "seclabel", "sync" }
fs_options
Which is: { "data=ordered", "discard", "noatime", "nodev", "nosuid", "rw", "seclabel" }

Test: atest fs_mgr_unit_test
Change-Id: I3bb084d62e81fda8948a100515bdaad62d18bb54
2019-10-28 14:42:01 +00:00
Yifan Hong 02f2c1b75a fs_mgr: retrofit VAB update after A/B calc COW space.
When applying retrofit VAB update on a regular A/B device,
if device is at version Android R, update_engine may run
a virtual A/B update directly. In this case, partitions
with suffix B in slot 0 (current slot) should not be treated
as unusable space by CoW.

Fixes: 143323939
Test: libsnapshot_test

Change-Id: Ic845374e519885d21e021e97cb32fab9f5d56a63
2019-10-25 15:54:00 -07:00
Yifan Hong d2a0247538 libsnapshot: Add EnsureMetadataMounted
In recovery, client is responsible for calling
EnsureMetadataMounted before doing (almost) all
operations on SnapshotManager, e.g.

- CancelUpdate() before sideloading
- BeginUpdate() on retrofit Virtual A/B before sideloading
- Finishing merge before flashing

Test: libsnapshot_test
Test: recovery sideload
Bug: 140749209
Change-Id: I1034a7fa74e31b6850896e61e86341239dbf2699
2019-10-25 15:37:11 -07:00
Nikita Ioffe 12a36076a7 Userspace reboot: Support remounting userdata for f2fs
Test: adb reboot userspace
Test: adb shell /system/bin/vdc startCheckpoint 1;
      adb reboot userspace
Bug: 135984674
Change-Id: I227f2c1cc18495d893decb2df5173fc7a7919df6
2019-10-25 16:27:10 +01:00
Yifan Hong 81a0738c68 Merge "libsnapshot: Only EnsureImageManager when it is needed." 2019-10-24 21:32:58 +00:00
Treehugger Robot 2c7ae59ede Merge "libsnapshot: MapCowImage returns the COW device path" 2019-10-24 12:15:41 +00:00
Yifan Hong 19b6f5f47e libsnapshot: Only EnsureImageManager when it is needed.
In functions / code paths where images_ is not used,
don't call EnsureImageManager.

Test: libsnapshot_test
Test: sideload on retrofit
Bug: 140749209
Change-Id: I36635e43b8c2e1c22524f8f4685a216d74c71ad7
2019-10-23 19:51:33 -07:00
Treehugger Robot 92155132e2 Merge "libsnapshot_test: Fix loading both the static and dynamic libcrypto libs" 2019-10-21 23:22:53 +00:00
Alessio Balsini 3f88b4e63c libsnapshot_test: Fix loading both the static and dynamic libcrypto libs
libsnapshot_test was depending both directly on libcrypto_static and
indirectly through liblp on libcrypto.  This was causing a failure at
runtime on the sanity check when loading the libcrypto library.
Dropped the dependency on libcrypto_static and switched to the dynamic
libcrypto to fix this violation.

Test: libsnapshot_test
Fixes: 143094706
Change-Id: Iba959e234348f7deb81893c9105a13628ce0eb6e
Signed-off-by: Tobias Thierer <tobiast@google.com>
Signed-off-by: Alessio Balsini <balsini@google.com>
2019-10-21 21:31:39 +00:00
Alessio Balsini d0de1114a9 Fix fuzzer name and sizeof(array)
The fuzzer name "dm_table_fuzzer" was too generic. Looking forward to an
extension to host tests where each fuzzer name should be considered a
unique identifier, change the fuzzer name to, "dm_linear_table_fuzzer".

Fix also the syntax of sizeof(array) declaration.

Bug: none
Test: dm_linear_table_fuzzer
Change-Id: Iaa0ee9a0eb1352f0c5269b07198d0a34d8fb3254
Signed-off-by: Alessio Balsini <balsini@google.com>
2019-10-21 11:44:08 +00:00
David Anderson c243e19936 Merge "Integrate libsnapshot with the boot control HAL." 2019-10-17 19:57:04 +00:00
Treehugger Robot 356951f2be Merge "fs_mgr: vts_core_liblp_test requires root" 2019-10-17 19:55:23 +00:00
Treehugger Robot d8a72367e5 Merge "Utility class for COW size calculation" 2019-10-17 13:55:44 +00:00
Yifan Hong 4fc16610df fs_mgr: vts_core_liblp_test requires root
Test: atest vts_core_liblp_test

Fixes: 141940321
Change-Id: I2d6e06f4e596cdb985ea67e383e38545d666833b
2019-10-16 18:26:40 -07:00
Yifan Hong b4383e144e Merge "liblp: MetadataBuilder::NewForUpdate takes always_keep_source_slot arg" 2019-10-17 00:10:32 +00:00
David Anderson dfe6d07a4b Integrate libsnapshot with the boot control HAL.
This patch translates UpdateState states into a MergeStatus from
IBootControl 1.1, and asks the HAL to store it. Unfortunately this patch
has to work around a few issues.

The first issue is that Soong doesn't allow including only the headers
from a HAL. The second issue is that entraining the headers requires
linking to libraries that would otherwise not be needed in init.

To address this, we now have three ways of linking to libsnapshot:
  1. libsnapshot - Has access to gsid and HALs.
  2. libsnapshot_nobinder - Has access to HALs, but not binder (for
                            recovery).
  3. libsnapshot_init - Does not use binder or HALs.

The HAL code is #ifdef'd behind LIBSNAPSHOT_USE_HAL and we make use of
forward declarations and dependency injection to minimize its spread.

Bug: 139154945
Test: libsnapshot_test gtest
Change-Id: I21ffd8a79a43d0589f2f71f346ac1b019584a183
2019-10-16 16:09:38 -07:00
Alessio Balsini 391086908c libsnapshot: MapCowImage returns the COW device path
When a device is not dm-mapped, the whole path of the newly generated
COW device is required.
This was causing some of the libsnapshot_test cases to fail.
Fix by making MapCowImage() optionally return the COW device path.

Fixes: 142800685
Test: libsnapshot_test
Change-Id: I9570b4254d47b2d8fc942053590a320dcb20f7d5
Signed-off-by: Alessio Balsini <balsini@google.com>
2019-10-16 21:01:58 +01:00
Alessio Balsini 0355d22d64 Use ReadFileToString() in GetHash()
On some devices the previous implementation of GetHash() was failing at
reading files, returning "Bad file descriptor" error.
Using ReadFileToString() that seems to have fixed the issue.

Test: libsnapshot_test
Change-Id: Ie3598d8bad5b3db1cf816c120e6922a066aa2743
Signed-off-by: Alessio Balsini <balsini@google.com>
2019-10-15 18:55:10 +01:00
Alessio Balsini a6e3d497ae Utility class for COW size calculation
The Linux kernel's dm-snapshot relies on a COW device to keep trace of
all the modified sectors.
The COW device has a precise structure, which allows to compute its
space requirement in advance, as a function of:
- sector size;
- chunk size;
- list of modifications applied to the snapshot device.

Create a class that implements the COW device space occupancy given this
information.

Bug: 140835698
Test: libsnapshot_test
Change-Id: I50e3815741ee689d14fc3611532ff9d3b3e0e879
Signed-off-by: Alessio Balsini <balsini@google.com>
2019-10-15 13:06:48 +01:00