OSInside / kiwi

KIWI - Appliance Builder Next Generation
https://osinside.github.io/kiwi
GNU General Public License v3.0
282 stars 142 forks source link

Loop cleanup race condition #2580

Open schaefi opened 1 week ago

schaefi commented 1 week ago

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 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
}