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

[Xen-changelog] Avoid a hang when probing the partition table on imported block



# HG changeset patch
# User sos22@xxxxxxxxxxxxxxxxxxxx
# Node ID 265f68795ebf254cc07b8cc17e8d5813b7df5c0c
# Parent  d4ab8e46136ccb64a75dbdb6e84126d6a9552ca4
Avoid a hang when probing the partition table on imported block
devices.  If you export a device so the importing domain sees it as a
whole disk rather than a partition, then add_disk will try to probe
its partition table.  However, we were calling add_disk before the
device was properly connected, and then not connecting it until
add_disk had finished.  This meant that we ended up never actually
connecting the device, and any accesses to it would then hang.

Fix this by not calling add_disk until we're connected.

Signed-off-by: Steven Smith, sos22@xxxxxxxxx

diff -r d4ab8e46136c -r 265f68795ebf 
linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c      Fri Dec  2 
12:27:39 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c      Fri Dec  2 
14:16:37 2005
@@ -311,7 +311,7 @@
        int err;
 
         if( (info->connected == BLKIF_STATE_CONNECTED) || 
-           (info->connected == BLKIF_STATE_SUSPENDED) ) 
+           (info->connected == BLKIF_STATE_SUSPENDED) )
                return;
 
        DPRINTK("blkfront.c:connect:%s.\n", info->xbdev->otherend);
@@ -327,16 +327,18 @@
                                 info->xbdev->otherend);
                return;
        }
-       
+
         xlvbd_add(sectors, info->vdevice, binfo, sector_size, info);
 
        (void)xenbus_switch_state(info->xbdev, NULL, XenbusStateConnected); 
-       
+
        /* Kick pending requests. */
        spin_lock_irq(&blkif_io_lock);
        info->connected = BLKIF_STATE_CONNECTED;
        kick_pending_request_queues(info);
        spin_unlock_irq(&blkif_io_lock);
+
+       add_disk(info->gd);
 }
 
 /**
@@ -588,7 +590,6 @@
 
        while ((req = elv_next_request(rq)) != NULL) {
                info = req->rq_disk->private_data;
-
                if (!blk_fs_request(req)) {
                        end_request(req, 0);
                        continue;
diff -r d4ab8e46136c -r 265f68795ebf 
linux-2.6-xen-sparse/drivers/xen/blkfront/block.h
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/block.h Fri Dec  2 12:27:39 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/block.h Fri Dec  2 14:16:37 2005
@@ -146,6 +146,9 @@
 extern void do_blkif_request (request_queue_t *rq); 
 
 /* Virtual block-device subsystem. */
+/* Note that xlvbd_add doesn't call add_disk for you: you're expected
+   to call add_disk on info->gd once the disk is properly connected
+   up. */
 int xlvbd_add(blkif_sector_t capacity, int device,
              u16 vdisk_info, u16 sector_size, struct blkfront_info *info);
 void xlvbd_del(struct blkfront_info *info);
diff -r d4ab8e46136c -r 265f68795ebf 
linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c   Fri Dec  2 12:27:39 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c   Fri Dec  2 14:16:37 2005
@@ -261,7 +261,6 @@
        if (vdisk_info & VDISK_CDROM)
                gd->flags |= GENHD_FL_CD;
 
-       add_disk(gd);
        info->gd = gd;
 
        return 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®.