Previously, libdm ensured that uevent will be generated when a dm device
is deleted. However, there actually are cases where uevent can't be
expected; for example, if an empty dm device is created, but then gets
deleted without being activated, then there should be no uevent upon
deleting because there actually is nothing to remove from /dev. (dm
device gets added to /dev only if it is activated).
Actually such a case exists in apexd. As a performance optimization, it
proactively creates empty dm devices for all APEXes it scanns. But
some of them don't ever get activated if the APEX is already in a
dm-verity protected block device (i.e. the pre-instaled APEX is the
latest one). In that cases, the empty dm devices are deleted at the end
of the boot process as a clean up.
The libdm triggered error during the clean up, because there was no
uevent generated for the empty dm devices. This has triggered a lot of
false alarms to the apex team.
This CL fixes this by ensuring uevent only for activate dm devices. If
the dm device doesn't show up in /dev, we just delete the in-kernel
object and don't expect it to generate uevent for it - which actually is
the kernel's behavior.
Bug: 286176029
Test: build and run aosp_cf_x86_64_phone. observe dmesg.
Before the change:
I apexd : Deleting unused dm device com.android.hardware.core_permissions
E apexd : Didn't generate uevent for [com.android.hardware.core_permissions] removal
W apexd : Failed to delete dm-device com.android.hardware.core_permissions
After the change:
I apexd : Deleting unused dm device com.android.hardware.core_permissions
<no error or warning logs>
Change-Id: I52042de7d4d9ab62e6a13428c32a67e13395d1b5
This only added one real method to ICowWriter, so let's just fold it
into ICowWriter. CompressedSnapshotWriter goes away as well.
CompressedSnapshotReader is now part of libsnapshot_cow.
Bug: 280529365
Test: m otapackage
apply ota
Change-Id: I55358c3c9be111d5aee1a0c22c29cb1539d05494
To support multiple implementations of CowWriter, we will need to move
direct usage of CowWriter to ICowWriter. This CL does this while also
adding some small cleanups:
- Move ICowWriter implementation methods to a new CowWriterBase class.
This keeps ICowWriter as a clean interface.
- Make the "Add" methods pure virtual, move the "Emit" methods to
CowWriterBase as an implementation detail.
- Simplify Initialize/InitializeAppend so they can be shared.
- Rename CowWriter to CowWriterV2.
- Rename cow_writer.cpp to writer_v2.cpp.
- Rename cow_api_test.cpp to test_v2.cpp.
- Remove ICowWriter::options, replace with GetBlockSize.
- Add a CreateCowWriter helper to avoid implementation details in
update_engine.
Bug: 280529365
Test: builds
Change-Id: If50faf03b292c6c8b23a6170e3f37329fb759ff6
Adjust this test to align with VSR. First, skip the test if kernel is
< 5.10 or < Android 13. Second, allow non-dynamic partitions to be vfat.
Bug: 286038059
Test: vts_fs_test on CF
Change-Id: I5bd874f68296f7155d8c4366ebc13fe3d59c3ee6
These tests are still giving us trouble. Move them to libfiemap, which
(1) is closer to the source of implementation, and (2) allows us to
re-use the temporary filesystem code. This won't perturb the state of
the actual device.
The new test creates a 64MB ext4 or f2fs mount point as a sandbox, which
should be much safer.
Bug: 285197715
Test: fiemap_writer_test
Change-Id: I33502d49613be4f269a80e5c632514fc56a0246a
A point of confusion that has been encountered recently is that the
fileencryption argument is optional (since Android 11), yet the fstab
parser requires the equals sign in "fileencryption=". Thus, someone
wanting to use the default options must use "...,fileencryption=,...".
Make "fileencryption" by itself mean the same thing so that it works as
expected.
Test: atest CtsFsMgrTestCases
Change-Id: I65ce6b9513942bec2107838396835e7aafb3bf37
The type of f_frsize is `unsigned long` which is 32 bit for some system so it will overflow after multiplied by f_bfree. This solution adds one more type casting to ensure the type is 64 bit unsigned integer during the computing.
Bug: 281599020
Test: adb root; adb shell disable-verity
Change-Id: I377ed722d5e245c235c3ae12ff66ac7e91d1d6e8
This was never used or tested. The idea was to unify update_engine's
write paths on ISnapshotWriter. But given that legacy VAB is "legacy",
it doesn't make sense to begin refactoring that code and potentially
introducing bugs. Let's just remove this instead.
Bug: 280529365
Test: builds
Change-Id: Ie2f531bd140e183dfde4b65a144f3b4acc28e78a
Remove CowWriter::GetCowVersion. Instead, reject any update that asks
for VABC but has an unsupported version field. Do not fallback to legacy
VAB as the update was likely built improperly.
Bug: 280529365
Test: vts_libsnapshot_test
Change-Id: Ibc0f981801fd47bf39d7a19944134e4b3c66e5bf
This function is never used. It was intended to allow update_engine to
unify all writes through ISnapshotWriter, but that never came to pass.
Bug: 280529365
Test: builds
Change-Id: I7e418ffee404cd63faa5a5659d8971988f8d0e03
Remove format-specific logic from CowReader and split it out into a new
class called CowParserV2. To make reading the header easier, the
version and size bits are now in a separate CowHeaderPrefix struct.
Bug: 280529365
Test: apply OTA on CF
inspect_cow
Change-Id: I29b5617ec094d4fb0c284485883d2e921a5bdbf8
When we changed our ENOSPC tests, it exposed a path in F2FS were
fallocate can return EAGAIN. This is expected if F2FS attempts GC to
acquire more chunks, and it can leave the file in a partially allocated
state.
As a fix, keep attempting fallocate() as long as (1) it returns EAGAIN,
and (2) the allocated size keeps growing. If (2) fails we return ENOSPC.
Bug: N/A
Test: treehugger
Change-Id: I5f867b5a200b9260e486985f203f9872a949b3f9
We've had flake in libdm_test for a long time, with no clear cause.
Lately however it has become particularly reproducible when running
the UeventAfterLoadTable test in isolation, and thus we've identified
the root cause.
uevents for device-mapper are fired when the sysfs node is added, but at
that time, the "dm" subnode has not yet been added. The root node and dm
node are added very close together, so usually it works, but sometimes
ueventd is too fast.
Instead of relying on sysfs, query the uuid/name node directly from
device-mapper.
Bug: 270183812
Test: libdm_test
Change-Id: I258de5de05d813c3cb7f129e82e56dbfe8bf3117
These tests have been a plague of flakiness forever, and while we've
made improvements, the test is fundamentally flaky, and keeps showing up
in presubmit.
This change removes the code that attempts to fill /data until it's
almost full, which is unreliable and destructive. Instead, attempt to
allocate a file that is one block smaller than the maximum file size.
This should always fail with ENOSPC, as opposed to the maximum file size
which would fail with EFBIG.
Bug: N/A
Test: vts_libsnapshot_test
Change-Id: I4652b83e31c50975ddb50b6cbe846e102ba0f322
adb remount clearly indicates that the user will use
a scratch partition to modify RO content. In this CL we're
trying to be more aggressive and take more space from
data to scratch to improve the developers experience.
Bug: 228945443
Test: launch cvd with updated value and check it reflects
Change-Id: Ied9cee6e98d3b2dd594babcf213071a80bd3cf14
Signed-off-by: Dmitrii Merkurev <dimorinny@google.com>
Most callers already converted the reference to a pointer, and pointers
will make it much easier to move around the op list.
Bug: 280529365
Test: builds
Change-Id: I7ec850b58a79c33e57b0e2602e1be953484daa46
Block sizes should not be hardcoded, since the value is set in the
cow header. Move this to snapuserd to isolate use.
Bug: 280529365
Test: builds
Change-Id: I62aa8c7b795f9d258d4b6deb0779a536cba65d52
Clean up the formatting and unit display, and add a line displaying how
long it took to parse the COW.
Example of new output:
Version: 2.0
Header size: 38
Footer size: 84
Block size: 4096
Merge ops: 0
Readahead buffer: 2097152 bytes
Footer: ops usage: 1005680 bytes
Footer: op count: 50284
Parse time: 6.77921ms
Data ops: 50015
Replace ops: 50015
Zero ops: 0
Copy ops: 0
Xor ops: 0
Bug: 280529365
Test: inspect_cow /dev/block/mapper/product_b-cow
Change-Id: Ie8ac02adc004289cc3a08ef44aa3048280a2407f
Done and RDone are not exactly symmetrical, so rename them to match
their underlying STL behavior. Done becomes "AtEnd" and RDone becomes
"AtBegin".
Bug: 280529365
Test: builds
Change-Id: I876f858a7bef84d8b37c1c822fb42941fbcded25
This function cannot fail, so replace it with an infallible version.
This is also slightly more efficient since there's no copying involved.
Bug: 280529365
Test: builds
Change-Id: Iccfd6e72bc2192f4e1efda50cf544e1e956a9263
Temporarily turn off these tests until root cause is found.
Bug: 279009697
Test: presubmit
Change-Id: I90f695fac318b71871ff60c1f74c90265437687d
Signed-off-by: Akilesh Kailash <akailash@google.com>
This added some new failure paths, so the patch also includes an RAII
helper to assist with handling those.
Bug: 278637212
Test: vts_libsnapshot_test
apply ota on CF
Change-Id: Ide59c83cb34b6d448fe9afdc1d15c6139a0c99fa
This introduces a replacement for the IByteSink API, which was never
really used in any advantageous way, and is not expected to be useful.
The new API attempts to fill an entire buffer rather than request
individual slices of a buffer.
This patch simply introduces the API and refactors tests. Subsequent
patches will replace IByteSink callers and remove the API.
Bug: 278637212
Test: cow_api_test
Change-Id: Ib740de5e65fee8d61f603b106752338cc8e95967
These are failing on 6.1 kernels. Disabling them since legacy merges +
6.1 is not a supported combination.
Bug: 279009697
Test: vabc_legacy_tests on 6.1 CF
Change-Id: Iddc86f858e1a0101a7823b79fd0e81e221797f33
PowerTest is no longer relevant with snapuserd, and was not particularly
good at rooting out dm issues anyway.
make_cow_from_ab_ota and estimate_cow_from_nonab_ota are no longer
relevant as they were mainly for estimation during VABC prototyping.
The update_metadata proto was part of the fuzzer which has since been
removed.
Bug: N/A
Test: th builds
Change-Id: Ie341e360f1824ea16794c4625817cfc8f8b8644b