Call udevadm settle before kpartx -d

Back in 2017 some code was added to ignore failures tearing down loop
devices. But debugging that growpart race on cloud images made me (very)
aware of a potential cause of the race: doing something like zerofree on
a device will cause udev scripts to run, and if they are still running
by the time kpartx is called, you would expect the kpartx -d to fail. So
lets see if a udevadm settle helps, and get rid of one of the "sometimes
this fails but we don't know why" comments...
arbitrary-model-names
Michael Hudson-Doyle 5 years ago
parent 8f76e539b1
commit 2498aadebb

6
debian/changelog vendored

@ -1,3 +1,9 @@
livecd-rootfs (2.656) UNRELEASED; urgency=medium
* Call udevadm settle before kpartx -d.
-- Michael Hudson-Doyle <michael.hudson@ubuntu.com> Sat, 21 Mar 2020 00:07:43 +1300
livecd-rootfs (2.655) focal; urgency=medium
* minimized: reinstall packages one by one, instead of all of them

@ -14,18 +14,12 @@ clean_loops() {
local kpartx_stdout
if [ -n "${backing_img}" ]; then
# sync before removing loop to avoid "Device or resource busy" errors
# If something just finished writing to the device or a
# partition (e.g. the zerofree in umount_partition) udev might
# still be processing the device.
udevadm settle
sync
kpartx_ret=""
kpartx_stdout=$(kpartx -v -d "${backing_img}") || kpartx_ret=$?
echo "$kpartx_stdout"
if [ -n "$kpartx_ret" ]; then
if echo "$kpartx_stdout" | grep -q "loop deleted"; then
echo "Suppressing kpartx returning error (#860894)"
else
exit $kpartx_ret
fi
fi
kpartx -v -d "${backing_img}"
unset backing_img
fi

Loading…
Cancel
Save