Files
systemd/docs
Lennart Poettering e582484789 tree-wide: open block device locks in writable mode
udev's block device locking protocol has one pitfall not even the
example in the documentation got right so far (even though this is
explained in all detail above): udev's rescanning is only triggered when
an fd that is opened for writing is closed. This means that if a
separate locking fd is opened on a block device – one that is maintained
independently of the fd actually used for writing – it must be opened for
writing too, so that closing the lock definitely triggers a rescan. This
matters in cases where the lock fd is kept for longer than the fd used
for writing to disk. (Because otherwise udev might get the
IN_CLOSE_WRITE event, but when it tries to rescan will find the device
locked, and never retry because no IN_CLOSE_WRITE is triggred anymore.)

Let's fix that across the codebase, at 4 places:

1. in makefs (a lock fd is kept, and mkfs then invoked as child, which
   uses a different fd, and the lock fd is closed only once the child
   died)

2. in udevadm lock (embarassing!): which is intended to be used to wrap tools
   that modify disk contents, very similar to the makefs case. The lock
   is also kept until after the tool exited.

3. In storagetm: the kernel nvme-tcp layer writes to the device
   directly, we just keep a lock fd.

4. the example in BLOCK_DEVICE_LOCKING.md
2025-10-22 22:56:02 +02:00
..
2025-02-17 19:49:32 +00:00
2024-03-27 07:11:54 +01:00
2025-09-27 00:21:53 +09:00
2024-12-28 12:24:42 +09:00
2024-10-17 00:49:59 +09:00
2025-07-13 05:49:09 +09:00
2025-09-24 08:48:17 +02:00
2025-05-14 18:06:04 +02:00
2025-08-18 04:43:44 +09:00
2025-05-07 00:49:49 +09:00
2025-07-03 17:43:01 +02:00
2024-03-27 07:12:01 +01:00
2024-03-27 07:12:01 +01:00
2024-03-27 07:12:04 +01:00
2025-07-22 18:27:37 +09:00
2024-03-15 04:04:01 +09:00