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
Merged-In: Idd4c86cd96ef80534681a854ebbe944e324017e0
(cherry picked from commit 1fe962447ca4b082097673ae2d2e65ebe645d64b)
2 files changed
tree: 63729b0522873b6da5ca7415d472528bf8ef8ae5
  1. apexd/
  2. apexer/
  3. proto/
  4. shim/
  5. tests/
  6. CleanSpec.mk
  7. OWNERS
  8. PREUPLOAD.cfg