#1021653 parted: prefer exclusively locking devices over calling udevadm settle

Package:
parted
Source:
parted
Description:
disk partition manipulator
Submitter:
Date:
2026-01-08 02:59:03 UTC
Severity:
normal
#1021653#5
Date:
2022-10-12 09:49:31 UTC
From:
To:
Dear Maintainer,

Currently with debian/patches/udevadm-settle.patch, `udevadm settle` is called
around the opening/closing of the block device. This is supposed to wait for
udev to process device creation events and ensuring that the device nodes have
been created.

I don't think this call is needed, instead we should lock the device using
flock(LOCK_EX) and hold the lock until we are done with the device.

According to systemd documentation, https://systemd.io/BLOCK_DEVICE_LOCKING/
this is the correct way to stop udev from processing events on the block device
while it is being modified.

This method could also be pushed upstream to parted, there is an outstanding
patch (long before systemd!) which could be used for inspiration:
https://www.mail-archive.com/parted-devel@lists.alioth.debian.org/msg04119.html