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
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
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
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
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
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>
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
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>
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
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
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
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
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
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>
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>
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
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>
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>
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>