On a build server where other jobs are making use of loop devices, we
occasionally see GRUB's filesystem tests failing with errors like:

  losetup: /tmp/tmp.uMgVEh1vvn/ext2_old_256_1024_1_0.img: failed to set
  up loop device: Device or resource busy

This is because grub-fs-tester runs `losetup --find` to get a free loop
device, then runs `losetup $LODEVICE $FILE` to use it. In between the
two invocations, something else may have started using the free device.

It's easy to reproduce this by running a script like this at the same
time as a fs test:

  while true; do
    x=$(losetup --find --show /path/to/a/file)
    losetup -d $x
  done

The fix is to ask losetup to attach the file to a free loop device, and
print that device to stdout, in a single invocation. (losetup internally
has a retry loop.)

Will Thompson (1):
  grub-fs-tester: fix losetup race

 tests/util/grub-fs-tester.in | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

-- 
2.17.1


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to