WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 1/2] Fix problems with vbd hotplug on Linux

To: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH 1/2] Fix problems with vbd hotplug on Linux
From: Gary Grebus <Gary.Grebus@xxxxxxxxxx>
Date: Mon, 02 Nov 2009 16:35:15 -0500
Delivery-date: Mon, 02 Nov 2009 13:36:33 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.23 (X11/20090825)
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>

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
        ;;



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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH 1/2] Fix problems with vbd hotplug on Linux, Gary Grebus <=