* [PATCH 1/2] Fix problems with vbd hotplug on Linux
@ 2009-11-02 21:35 Gary Grebus
0 siblings, 0 replies; only message in thread
From: Gary Grebus @ 2009-11-02 21:35 UTC (permalink / raw)
To: xen-devel
Avoid races between hotplug "add" and "remove" leading to "leaked"
loopback devices.
- Don't setup loopback device if xend is no longer waiting for the vbd.
- Use the lock file to avoid add/remove races.
Signed-off-by: Gary Grebus <gary.grebus@oracle.com>
diff -r 8ca4e32583b6 tools/hotplug/Linux/block
--- a/tools/hotplug/Linux/block Fri Oct 23 10:15:17 2009 +0100
+++ b/tools/hotplug/Linux/block Mon Oct 26 12:34:57 2009 -0400
@@ -233,6 +233,15 @@
claim_lock "block"
+ # Avoid a race with the remove if the path has been deleted, or
+ # otherwise changed from "InitWait" state e.g. due to a timeout
+ xenbus_state=$(xenstore_read_default "$XENBUS_PATH/state" 'unknown')
+ if [ "$xenbus_state" != '2' ]
+ then
+ release_lock "block"
+ fatal "Path closed or removed during hotplug add: $XENBUS_PATH state: $xenbus_state"
+ fi
+
if [ "$mode" = 'w' ] && ! stat "$file" -c %A | grep -q w
then
release_lock "block"
@@ -363,8 +372,10 @@
;;
file)
+ claim_lock "block"
node=$(xenstore_read "$XENBUS_PATH/node")
losetup -d "$node"
+ release_lock "block"
exit 0
;;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-11-02 21:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-02 21:35 [PATCH 1/2] Fix problems with vbd hotplug on Linux Gary Grebus
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.