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

[Xen-changelog] The device sharing check races when more than one file b

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] The device sharing check races when more than one file backed vbd is
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 29 Nov 2005 12:08:08 +0000
Delivery-date: Tue, 29 Nov 2005 12:08:30 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# 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 <=