Skip to content

grub-fs-tester: fix losetup race

Will Thompson grub-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest1 patch 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/1grub-fs-tester: fix losetup racetests/util/grub-fs-tester.in+1 -22 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/1] grub-fs-tester: fix losetup race

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(-)
Signature · 1 line
2.17.1