|
|
|
|
|
|
|
|
|
|
xen-changelog
[Xen-changelog] The device sharing check races when more than one file b
# HG changeset patch
# User rread@xxxxxxxxxxxxxxxxxxxxxxxxxxx
# Node ID 880b02c046562a8ed4690f2ab5c9cea16dbd8c1e
# Parent 444b968a3e094829becf2d1533e24599a4da0c01
The device sharing check races when more than one file backed vbd is
configured. Both of the files pick the same free loop device in the for
loop, and then one fails to losetup. This patch will now retry if
losetup fails until it succeeds or no more devices are available.
Signed-off-by: Robert Read <robert@xxxxxxxxxxxxx>
diff -r 444b968a3e09 -r 880b02c04656 tools/examples/block
--- a/tools/examples/block Mon Nov 28 19:16:27 2005
+++ b/tools/examples/block Mon Nov 28 22:34:00 2005
@@ -202,59 +202,61 @@
mount it read-write in a guest domain."
fi
- loopdev=''
-
- for dev in /dev/loop*
- do
- if [ ! -b "$dev" ]
- then
- continue
- fi
-
- f=$(losetup "$dev" 2>/dev/null) || f='()'
- f=$(echo "$f" | sed -e 's/.*(\(.*\)).*/\1/g')
-
- log err "$file $f $dev"
-
- if [ "$f" ]
- then
- # $dev is in use. Check sharing.
-
- if [ "$mode" == 'no' ]
+
+ while true
+ do
+ loopdev=''
+ for dev in /dev/loop*
+ do
+ if [ ! -b "$dev" ]
then
continue
fi
- f=$(readlink -f "$f")
-
- if [ "$f" == "$file" ]
+ f=$(losetup "$dev" 2>/dev/null) || f='()'
+ f=$(echo "$f" | sed -e 's/.*(\(.*\)).*/\1/g')
+
+ log err "$file $f $dev"
+
+ if [ "$f" ]
then
- check_file_sharing "$file" "$dev" "$mode"
+ # $dev is in use. Check sharing.
+ if [ "$mode" == 'no' ]
+ then
+ continue
+ fi
+
+ f=$(readlink -f "$f")
+
+ if [ "$f" == "$file" ]
+ then
+ check_file_sharing "$file" "$dev" "$mode"
+ fi
+ else
+ # $dev is not in use, so we'll remember it for use later; we want
+ # to finish the sharing check first.
+
+ if [ "$loopdev" == '' ]
+ then
+ loopdev="$dev"
+ fi
fi
+ done
+
+ if [ "$loopdev" == '' ]
+ then
+ fatal 'Failed to find an unused loop device'
+ fi
+ if losetup "$loopdev" "$file"
+ then
+ log err "mapped $file using $loopdev"
+ xenstore_write "$XENBUS_PATH/node" "$loopdev"
+ write_dev "$loopdev"
+ exit 0
else
- # $dev is not in use, so we'll remember it for use later; we want
- # to finish the sharing check first.
-
- if [ "$loopdev" == '' ]
- then
- loopdev="$dev"
- fi
+ log err "losetup $loopdev $file failed, retry"
fi
- done
-
- if [ "$loopdev" == '' ]
- then
- fatal 'Failed to find an unused loop device'
- fi
-
- if losetup "$loopdev" "$file"
- then
- xenstore_write "$XENBUS_PATH/node" "$loopdev"
- write_dev "$loopdev"
- exit 0
- else
- fatal "losetup $loopdev $file failed"
- fi
+ done
;;
esac
;;
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|
<Prev in Thread] |
Current Thread |
[Next in Thread> |
- [Xen-changelog] The device sharing check races when more than one file backed vbd is,
Xen patchbot -unstable <=
|
|
|
|
|