All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/1] grub-fs-tester: fix losetup race
@ 2018-06-15 17:34 Will Thompson
  2018-06-15 17:34 ` [PATCH 1/1] " Will Thompson
  0 siblings, 1 reply; 4+ messages in thread
From: Will Thompson @ 2018-06-15 17:34 UTC (permalink / raw)
  To: grub-devel; +Cc: Will Thompson

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



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/1] grub-fs-tester: fix losetup race
  2018-06-15 17:34 [PATCH 0/1] grub-fs-tester: fix losetup race Will Thompson
@ 2018-06-15 17:34 ` Will Thompson
  2018-06-20  9:33   ` Daniel Kiper
  0 siblings, 1 reply; 4+ messages in thread
From: Will Thompson @ 2018-06-15 17:34 UTC (permalink / raw)
  To: grub-devel; +Cc: Will Thompson

If something else on the system is using loopback devices, then the
device that's free at the call to `losetup -f` may not be free in the
following call to try to use it. Instead, find and use the first free
loopback device in a single call to losetup.
---
 tests/util/grub-fs-tester.in | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in
index 26bd57a80..ef65fbc93 100644
--- a/tests/util/grub-fs-tester.in
+++ b/tests/util/grub-fs-tester.in
@@ -616,9 +616,8 @@ for LOGSECSIZE in $(range "$MINLOGSECSIZE" "$MAXLOGSECSIZE" 1); do
 		    mkdir -p "$MNTPOINTRO"
 		    for i in $(range 0 $((NDEVICES-1)) 1); do
 			dd if=/dev/zero of="$FSIMAGEP${i}.img" count=1 bs=1 seek=$((DISKSIZE-1)) &> /dev/null
-			LODEVICE="$(losetup -f)"
+			LODEVICE=$(losetup --find --show "$FSIMAGEP${i}.img")
 			LODEVICES="$LODEVICES $LODEVICE"
-			losetup "$LODEVICE" "$FSIMAGEP${i}.img"
 			if test "$i" = 0; then
 			    MOUNTDEVICE="$LODEVICE"
 			fi
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] grub-fs-tester: fix losetup race
  2018-06-15 17:34 ` [PATCH 1/1] " Will Thompson
@ 2018-06-20  9:33   ` Daniel Kiper
  2018-06-20 11:15     ` Will Thompson
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Kiper @ 2018-06-20  9:33 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: Will Thompson

On Fri, Jun 15, 2018 at 06:34:04PM +0100, Will Thompson wrote:
> If something else on the system is using loopback devices, then the
> device that's free at the call to `losetup -f` may not be free in the
> following call to try to use it. Instead, find and use the first free
> loopback device in a single call to losetup.

In general LGTM except lack of SOB. I can add it (Signed-off-by: Will
Thompson <wjt@endlessm.com>) before committing if you are OK with that.
Next time please do not forget about that.

Daniel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] grub-fs-tester: fix losetup race
  2018-06-20  9:33   ` Daniel Kiper
@ 2018-06-20 11:15     ` Will Thompson
  0 siblings, 0 replies; 4+ messages in thread
From: Will Thompson @ 2018-06-20 11:15 UTC (permalink / raw)
  To: Daniel Kiper; +Cc: The development of GNU GRUB

[-- Attachment #1: Type: text/plain, Size: 697 bytes --]

On Wed, 20 Jun 2018 at 10:33 Daniel Kiper <dkiper@net-space.pl> wrote:

> On Fri, Jun 15, 2018 at 06:34:04PM +0100, Will Thompson wrote:
> > If something else on the system is using loopback devices, then the
> > device that's free at the call to `losetup -f` may not be free in the
> > following call to try to use it. Instead, find and use the first free
> > loopback device in a single call to losetup.
>
> In general LGTM except lack of SOB. I can add it (Signed-off-by: Will
> Thompson <wjt@endlessm.com>) before committing if you are OK with that.
> Next time please do not forget about that.
>

That's fine by me – I'll include it in the submitted patch in future.
Thanks!

[-- Attachment #2: Type: text/html, Size: 1053 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-06-20 11:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-15 17:34 [PATCH 0/1] grub-fs-tester: fix losetup race Will Thompson
2018-06-15 17:34 ` [PATCH 1/1] " Will Thompson
2018-06-20  9:33   ` Daniel Kiper
2018-06-20 11:15     ` Will Thompson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.