We may have snapshot files in /metadata/ota/snapshot/ which ends with
.tmp such as system_a.tmp - This happens if the device
reboots just before `rename` in `WriteStringToFileAtomic`. This
can lead to spurious merge failures.
Log the error and skip these snapshot files. It is ok to skip
as we will still have original snapshot status files since
we are already in the merge path. Additionally, try to remove
these files when snapshot is deleted.
Bug: 292198189
Test: OTA
Change-Id: I5db3dbd5a919b263ae577185de3e7f79a5e9b89a
Signed-off-by: Akilesh Kailash <akailash@google.com>
This greatly reduces the runtime of snapuserd_test, from 4 minutes to
about 1.5 minutes.
Bug: 269361087
Test: snapuserd_test
Change-Id: Ic18443d4e4318f6ef6adadeabd47ccceeeb19b6f
These tests are for real bugs that were previously not testable.
Bug: 288273605
Test: snapuserd_test
Change-Id: I9e9af999e4f5f988f4538750eba109f6b2fe448c
This adds an implementation of ITestHarness suitable for running tests
on the host. IUserDevice and ProcessRequests are implemented just enough
for shutdown of ReadWorker to work. Most snapuserd tests are focused on
merging, and do not need a ReadWorker accepting requests.
Bug: 288273605
Test: snapuserd_test
Change-Id: I00cf6ec941fb6423290f7a299e5321adea7d8919
Placing temporary files in the executable dir creates unexpected files
in the build dir when running on the host, which linger if snapuserd
crashes.
Bug: 288273605
Test: snapuserd_test
Change-Id: Ia1ea4ba70b645a9d2f49419b91003bc62fb03cb2
This factors a lighter weight class out of SnapuserdTest, so we can
construct tests without needing a HandlerManager/daemon.
Bug: 288273605
Test: snapuserd_test
Change-Id: Ib33dc593a5b3d3df86853e73f245918ef36fd9fa
snapuserd_test in general doesn't propagate errors, which means the
first failure will cascade into many failures. This can make it harder
to figure out what's going on.
Unfortunately error propagation is difficult with gtest, since bool
returns don't work with ASSERT_EQ and Android doesn't use exceptions.
Use ASSERT_NO_FATAL_FAILURE for now, since that is the least invasive
change.
Bug: 288273605
Test: snapuserd_test
Change-Id: I6550682fd63602bc15649f705def2915f6329357
Adds calls to pthread_setname_np for each thread.
Clarify error messages from io_uring calls that return -errno.
Add log messages for some failure paths that didn't have any.
Add an ostream overload for MERGE_IO_TRANSITION, and add an INVALID
state for initialization.
Bug: 288273605
Test: builds
Change-Id: Ic0681cbf0017af67bcf52b98db184a9b48752faf
When HandlerManager shuts down, the monitor thread is left detached. The
monitor thread does not hold a shared_ptr reference to the
HandlerManager, so the pointer can be left dangling.
Fix this by not detaching the monitor merge thread.
This patch also changes the test harness to destroy
SnapshotHandlerManager on "shutdown", to avoid state leaking into the
next instance of snapuserd.
Bug: 288273605
Test: snapuserd_test
Change-Id: Iaaf96a37657c85cff4d2a8b15ccfde4aa03d3220
LoopDevice requires root, which is an obstacle to running this test in
automation. The test also requires memfd which is not available in our
included glibc. Create an IBackingDevice layer so we can use temporary
files instead on host tests, while keeping the block-device code for
on-device tests, which more closely matches how snapuserd runs.
Bug: 288273605
Test: snapuserd_test
Change-Id: I89b154921b6bbcf8fe213ef7f5c4da4d48322909
Since we're adding compression levels should consolidate this
information into one structure. Adding in CowCompression struct
to hold this information and refactoring code to work off this struct
Test: ota
Change-Id: I969a3ae19ec80fd964bcfb76b39f42f8dd31a56d
This allows disabling the code in host builds, since settid() isn't
available in the glibc prebuilt.
Bug: 288273605
Test: snapuserd_test
Change-Id: Ifddb5cb8b04484a1ab0a29794d65c9839759a919
This patch adds an abstraction layer around Tempdevice (which wraps
device-mapper), and a layer to replace hardcoding of DmUserBlockServer.
The only implementation of the new layer, currently, is for dm-user.
However this will allow the harness to run with a backend chosen at
runtime, making testing on the host or of ublk much easier.
Bug: 288273605
Test: snapuserd_test
Change-Id: I8735ef6c373f3e5c5cdf3df461668ddd8e551f63
To avoid SnapshotHandler hardcoding specifics about dm-user, this patch
adds a factory interface, responsible for providing IBlockServerOpener
objects.
The test harness will use this to facilitate dm-user-less testing on
host devices.
Bug: 288273605
Test: snapuserd_test
Change-Id: Ifd33c28ee7076f30a8a90f745353893188f97a08
BufferSink is not needed/used in all worker types, so move it explicitly
to MergeWorker. This also moves the sizeof(dm_user_header) computation
to BufferSink::Initialize.
Bug: 288273605
Test: snapuserd_test
Change-Id: I8fcea6f0e587ca6d8672df5ec58c4d4d14d4b72e
This adds the planned interface that will abstract around dm-user (for
now), and later ublk at which point it can be adjusted as needed.
This declares the interface and implements it, but does not yet switch
snapuserd to use it. The implementation is copied from read_worker.cpp.
Bug: 288273605
Test: snapuserd_test
Change-Id: I060788c91dba78e52d315b5616b84b37eaf4040f
Calling this in snapuserd_core fails when the base path is a regular
file. Since the value is only read once, just call it from
snapuserd_server instead, which also means we don't have to add an
S_ISBLK check here.
Bug: 288273605
Test: snapuserd_test
Change-Id: Ic26bf807b24611f2d97829d1b4eb1d0ede2feb6a
The only function we use from libfs_mgr is WaitForFile, so factor that
out into libfs_mgr_file_wait. libfs_mgr has too much dependence on AOSP
internals to build on the host.
Bug: 288273605
Test: builds
Change-Id: I8e5eb4075ae01b9ca64074422171a487179e7943
We don't need this on the host, since the host will not be running
snapuserd as a server. Rename it for clarity and remove it where we can.
Bug: 288273605
Test: snapuserd_test
Change-Id: I679ef668a89411c670fea8d3b758bde589623548
Right now there are two bootconfig parsers that gets linked into `init`.
One is from libinit itself and the other is from libfs_mgr.
The one in libinit removes all space characters between list elements,
so `key = "val1", "val2"` gets unquoted and squeezed into:
`key=val1,val2`
The one in libfs_mgr doesn't remove spaces, it only unquotes:
`key=val1, val2`
The libinit behavior is due to existing systems (such as sysprop)
expect the config value to be in the same format as kernel cmdline.
(aosp/1757971)
THe libfs_mgr behavior is due to the `androidboot.boot_device[s]`
format explicitly allows quoted comma appear in its list value, thus
relies on space, not comma, as the list value delimeter.
This commit merges the two parsers into libfs_mgr. Since all usages in
libfs_mgr besides `boot_device[s]` do not care about how list value are
delimited, and most usages in init expects the bootconfig value format
to be the same format as cmdline. We just special case the
`boot_device` scenario.
Also harden the test cases to cover all the different config value
format and expected result.
Note:
The format of kernel bootconfig is described here
https://docs.kernel.org/admin-guide/bootconfig.html
Bug: 293695109
Test: CtsFsMgrTestCases
Change-Id: I42b9bf626e8de38a60e8e09fac0693126b7efd91
This will cut down on the binary sizes of update_engine, snapshotctl,
and lpdumpd.
Bug: 291688516
Test: treehugger
Change-Id: Idae5ea075ab21c2bd4fdb839eb065d865cb07d58
init and libfs_mgr both defines get_android_dt_dir() with subtle
differences. Merge the two implementations into libfs_mgr to reduce code
duplication (in terms of source code and code gen)
Note:
init's implementation checks the kernel cmdline first and then the
kernel bootconfig, while libfs_mgr's order is the opposite.
Realistically I don't think this order matter much though. If any, we
should prioritize bootconfig over kernel cmdline most of the time.
Bug: 293695109
Test: Presubmit
Merged-In: Ic8d2c965c62f9e873ccdaf77d67c7708f25a7b56
Change-Id: Ic8d2c965c62f9e873ccdaf77d67c7708f25a7b56
The goal is to make the header definitions of the two curiously
intertwined libraries less chaotic.
After this change, libfstab's header would be self contained. In the
sense that all symbols exported by its headers are defined in its
compilation units.
libfs_mgr would still embed libfstab like before, it can use internal
symbols (symbols not exported by public headers) of libfstab through
the libfstab/fstab_priv.h private header.
Keep include_fstab/ as a symbolic link pointing to its new location.
This is a temporary workaround as there are still some bad build rules
(incorrectly) depending on the old include path with Android.bp
`include_dirs` directive.
Bug: 293695109
Test: build
Change-Id: Ib70a84984ac2cbfca5f5b27fadebf6a16e58146a
We aren't using anything through the removed path.
We also shouldn't use `include_dirs` to begin with, as it bypasses any
build system checks.
Bug: 293695109
Test: build
Change-Id: I06f7450c3ce545aa2583f8c3f8db18c45073f69e
The check result can just return the exact mount flags to use, this
reduces code duplication at the caller's side.
Bug: 293695109
Test: adb-remount-test
Change-Id: I9b5c918968f2494c0c1be3cb8d8e6b527a9c4eb2
It was accidentally moved to the public header when I was previously
refactoring the code. It hasn't caused any harm yet, but we probably
don't want to export this, too.
Bug: 293695109
Test: build
Change-Id: Id81c802cc6cc697c5a4204638aa467966bea1562
Sequence op should contain all ordered ops followed
by Replace and Zero ops. There shouldn't be any non-ordered
ops embedded between ordered ops in the sequence ordering.
Bug: 290159346
Test: inspect_cow <cow_file>, OTA
Change-Id: Ia840340b0e4be07525f216838043bf0265f690c3
Signed-off-by: Akilesh Kailash <akailash@google.com>