On Mon, Jun 14, 2021 at 09:35:30AM +0200, Ingo Franzki wrote: > However, shouldn't then the losetup userspace utility implement some kind of retry logic in case of -EAGAIN ? > I don't see that in the source of losetup.c nor in loopdev.c in the util-linux package. There is a retry loop in create_loop() in losetup.c retrying loopcxt_setup_device() in case of EBUSY, but not in case of EAGAIN. > > And losetup also hides the original error code and just returns EXIT_FAILURE in case of a failure. So no real good chance for the script that uses losetup to catch that error situation and perform a retry itself. > > Adding Karel Zak (the maintainer of util-linux). > > @Karel Zak: How about adding EAGAIN to the condition for performing a retry? > > Something like this: > > - if (errno == EBUSY && !hasdev && ntries < 64) { > + if ((errno == EBUSY || errno == EAGAIN) && !hasdev && ntries < 64) { > xusleep(200000); > ntries++; > continue; > } EAGAIN sounds like the best reason to try it again :-) Committed, it will be also available in v2.37.1. Karel -- Karel Zak <kzak@xxxxxxxxxx> http://karelzak.blogspot.com