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

[Xen-changelog] Clean up ctrl msg handling in Linux. Remove VBD_GROW/SHRINK -- a VBD



ChangeSet 1.1409, 2005/03/31 12:00:46+01:00, kaf24@xxxxxxxxxxxxxxxxxxxx

        Clean up ctrl msg handling in Linux. Remove VBD_GROW/SHRINK -- a VBD
        now maps onto a single complete major/minor that is specified at
        VBD_CREATE time. Also improve blkdev request_queue unplugging in the
        2.6 backend driver to promote better batching.
        Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>



 linux-2.6.11-xen-sparse/drivers/xen/balloon/balloon.c          |   11 
 linux-2.6.11-xen-sparse/drivers/xen/blkback/blkback.c          |   31 
 linux-2.6.11-xen-sparse/drivers/xen/blkback/common.h           |   22 
 linux-2.6.11-xen-sparse/drivers/xen/blkback/control.c          |   34 
 linux-2.6.11-xen-sparse/drivers/xen/blkback/vbd.c              |  407 
+---------
 linux-2.6.11-xen-sparse/drivers/xen/blkfront/blkfront.c        |   12 
 linux-2.6.11-xen-sparse/drivers/xen/blktap/blktap_controlmsg.c |   26 
 linux-2.6.11-xen-sparse/drivers/xen/netback/control.c          |   22 
 linux-2.6.11-xen-sparse/drivers/xen/netfront/netfront.c        |    5 
 linux-2.6.11-xen-sparse/drivers/xen/usbback/control.c          |   24 
 linux-2.6.11-xen-sparse/drivers/xen/usbfront/usbfront.c        |   12 
 tools/blktap/blkdump.c                                         |    8 
 tools/python/xen/lowlevel/xu/xu.c                              |   32 
 tools/python/xen/xend/server/blkif.py                          |   33 
 tools/python/xen/xend/server/messages.py                       |    9 
 tools/xcs/dump.c                                               |   22 
 xen/include/public/io/domain_controller.h                      |   44 -
 17 files changed, 127 insertions(+), 627 deletions(-)


diff -Nru a/linux-2.6.11-xen-sparse/drivers/xen/balloon/balloon.c 
b/linux-2.6.11-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6.11-xen-sparse/drivers/xen/balloon/balloon.c     2005-03-31 
07:03:54 -05:00
+++ b/linux-2.6.11-xen-sparse/drivers/xen/balloon/balloon.c     2005-03-31 
07:03:54 -05:00
@@ -305,21 +305,16 @@
     case CMSG_MEM_REQUEST_SET:
     {
         mem_request_t *req = (mem_request_t *)&msg->msg[0];
-        if ( msg->length != sizeof(mem_request_t) )
-            goto parse_error;
         set_new_target(req->target);
         req->status = 0;
     }
     break;        
+
     default:
-        goto parse_error;
+        msg->length = 0;
+        break;
     }
 
-    ctrl_if_send_response(msg);
-    return;
-
- parse_error:
-    msg->length = 0;
     ctrl_if_send_response(msg);
 }
 
diff -Nru a/linux-2.6.11-xen-sparse/drivers/xen/blkback/blkback.c 
b/linux-2.6.11-xen-sparse/drivers/xen/blkback/blkback.c
--- a/linux-2.6.11-xen-sparse/drivers/xen/blkback/blkback.c     2005-03-31 
07:03:54 -05:00
+++ b/linux-2.6.11-xen-sparse/drivers/xen/blkback/blkback.c     2005-03-31 
07:03:54 -05:00
@@ -67,6 +67,19 @@
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
 static kmem_cache_t *buffer_head_cachep;
+#else
+static request_queue_t *plugged_queue;
+void bdev_put(struct block_device *bdev)
+{
+    request_queue_t *q = plugged_queue;
+    /* We might be giving up last reference to plugged queue. Flush if so. */
+    if ( (q != NULL) &&
+         (q == bdev_get_queue(bdev)) && 
+         (cmpxchg(&plugged_queue, q, NULL) == q) )
+        blk_run_queue(q);
+    /* It's now safe to drop the block device. */
+    blkdev_put(bdev);
+}
 #endif
 
 #ifdef CONFIG_XEN_BLKDEV_TAP_BE
@@ -189,9 +202,15 @@
             blkif_put(blkif);
         }
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
         /* Push the batch through to disc. */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
         run_task_queue(&tq_disk);
+#else
+        if ( plugged_queue != NULL )
+        {
+            blk_run_queue(plugged_queue);
+            plugged_queue = NULL;
+        }
 #endif
     }
 }
@@ -512,6 +531,7 @@
     for ( i = 0; i < nr_psegs; i++ )
     {
         struct bio *bio;
+        request_queue_t *q;
 
         bio = bio_alloc(GFP_ATOMIC, 1);
         if ( unlikely(bio == NULL) )
@@ -531,7 +551,14 @@
             phys_seg[i].nr_sects << 9,
             phys_seg[i].buffer & ~PAGE_MASK);
 
-        submit_bio(operation | (1 << BIO_RW_SYNC), bio);
+        if ( (q = bdev_get_queue(bio->bi_bdev)) != plugged_queue )
+        {
+            if ( plugged_queue != NULL )
+                blk_run_queue(plugged_queue);
+            plugged_queue = q;
+        }
+
+        submit_bio(operation, bio);
     }
 #endif
 
diff -Nru a/linux-2.6.11-xen-sparse/drivers/xen/blkback/common.h 
b/linux-2.6.11-xen-sparse/drivers/xen/blkback/common.h
--- a/linux-2.6.11-xen-sparse/drivers/xen/blkback/common.h      2005-03-31 
07:03:53 -05:00
+++ b/linux-2.6.11-xen-sparse/drivers/xen/blkback/common.h      2005-03-31 
07:03:53 -05:00
@@ -31,8 +31,10 @@
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
 typedef struct rb_root rb_root_t;
 typedef struct rb_node rb_node_t;
+extern void bdev_put(struct block_device *bdev);
 #else
 struct block_device;
+#define bdev_put(_b) ((void)0)
 #endif
 
 typedef struct blkif_st {
@@ -80,24 +82,16 @@
             blkif_disconnect_complete(_b);        \
     } while (0)
 
-/* An entry in a list of xen_extents. */
-typedef struct _blkif_extent_le { 
-    blkif_extent_t extent;               /* an individual extent */
-    struct _blkif_extent_le *next;       /* and a pointer to the next */ 
-    struct block_device *bdev;
-} blkif_extent_le_t; 
-
 typedef struct _vbd { 
-    blkif_vdev_t       vdevice;   /* what the domain refers to this vbd as */
-    unsigned char      readonly;  /* Non-zero -> read-only */
-    unsigned char      type;      /* VDISK_TYPE_xxx */
-    blkif_extent_le_t *extents;   /* list of xen_extents making up this vbd */
-    rb_node_t          rb;        /* for linking into R-B tree lookup struct */
+    blkif_vdev_t   vdevice;     /* what the domain refers to this vbd as */
+    unsigned char  readonly;    /* Non-zero -> read-only */
+    unsigned char  type;        /* VDISK_TYPE_xxx */
+    blkif_pdev_t   pdevice;     /* phys device that this vbd maps to */
+    struct block_device *bdev;
+    rb_node_t      rb;          /* for linking into R-B tree lookup struct */
 } vbd_t; 
 
 void vbd_create(blkif_be_vbd_create_t *create); 
-void vbd_grow(blkif_be_vbd_grow_t *grow); 
-void vbd_shrink(blkif_be_vbd_shrink_t *shrink);
 void vbd_destroy(blkif_be_vbd_destroy_t *delete); 
 int vbd_probe(blkif_t *blkif, vdisk_t *vbd_info, int max_vbds);
 void destroy_all_vbds(blkif_t *blkif);
diff -Nru a/linux-2.6.11-xen-sparse/drivers/xen/blkback/control.c 
b/linux-2.6.11-xen-sparse/drivers/xen/blkback/control.c
--- a/linux-2.6.11-xen-sparse/drivers/xen/blkback/control.c     2005-03-31 
07:03:54 -05:00
+++ b/linux-2.6.11-xen-sparse/drivers/xen/blkback/control.c     2005-03-31 
07:03:54 -05:00
@@ -15,57 +15,31 @@
     switch ( msg->subtype )
     {
     case CMSG_BLKIF_BE_CREATE:
-        if ( msg->length != sizeof(blkif_be_create_t) )
-            goto parse_error;
         blkif_create((blkif_be_create_t *)&msg->msg[0]);
         break;        
     case CMSG_BLKIF_BE_DESTROY:
-        if ( msg->length != sizeof(blkif_be_destroy_t) )
-            goto parse_error;
         blkif_destroy((blkif_be_destroy_t *)&msg->msg[0]);
         break;        
     case CMSG_BLKIF_BE_CONNECT:
-        if ( msg->length != sizeof(blkif_be_connect_t) )
-            goto parse_error;
         blkif_connect((blkif_be_connect_t *)&msg->msg[0]);
         break;        
     case CMSG_BLKIF_BE_DISCONNECT:
-        if ( msg->length != sizeof(blkif_be_disconnect_t) )
-            goto parse_error;
         if ( !blkif_disconnect((blkif_be_disconnect_t *)&msg->msg[0],msg->id) )
             return; /* Sending the response is deferred until later. */
         break;        
     case CMSG_BLKIF_BE_VBD_CREATE:
-        if ( msg->length != sizeof(blkif_be_vbd_create_t) )
-            goto parse_error;
         vbd_create((blkif_be_vbd_create_t *)&msg->msg[0]);
         break;
     case CMSG_BLKIF_BE_VBD_DESTROY:
-        if ( msg->length != sizeof(blkif_be_vbd_destroy_t) )
-            goto parse_error;
         vbd_destroy((blkif_be_vbd_destroy_t *)&msg->msg[0]);
         break;
-    case CMSG_BLKIF_BE_VBD_GROW:
-        if ( msg->length != sizeof(blkif_be_vbd_grow_t) )
-            goto parse_error;
-        vbd_grow((blkif_be_vbd_grow_t *)&msg->msg[0]);
-        break;
-    case CMSG_BLKIF_BE_VBD_SHRINK:
-        if ( msg->length != sizeof(blkif_be_vbd_shrink_t) )
-            goto parse_error;
-        vbd_shrink((blkif_be_vbd_shrink_t *)&msg->msg[0]);
-        break;
     default:
-        goto parse_error;
+        DPRINTK("Parse error while reading message subtype %d, len %d\n",
+                msg->subtype, msg->length);
+        msg->length = 0;
+        break;
     }
 
-    ctrl_if_send_response(msg);
-    return;
-
- parse_error:
-    DPRINTK("Parse error while reading message subtype %d, len %d\n",
-            msg->subtype, msg->length);
-    msg->length = 0;
     ctrl_if_send_response(msg);
 }
 
diff -Nru a/linux-2.6.11-xen-sparse/drivers/xen/blkback/vbd.c 
b/linux-2.6.11-xen-sparse/drivers/xen/blkback/vbd.c
--- a/linux-2.6.11-xen-sparse/drivers/xen/blkback/vbd.c 2005-03-31 07:03:53 
-05:00
+++ b/linux-2.6.11-xen-sparse/drivers/xen/blkback/vbd.c 2005-03-31 07:03:53 
-05:00
@@ -7,13 +7,18 @@
  * in vbd_translate.  All other lookups are implicitly protected because the 
  * only caller (the control message dispatch routine) serializes the calls.
  * 
- * Copyright (c) 2003-2004, Keir Fraser & Steve Hand
+ * Copyright (c) 2003-2005, Keir Fraser & Steve Hand
  */
 
 #include "common.h"
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-static dev_t vbd_map_devnum(blkif_pdev_t);
+static inline dev_t vbd_map_devnum(blkif_pdev_t cookie)
+{ return MKDEV(cookie>>8, cookie&0xff); }
+#define vbd_sz(_v)   ((_v)->bdev->bd_part ? \
+    (_v)->bdev->bd_part->nr_sects : (_v)->bdev->bd_disk->capacity)
+#else
+#define vbd_sz(_v)   (blk_size[MAJOR((_v)->pdevice)][MINOR((_v)->pdevice)]*2)
 #endif
 
 void vbd_create(blkif_be_vbd_create_t *create) 
@@ -63,203 +68,45 @@
     vbd->vdevice  = vdevice; 
     vbd->readonly = create->readonly;
     vbd->type     = VDISK_TYPE_DISK | VDISK_FLAG_VIRT;
-    vbd->extents  = NULL; 
-
-    spin_lock(&blkif->vbd_lock);
-    rb_link_node(&vbd->rb, rb_parent, rb_p);
-    rb_insert_color(&vbd->rb, &blkif->vbd_rb);
-    spin_unlock(&blkif->vbd_lock);
-
-    DPRINTK("Successful creation of vdev=%04x (dom=%u)\n",
-            vdevice, create->domid);
-    create->status = BLKIF_BE_STATUS_OKAY;
-}
-
-
-/* Grow a VBD by appending a new extent. Fails if the VBD doesn't exist. */
-void vbd_grow(blkif_be_vbd_grow_t *grow) 
-{
-    blkif_t            *blkif;
-    blkif_extent_le_t **px, *x; 
-    vbd_t              *vbd = NULL;
-    rb_node_t          *rb;

_______________________________________________
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®.