[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] Linux vbd hotplug: Avoid "leaked" loopback devices



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1257237535 0
# Node ID 2ddad83e9733b006afb1169fe8a1bc02cfa41848
# Parent  98593d8d262e3cd15d06b0dd42cc137c23e857af
Linux vbd hotplug: Avoid "leaked" loopback devices

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@xxxxxxxxxx>
---
 tools/hotplug/Linux/block |   11 +++++++++++
 1 files changed, 11 insertions(+)

diff -r 98593d8d262e -r 2ddad83e9733 tools/hotplug/Linux/block
--- a/tools/hotplug/Linux/block Tue Nov 03 08:37:52 2009 +0000
+++ b/tools/hotplug/Linux/block Tue Nov 03 08:38:55 2009 +0000
@@ -232,6 +232,15 @@ case "$command" in
         mode=$(canonicalise_mode "$mode")
 
         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
@@ -363,8 +372,10 @@ mount it read-write in a guest domain."
        ;;
 
       file)
+        claim_lock "block"
         node=$(xenstore_read "$XENBUS_PATH/node")
        losetup -d "$node"
+        release_lock "block"
        exit 0
        ;;
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.