All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gary Grebus <Gary.Grebus@oracle.com>
To: xen-devel <xen-devel@lists.xensource.com>
Subject: [PATCH 1/2] Fix problems with vbd hotplug on Linux
Date: Mon, 02 Nov 2009 16:35:15 -0500	[thread overview]
Message-ID: <4AEF5093.9090707@oracle.com> (raw)

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

                 reply	other threads:[~2009-11-02 21:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4AEF5093.9090707@oracle.com \
    --to=gary.grebus@oracle.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.