A call to losetup -d returns but that doesn't mean the actual loop device has already been cleared. Using the same loop device right after the call may lead to an error depending on the kernel that has really released the resource or not. In kiwi we have code in
which deals with the race condition by calling udevadm settle and wait for the event queue to become empty. However, this seems not the right fix as it only waits for the event queue to become empty and that is actually not directly connected to the device release of the respective loop device.
Therefore another suggestion was made to lookup the sys layer for the particular loop to be really free
function settle() {
while test -d /sys/devices/virtual/block/loop0/loop ; do
:
done
}
Problem description
A call to
losetup -d
returns but that doesn't mean the actual loop device has already been cleared. Using the same loop device right after the call may lead to an error depending on the kernel that has really released the resource or not. In kiwi we have code inwhich deals with the race condition by calling
udevadm settle
and wait for the event queue to become empty. However, this seems not the right fix as it only waits for the event queue to become empty and that is actually not directly connected to the device release of the respective loop device.Therefore another suggestion was made to lookup the sys layer for the particular loop to be really free