apexd: Wait for dm-verity device to be deleted
Just calling DeviceMapper::DeleteDevice is not enough, because the
uevents from the kernel to userspace can take a bit of time to get
processed, which can result in the following race condition:
1. On unmount apexd deletes /dev/block/dm-2.
2. Kernel sends "remove" to userspace.
3. On mount apexd creates new device.
4. Kernel reallocates /dev/block/dm-2 and sends "add" to userspace.
5. Userspace process "remove".
6. Apexd tries to mount on /dev/block/dm-2 and fails.
See attached bug for more context.
With this change, apexd will start waiting for the device to be actually
removed during unmount.
For most of scenarios, it shouldn't introduce a boot time regression,
but if apexd for some reason fails to mount an apex from /data
partition, it will now synchronize on corresponding dm-verity device
deletion which might add from XXX milis to X seconds to a boot time.
Test: apexservice_test
Bug: 130013353
Change-Id: Idd4c86cd96ef80534681a854ebbe944e324017e0
2 files changed