udev: requeue event when the corresponding block device is locked by another process
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 15 Mar 2022 04:50:06 +0000 (13:50 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 25 Mar 2022 01:28:03 +0000 (10:28 +0900)
commit5d354e525a56955ae7f68062e283dda85ab07794
treef78541c20b348fa66d2fd681888a552af9e0951d
parent0c3d8182c997c979c7a0ccce88d9fc48638261a5
udev: requeue event when the corresponding block device is locked by another process

Previously, if a block device is locked by another process, then the
corresponding worker skip to process the corresponding event, and does
not broadcast the uevent to libudev listners. This causes several issues:

- During a period of a device being locked by a process, if a user trigger
  an event with `udevadm trigger --settle`, then it never returned.

- When there is a delay between close and unlock in a process, then the
  synthesized events triggered by inotify may not be processed. This can
  happens easily by wrapping mkfs with flock. This causes severe issues
  e.g. new devlinks are not created, or old devlinks are not removed.

This commit makes events are requeued with a tiny delay when the corresponding
block devices are locked by other processes. With this way, the triggered
uevent may be delayed but is always processed by udevd. Hence, the above
issues can be solved. Also, it is not necessary to watch a block device
unconditionally when it is already locked. Hence, the logic is dropped.
src/udev/udevd.c