platform_system_core/fs_mgr/libdm
Jiyong Park e09de2a5ca libdm: don't expect uevent for devices that have never been activated
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
2023-06-22 00:43:32 +09:00
..
include/libdm ueventd: Fix a race condition in handling device-mapper events. 2023-05-17 15:52:16 -07:00
Android.bp libdm: Remove dm_linear_fuzzer. 2023-01-24 21:37:18 -08:00
dm.cpp libdm: don't expect uevent for devices that have never been activated 2023-06-22 00:43:32 +09:00
dm_table.cpp Fix the return values of DmTable::valid to match the expected type 2023-05-08 13:26:35 -07:00
dm_target.cpp fs_mgr: support 'check_at_most_once' for dm-verity 2021-05-31 10:43:25 +00:00
dm_test.cpp ueventd: Fix a race condition in handling device-mapper events. 2023-05-17 15:52:16 -07:00
loop_control.cpp adds LO_FLAGS_AUTOCLEAR for loop device of zram backing device 2021-09-26 10:07:50 +08:00
loop_control_test.cpp libdm: Fix race conditions in LoopControl::Attach. 2019-07-11 15:39:53 -07:00
test_util.cpp libdm: Add unit tests for dm-linear. 2018-06-25 12:56:14 -07:00
test_util.h Move TempDevice to test_util.h 2019-10-10 20:59:33 +01:00
utility.cpp libdm: Fix WaitForFile early-returning on failed accesses. 2020-02-26 15:21:53 -08:00
utility.h libdm: add an overload of DeleteDevice accepting a timeout_ms 2019-12-05 10:37:47 +00:00