[Bug 2087877] [NEW] Calling "flock parted mkpart" soft deadlocks
Chris Gunn
2087877 at bugs.launchpad.net
Tue Nov 12 00:38:11 UTC 2024
Public bug reported:
In Ubuntu 24.04, if you call 'parted' or 'partprobe' while holding a
file-lock to the disk device (e.g. using 'flock'), then the 'parted'
command can end up deadlocked on the internal call to 'udevadm settle'.
It looks like back in 2013, Ubuntu added a patch to libparted that calls
`udevadm settle' both before and after partition changes are committed
to disk:
https://git.launchpad.net/ubuntu/+source/parted/tree/debian/patches/udevadm-
settle.patch
In Ubuntu 22.04, if you call 'parted' under 'flock', then it works fine.
In systemd versions prior to v251, if a udev event was triggered that
couldn't be processed because the disk's file-lock was held by another
process, then the udev event was simply dropped. This would allow the
udev event queue to clear. Which in turn would allow the 'udevadm
settle' call to complete.
However, in systemd v251 a change was made to the udev event queue where
instead of dropping udev events that are blocked by a disk's file-lock,
the udev events are instead requeued in a loop. This prevents the udev
event queue from clearing. Which in turn blocks the 'udevadm settle'
call in 'parted'.
https://github.com/systemd/systemd/commit/5d354e525a56955ae7f68062e283dda85ab07794
Systemd's official recommendation is that users should use 'flock' when
making changes to partitions. If everyone did that, then I suspect the
'udevadm-settle.patch' patch would not be needed.
https://systemd.io/BLOCK_DEVICE_LOCKING/
However, I realize that removing the 'udevadm-settle.patch' patch might
be undesirable since it might break back-compat for users that don't use
'flock' with 'parted'.
As a workaround, the 'udevadm-settle.patch' patch could be modified to
first check if the disk file-lock is held and if it is, assume the user
is using 'flock' and don't call 'udevadm settle'. This should hopefully
fix the issue for users who use 'flock', while maintaining existing
behavior for users who don't use 'flock'.
** Affects: parted (Ubuntu)
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to parted in Ubuntu.
https://bugs.launchpad.net/bugs/2087877
Title:
Calling "flock parted mkpart" soft deadlocks
Status in parted package in Ubuntu:
New
Bug description:
In Ubuntu 24.04, if you call 'parted' or 'partprobe' while holding a
file-lock to the disk device (e.g. using 'flock'), then the 'parted'
command can end up deadlocked on the internal call to 'udevadm
settle'.
It looks like back in 2013, Ubuntu added a patch to libparted that
calls `udevadm settle' both before and after partition changes are
committed to disk:
https://git.launchpad.net/ubuntu/+source/parted/tree/debian/patches/udevadm-
settle.patch
In Ubuntu 22.04, if you call 'parted' under 'flock', then it works
fine. In systemd versions prior to v251, if a udev event was triggered
that couldn't be processed because the disk's file-lock was held by
another process, then the udev event was simply dropped. This would
allow the udev event queue to clear. Which in turn would allow the
'udevadm settle' call to complete.
However, in systemd v251 a change was made to the udev event queue
where instead of dropping udev events that are blocked by a disk's
file-lock, the udev events are instead requeued in a loop. This
prevents the udev event queue from clearing. Which in turn blocks the
'udevadm settle' call in 'parted'.
https://github.com/systemd/systemd/commit/5d354e525a56955ae7f68062e283dda85ab07794
Systemd's official recommendation is that users should use 'flock'
when making changes to partitions. If everyone did that, then I
suspect the 'udevadm-settle.patch' patch would not be needed.
https://systemd.io/BLOCK_DEVICE_LOCKING/
However, I realize that removing the 'udevadm-settle.patch' patch
might be undesirable since it might break back-compat for users that
don't use 'flock' with 'parted'.
As a workaround, the 'udevadm-settle.patch' patch could be modified to
first check if the disk file-lock is held and if it is, assume the
user is using 'flock' and don't call 'udevadm settle'. This should
hopefully fix the issue for users who use 'flock', while maintaining
existing behavior for users who don't use 'flock'.
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/parted/+bug/2087877/+subscriptions
More information about the foundations-bugs
mailing list