ia64/xen-unstable

changeset 4402:fa851e5b369e

bitkeeper revision 1.1236.1.173 (424bd85e5lo6-hlVKAhgf-Zu85iruw)

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@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Mar 31 11:00:46 2005 +0000 (2005-03-31)
parents fbaf3439e3b9
children cb602e6ad404
files linux-2.6.11-xen-sparse/drivers/xen/balloon/balloon.c linux-2.6.11-xen-sparse/drivers/xen/blkback/blkback.c linux-2.6.11-xen-sparse/drivers/xen/blkback/common.h linux-2.6.11-xen-sparse/drivers/xen/blkback/control.c linux-2.6.11-xen-sparse/drivers/xen/blkback/vbd.c linux-2.6.11-xen-sparse/drivers/xen/blkfront/blkfront.c linux-2.6.11-xen-sparse/drivers/xen/blktap/blktap_controlmsg.c linux-2.6.11-xen-sparse/drivers/xen/netback/control.c linux-2.6.11-xen-sparse/drivers/xen/netfront/netfront.c linux-2.6.11-xen-sparse/drivers/xen/usbback/control.c linux-2.6.11-xen-sparse/drivers/xen/usbfront/usbfront.c tools/blktap/blkdump.c tools/python/xen/lowlevel/xu/xu.c tools/python/xen/xend/server/blkif.py tools/python/xen/xend/server/messages.py tools/xcs/dump.c xen/include/public/io/domain_controller.h
line diff
     1.1 --- a/linux-2.6.11-xen-sparse/drivers/xen/balloon/balloon.c	Thu Mar 31 09:56:18 2005 +0000
     1.2 +++ b/linux-2.6.11-xen-sparse/drivers/xen/balloon/balloon.c	Thu Mar 31 11:00:46 2005 +0000
     1.3 @@ -305,22 +305,17 @@ static void balloon_ctrlif_rx(ctrl_msg_t
     1.4      case CMSG_MEM_REQUEST_SET:
     1.5      {
     1.6          mem_request_t *req = (mem_request_t *)&msg->msg[0];
     1.7 -        if ( msg->length != sizeof(mem_request_t) )
     1.8 -            goto parse_error;
     1.9          set_new_target(req->target);
    1.10          req->status = 0;
    1.11      }
    1.12      break;        
    1.13 +
    1.14      default:
    1.15 -        goto parse_error;
    1.16 +        msg->length = 0;
    1.17 +        break;
    1.18      }
    1.19  
    1.20      ctrl_if_send_response(msg);
    1.21 -    return;
    1.22 -
    1.23 - parse_error:
    1.24 -    msg->length = 0;
    1.25 -    ctrl_if_send_response(msg);
    1.26  }
    1.27  
    1.28  static int balloon_write(struct file *file, const char __user *buffer,
     2.1 --- a/linux-2.6.11-xen-sparse/drivers/xen/blkback/blkback.c	Thu Mar 31 09:56:18 2005 +0000
     2.2 +++ b/linux-2.6.11-xen-sparse/drivers/xen/blkback/blkback.c	Thu Mar 31 11:00:46 2005 +0000
     2.3 @@ -67,6 +67,19 @@ static PEND_RING_IDX pending_prod, pendi
     2.4  
     2.5  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
     2.6  static kmem_cache_t *buffer_head_cachep;
     2.7 +#else
     2.8 +static request_queue_t *plugged_queue;
     2.9 +void bdev_put(struct block_device *bdev)
    2.10 +{
    2.11 +    request_queue_t *q = plugged_queue;
    2.12 +    /* We might be giving up last reference to plugged queue. Flush if so. */
    2.13 +    if ( (q != NULL) &&
    2.14 +         (q == bdev_get_queue(bdev)) && 
    2.15 +         (cmpxchg(&plugged_queue, q, NULL) == q) )
    2.16 +        blk_run_queue(q);
    2.17 +    /* It's now safe to drop the block device. */
    2.18 +    blkdev_put(bdev);
    2.19 +}
    2.20  #endif
    2.21  
    2.22  #ifdef CONFIG_XEN_BLKDEV_TAP_BE
    2.23 @@ -189,9 +202,15 @@ static int blkio_schedule(void *arg)
    2.24              blkif_put(blkif);
    2.25          }
    2.26  
    2.27 +        /* Push the batch through to disc. */
    2.28  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
    2.29 -        /* Push the batch through to disc. */
    2.30          run_task_queue(&tq_disk);
    2.31 +#else
    2.32 +        if ( plugged_queue != NULL )
    2.33 +        {
    2.34 +            blk_run_queue(plugged_queue);
    2.35 +            plugged_queue = NULL;
    2.36 +        }
    2.37  #endif
    2.38      }
    2.39  }
    2.40 @@ -512,6 +531,7 @@ static void dispatch_rw_block_io(blkif_t
    2.41      for ( i = 0; i < nr_psegs; i++ )
    2.42      {
    2.43          struct bio *bio;
    2.44 +        request_queue_t *q;
    2.45  
    2.46          bio = bio_alloc(GFP_ATOMIC, 1);
    2.47          if ( unlikely(bio == NULL) )
    2.48 @@ -531,7 +551,14 @@ static void dispatch_rw_block_io(blkif_t
    2.49              phys_seg[i].nr_sects << 9,
    2.50              phys_seg[i].buffer & ~PAGE_MASK);
    2.51  
    2.52 -        submit_bio(operation | (1 << BIO_RW_SYNC), bio);
    2.53 +        if ( (q = bdev_get_queue(bio->bi_bdev)) != plugged_queue )
    2.54 +        {
    2.55 +            if ( plugged_queue != NULL )
    2.56 +                blk_run_queue(plugged_queue);
    2.57 +            plugged_queue = q;
    2.58 +        }
    2.59 +
    2.60 +        submit_bio(operation, bio);
    2.61      }
    2.62  #endif
    2.63  
     3.1 --- a/linux-2.6.11-xen-sparse/drivers/xen/blkback/common.h	Thu Mar 31 09:56:18 2005 +0000
     3.2 +++ b/linux-2.6.11-xen-sparse/drivers/xen/blkback/common.h	Thu Mar 31 11:00:46 2005 +0000
     3.3 @@ -31,8 +31,10 @@
     3.4  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
     3.5  typedef struct rb_root rb_root_t;
     3.6  typedef struct rb_node rb_node_t;
     3.7 +extern void bdev_put(struct block_device *bdev);
     3.8  #else
     3.9  struct block_device;
    3.10 +#define bdev_put(_b) ((void)0)
    3.11  #endif
    3.12  
    3.13  typedef struct blkif_st {
    3.14 @@ -80,24 +82,16 @@ blkif_t *blkif_find_by_handle(domid_t do
    3.15              blkif_disconnect_complete(_b);        \
    3.16      } while (0)
    3.17  
    3.18 -/* An entry in a list of xen_extents. */
    3.19 -typedef struct _blkif_extent_le { 
    3.20 -    blkif_extent_t extent;               /* an individual extent */
    3.21 -    struct _blkif_extent_le *next;       /* and a pointer to the next */ 
    3.22 +typedef struct _vbd { 
    3.23 +    blkif_vdev_t   vdevice;     /* what the domain refers to this vbd as */
    3.24 +    unsigned char  readonly;    /* Non-zero -> read-only */
    3.25 +    unsigned char  type;        /* VDISK_TYPE_xxx */
    3.26 +    blkif_pdev_t   pdevice;     /* phys device that this vbd maps to */
    3.27      struct block_device *bdev;
    3.28 -} blkif_extent_le_t; 
    3.29 -
    3.30 -typedef struct _vbd { 
    3.31 -    blkif_vdev_t       vdevice;   /* what the domain refers to this vbd as */
    3.32 -    unsigned char      readonly;  /* Non-zero -> read-only */
    3.33 -    unsigned char      type;      /* VDISK_TYPE_xxx */
    3.34 -    blkif_extent_le_t *extents;   /* list of xen_extents making up this vbd */
    3.35 -    rb_node_t          rb;        /* for linking into R-B tree lookup struct */
    3.36 +    rb_node_t      rb;          /* for linking into R-B tree lookup struct */
    3.37  } vbd_t; 
    3.38  
    3.39  void vbd_create(blkif_be_vbd_create_t *create); 
    3.40 -void vbd_grow(blkif_be_vbd_grow_t *grow); 
    3.41 -void vbd_shrink(blkif_be_vbd_shrink_t *shrink);
    3.42  void vbd_destroy(blkif_be_vbd_destroy_t *delete); 
    3.43  int vbd_probe(blkif_t *blkif, vdisk_t *vbd_info, int max_vbds);
    3.44  void destroy_all_vbds(blkif_t *blkif);
     4.1 --- a/linux-2.6.11-xen-sparse/drivers/xen/blkback/control.c	Thu Mar 31 09:56:18 2005 +0000
     4.2 +++ b/linux-2.6.11-xen-sparse/drivers/xen/blkback/control.c	Thu Mar 31 11:00:46 2005 +0000
     4.3 @@ -15,58 +15,32 @@ static void blkif_ctrlif_rx(ctrl_msg_t *
     4.4      switch ( msg->subtype )
     4.5      {
     4.6      case CMSG_BLKIF_BE_CREATE:
     4.7 -        if ( msg->length != sizeof(blkif_be_create_t) )
     4.8 -            goto parse_error;
     4.9          blkif_create((blkif_be_create_t *)&msg->msg[0]);
    4.10          break;        
    4.11      case CMSG_BLKIF_BE_DESTROY:
    4.12 -        if ( msg->length != sizeof(blkif_be_destroy_t) )
    4.13 -            goto parse_error;
    4.14          blkif_destroy((blkif_be_destroy_t *)&msg->msg[0]);
    4.15          break;        
    4.16      case CMSG_BLKIF_BE_CONNECT:
    4.17 -        if ( msg->length != sizeof(blkif_be_connect_t) )
    4.18 -            goto parse_error;
    4.19          blkif_connect((blkif_be_connect_t *)&msg->msg[0]);
    4.20          break;        
    4.21      case CMSG_BLKIF_BE_DISCONNECT:
    4.22 -        if ( msg->length != sizeof(blkif_be_disconnect_t) )
    4.23 -            goto parse_error;
    4.24          if ( !blkif_disconnect((blkif_be_disconnect_t *)&msg->msg[0],msg->id) )
    4.25              return; /* Sending the response is deferred until later. */
    4.26          break;        
    4.27      case CMSG_BLKIF_BE_VBD_CREATE:
    4.28 -        if ( msg->length != sizeof(blkif_be_vbd_create_t) )
    4.29 -            goto parse_error;
    4.30          vbd_create((blkif_be_vbd_create_t *)&msg->msg[0]);
    4.31          break;
    4.32      case CMSG_BLKIF_BE_VBD_DESTROY:
    4.33 -        if ( msg->length != sizeof(blkif_be_vbd_destroy_t) )
    4.34 -            goto parse_error;
    4.35          vbd_destroy((blkif_be_vbd_destroy_t *)&msg->msg[0]);
    4.36          break;
    4.37 -    case CMSG_BLKIF_BE_VBD_GROW:
    4.38 -        if ( msg->length != sizeof(blkif_be_vbd_grow_t) )
    4.39 -            goto parse_error;
    4.40 -        vbd_grow((blkif_be_vbd_grow_t *)&msg->msg[0]);
    4.41 +    default:
    4.42 +        DPRINTK("Parse error while reading message subtype %d, len %d\n",
    4.43 +                msg->subtype, msg->length);
    4.44 +        msg->length = 0;
    4.45          break;
    4.46 -    case CMSG_BLKIF_BE_VBD_SHRINK:
    4.47 -        if ( msg->length != sizeof(blkif_be_vbd_shrink_t) )
    4.48 -            goto parse_error;
    4.49 -        vbd_shrink((blkif_be_vbd_shrink_t *)&msg->msg[0]);
    4.50 -        break;
    4.51 -    default:
    4.52 -        goto parse_error;
    4.53      }
    4.54  
    4.55      ctrl_if_send_response(msg);
    4.56 -    return;
    4.57 -
    4.58 - parse_error:
    4.59 -    DPRINTK("Parse error while reading message subtype %d, len %d\n",
    4.60 -            msg->subtype, msg->length);
    4.61 -    msg->length = 0;
    4.62 -    ctrl_if_send_response(msg);
    4.63  }
    4.64  
    4.65  void blkif_ctrlif_init(void)
     5.1 --- a/linux-2.6.11-xen-sparse/drivers/xen/blkback/vbd.c	Thu Mar 31 09:56:18 2005 +0000
     5.2 +++ b/linux-2.6.11-xen-sparse/drivers/xen/blkback/vbd.c	Thu Mar 31 11:00:46 2005 +0000
     5.3 @@ -7,13 +7,18 @@
     5.4   * in vbd_translate.  All other lookups are implicitly protected because the 
     5.5   * only caller (the control message dispatch routine) serializes the calls.
     5.6   * 
     5.7 - * Copyright (c) 2003-2004, Keir Fraser & Steve Hand
     5.8 + * Copyright (c) 2003-2005, Keir Fraser & Steve Hand
     5.9   */
    5.10  
    5.11  #include "common.h"
    5.12  
    5.13  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
    5.14 -static dev_t vbd_map_devnum(blkif_pdev_t);
    5.15 +static inline dev_t vbd_map_devnum(blkif_pdev_t cookie)
    5.16 +{ return MKDEV(cookie>>8, cookie&0xff); }
    5.17 +#define vbd_sz(_v)   ((_v)->bdev->bd_part ? \
    5.18 +    (_v)->bdev->bd_part->nr_sects : (_v)->bdev->bd_disk->capacity)
    5.19 +#else
    5.20 +#define vbd_sz(_v)   (blk_size[MAJOR((_v)->pdevice)][MINOR((_v)->pdevice)]*2)
    5.21  #endif
    5.22  
    5.23  void vbd_create(blkif_be_vbd_create_t *create) 
    5.24 @@ -63,7 +68,36 @@ void vbd_create(blkif_be_vbd_create_t *c
    5.25      vbd->vdevice  = vdevice; 
    5.26      vbd->readonly = create->readonly;
    5.27      vbd->type     = VDISK_TYPE_DISK | VDISK_FLAG_VIRT;
    5.28 -    vbd->extents  = NULL; 
    5.29 +
    5.30 +    /* Mask to 16-bit for compatibility with old tools */
    5.31 +    vbd->pdevice  = create->pdevice & 0xffff;
    5.32 +
    5.33 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
    5.34 +    vbd->bdev = open_by_devnum(
    5.35 +        vbd_map_devnum(vbd->pdevice),
    5.36 +        vbd->readonly ? FMODE_READ : FMODE_WRITE);
    5.37 +    if ( IS_ERR(vbd->bdev) )
    5.38 +    {
    5.39 +        DPRINTK("vbd_creat: device %08x doesn't exist.\n", vbd->pdevice);
    5.40 +        create->status = BLKIF_BE_STATUS_PHYSDEV_NOT_FOUND;
    5.41 +        return;
    5.42 +    }
    5.43 +
    5.44 +    if ( (vbd->bdev->bd_disk == NULL) )
    5.45 +    {
    5.46 +        DPRINTK("vbd_creat: device %08x doesn't exist.\n", vbd->pdevice);
    5.47 +        create->status = BLKIF_BE_STATUS_PHYSDEV_NOT_FOUND;
    5.48 +        bdev_put(vbd->bdev);
    5.49 +        return;
    5.50 +    }
    5.51 +#else
    5.52 +    if ( (blk_size[MAJOR(vbd->pdevice)] == NULL) || (vbd_sz(vbd) == 0) )
    5.53 +    {
    5.54 +        DPRINTK("vbd_creat: device %08x doesn't exist.\n", vbd->pdevice);
    5.55 +        create->status = BLKIF_BE_STATUS_PHYSDEV_NOT_FOUND;
    5.56 +        return;
    5.57 +    }
    5.58 +#endif
    5.59  
    5.60      spin_lock(&blkif->vbd_lock);
    5.61      rb_link_node(&vbd->rb, rb_parent, rb_p);
    5.62 @@ -76,199 +110,11 @@ void vbd_create(blkif_be_vbd_create_t *c
    5.63  }
    5.64  
    5.65  
    5.66 -/* Grow a VBD by appending a new extent. Fails if the VBD doesn't exist. */
    5.67 -void vbd_grow(blkif_be_vbd_grow_t *grow) 
    5.68 -{
    5.69 -    blkif_t            *blkif;
    5.70 -    blkif_extent_le_t **px, *x; 
    5.71 -    vbd_t              *vbd = NULL;
    5.72 -    rb_node_t          *rb;
    5.73 -    blkif_vdev_t        vdevice = grow->vdevice;
    5.74 -    unsigned long       sz;
    5.75 -
    5.76 -    blkif = blkif_find_by_handle(grow->domid, grow->blkif_handle);
    5.77 -    if ( unlikely(blkif == NULL) )
    5.78 -    {
    5.79 -        DPRINTK("vbd_grow attempted for non-existent blkif (%u,%u)\n", 
    5.80 -                grow->domid, grow->blkif_handle); 
    5.81 -        grow->status = BLKIF_BE_STATUS_INTERFACE_NOT_FOUND;
    5.82 -        return;
    5.83 -    }
    5.84 -
    5.85 -    rb = blkif->vbd_rb.rb_node;
    5.86 -    while ( rb != NULL )
    5.87 -    {
    5.88 -        vbd = rb_entry(rb, vbd_t, rb);
    5.89 -        if ( vdevice < vbd->vdevice )
    5.90 -            rb = rb->rb_left;
    5.91 -        else if ( vdevice > vbd->vdevice )
    5.92 -            rb = rb->rb_right;
    5.93 -        else
    5.94 -            break;
    5.95 -    }
    5.96 -
    5.97 -    if ( unlikely(vbd == NULL) || unlikely(vbd->vdevice != vdevice) )
    5.98 -    {
    5.99 -        DPRINTK("vbd_grow: attempted to append extent to non-existent VBD.\n");
   5.100 -        grow->status = BLKIF_BE_STATUS_VBD_NOT_FOUND;
   5.101 -        return;
   5.102 -    } 
   5.103 -
   5.104 -    if ( grow->extent.sector_start > 0 )
   5.105 -    {
   5.106 -        DPRINTK("vbd_grow: dev %08x start not zero.\n", grow->extent.device);
   5.107 -        grow->status = BLKIF_BE_STATUS_EXTENT_NOT_FOUND;
   5.108 -        return;
   5.109 -    }
   5.110 -
   5.111 -    if ( unlikely((x = kmalloc(sizeof(blkif_extent_le_t), 
   5.112 -                               GFP_KERNEL)) == NULL) )
   5.113 -    {
   5.114 -        DPRINTK("vbd_grow: out of memory\n");
   5.115 -        grow->status = BLKIF_BE_STATUS_OUT_OF_MEMORY;
   5.116 -        return;
   5.117 -    }
   5.118 -
   5.119 -    /* Mask to 16-bit for compatibility with old tools */
   5.120 -    x->extent.device        = grow->extent.device & 0xffff;
   5.121 -    x->extent.sector_start  = grow->extent.sector_start;
   5.122 -    x->extent.sector_length = grow->extent.sector_length;
   5.123 -    x->next                 = (blkif_extent_le_t *)NULL;
   5.124 -
   5.125 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
   5.126 -    x->bdev = open_by_devnum(vbd_map_devnum(x->extent.device),
   5.127 -                             vbd->readonly ? FMODE_READ : FMODE_WRITE);
   5.128 -    if ( IS_ERR(x->bdev) )
   5.129 -    {
   5.130 -        DPRINTK("vbd_grow: device %08x doesn't exist.\n", x->extent.device);
   5.131 -        grow->status = BLKIF_BE_STATUS_EXTENT_NOT_FOUND;
   5.132 -        goto out;
   5.133 -    }
   5.134 -    /* XXXcl maybe bd_claim? */
   5.135 -
   5.136 -    if ( (x->bdev->bd_disk == NULL) )
   5.137 -    {
   5.138 -        DPRINTK("vbd_grow: device %08x doesn't exist.\n", x->extent.device);
   5.139 -        grow->status = BLKIF_BE_STATUS_EXTENT_NOT_FOUND;
   5.140 -        blkdev_put(x->bdev);
   5.141 -        goto out;
   5.142 -    }
   5.143 -
   5.144 -    /* get size in sectors */   
   5.145 -    if ( x->bdev->bd_part )
   5.146 -	 sz = x->bdev->bd_part->nr_sects;
   5.147 -    else
   5.148 -	 sz = x->bdev->bd_disk->capacity;
   5.149 -
   5.150 -#else
   5.151 -    if( !blk_size[MAJOR(x->extent.device)] )
   5.152 -    {
   5.153 -        DPRINTK("vbd_grow: device %08x doesn't exist.\n", x->extent.device);
   5.154 -        grow->status = BLKIF_BE_STATUS_EXTENT_NOT_FOUND;
   5.155 -        goto out;
   5.156 -    }
   5.157 -    
   5.158 -    /* convert blocks (1KB) to sectors */
   5.159 -    sz = blk_size[MAJOR(x->extent.device)][MINOR(x->extent.device)] * 2;    
   5.160 -    
   5.161 -    if ( sz == 0 )
   5.162 -    {
   5.163 -        DPRINTK("vbd_grow: device %08x zero size!\n", x->extent.device);
   5.164 -        grow->status = BLKIF_BE_STATUS_EXTENT_NOT_FOUND;
   5.165 -        goto out;
   5.166 -    }
   5.167 -#endif
   5.168 -
   5.169 -    /*
   5.170 -     * NB. This test assumes sector_start == 0, which is always the case
   5.171 -     * in Xen 1.3. In fact the whole grow/shrink interface could do with
   5.172 -     * some simplification.
   5.173 -     */
   5.174 -    if ( x->extent.sector_length > sz )
   5.175 -        x->extent.sector_length = sz;
   5.176 -    
   5.177 -    DPRINTK("vbd_grow: requested_len %llu actual_len %lu\n", 
   5.178 -            x->extent.sector_length, sz);
   5.179 -
   5.180 -    for ( px = &vbd->extents; *px != NULL; px = &(*px)->next ) 
   5.181 -        continue;
   5.182 -    
   5.183 -    *px = x; /* ATOMIC: no need for vbd_lock. */
   5.184 -
   5.185 -    DPRINTK("Successful grow of vdev=%04x (dom=%u)\n",
   5.186 -            vdevice, grow->domid);
   5.187 -    
   5.188 -    grow->status = BLKIF_BE_STATUS_OKAY;
   5.189 -    return;
   5.190 -
   5.191 - out:
   5.192 -    kfree(x);
   5.193 -}
   5.194 -
   5.195 -
   5.196 -void vbd_shrink(blkif_be_vbd_shrink_t *shrink)
   5.197 -{
   5.198 -    blkif_t            *blkif;
   5.199 -    blkif_extent_le_t **px, *x; 
   5.200 -    vbd_t              *vbd = NULL;
   5.201 -    rb_node_t          *rb;
   5.202 -    blkif_vdev_t        vdevice = shrink->vdevice;
   5.203 -
   5.204 -    blkif = blkif_find_by_handle(shrink->domid, shrink->blkif_handle);
   5.205 -    if ( unlikely(blkif == NULL) )
   5.206 -    {
   5.207 -        DPRINTK("vbd_shrink attempted for non-existent blkif (%u,%u)\n", 
   5.208 -                shrink->domid, shrink->blkif_handle); 
   5.209 -        shrink->status = BLKIF_BE_STATUS_INTERFACE_NOT_FOUND;
   5.210 -        return;
   5.211 -    }
   5.212 -
   5.213 -    rb = blkif->vbd_rb.rb_node;
   5.214 -    while ( rb != NULL )
   5.215 -    {
   5.216 -        vbd = rb_entry(rb, vbd_t, rb);
   5.217 -        if ( vdevice < vbd->vdevice )
   5.218 -            rb = rb->rb_left;
   5.219 -        else if ( vdevice > vbd->vdevice )
   5.220 -            rb = rb->rb_right;
   5.221 -        else
   5.222 -            break;
   5.223 -    }
   5.224 -
   5.225 -    if ( unlikely(vbd == NULL) || unlikely(vbd->vdevice != vdevice) )
   5.226 -    {
   5.227 -        shrink->status = BLKIF_BE_STATUS_VBD_NOT_FOUND;
   5.228 -        return;
   5.229 -    }
   5.230 -
   5.231 -    if ( unlikely(vbd->extents == NULL) )
   5.232 -    {
   5.233 -        shrink->status = BLKIF_BE_STATUS_EXTENT_NOT_FOUND;
   5.234 -        return;
   5.235 -    }
   5.236 -
   5.237 -    /* Find the last extent. We now know that there is at least one. */
   5.238 -    for ( px = &vbd->extents; (*px)->next != NULL; px = &(*px)->next )
   5.239 -        continue;
   5.240 -
   5.241 -    x   = *px;
   5.242 -    *px = x->next; /* ATOMIC: no need for vbd_lock. */
   5.243 -
   5.244 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
   5.245 -    blkdev_put(x->bdev);
   5.246 -#endif
   5.247 -    kfree(x);
   5.248 -
   5.249 -    shrink->status = BLKIF_BE_STATUS_OKAY;
   5.250 -}
   5.251 -
   5.252 -
   5.253  void vbd_destroy(blkif_be_vbd_destroy_t *destroy) 
   5.254  {
   5.255      blkif_t           *blkif;
   5.256      vbd_t             *vbd;
   5.257      rb_node_t         *rb;
   5.258 -    blkif_extent_le_t *x, *t;
   5.259      blkif_vdev_t       vdevice = destroy->vdevice;
   5.260  
   5.261      blkif = blkif_find_by_handle(destroy->domid, destroy->blkif_handle);
   5.262 @@ -299,19 +145,8 @@ void vbd_destroy(blkif_be_vbd_destroy_t 
   5.263      spin_lock(&blkif->vbd_lock);
   5.264      rb_erase(rb, &blkif->vbd_rb);
   5.265      spin_unlock(&blkif->vbd_lock);
   5.266 -
   5.267 -    x = vbd->extents;
   5.268 +    bdev_put(vbd->bdev);
   5.269      kfree(vbd);
   5.270 -
   5.271 -    while ( x != NULL )
   5.272 -    {
   5.273 -        t = x->next;
   5.274 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
   5.275 -        blkdev_put(x->bdev);
   5.276 -#endif
   5.277 -        kfree(x);
   5.278 -        x = t;
   5.279 -    }
   5.280  }
   5.281  
   5.282  
   5.283 @@ -319,46 +154,28 @@ void destroy_all_vbds(blkif_t *blkif)
   5.284  {
   5.285      vbd_t             *vbd;
   5.286      rb_node_t         *rb;
   5.287 -    blkif_extent_le_t *x, *t;
   5.288  
   5.289      spin_lock(&blkif->vbd_lock);
   5.290  
   5.291      while ( (rb = blkif->vbd_rb.rb_node) != NULL )
   5.292      {
   5.293          vbd = rb_entry(rb, vbd_t, rb);
   5.294 -
   5.295          rb_erase(rb, &blkif->vbd_rb);
   5.296 -        x = vbd->extents;
   5.297 +        spin_unlock(&blkif->vbd_lock);
   5.298 +        bdev_put(vbd->bdev);
   5.299          kfree(vbd);
   5.300 -        
   5.301 -        while ( x != NULL )
   5.302 -        {
   5.303 -            t = x->next;
   5.304 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
   5.305 -            blkdev_put(x->bdev);
   5.306 -#endif
   5.307 -            kfree(x);
   5.308 -            x = t;
   5.309 -        }          
   5.310 +        spin_lock(&blkif->vbd_lock);
   5.311      }
   5.312  
   5.313      spin_unlock(&blkif->vbd_lock);
   5.314  }
   5.315  
   5.316  
   5.317 -static int vbd_probe_single(blkif_t *blkif, vdisk_t *vbd_info, vbd_t *vbd)
   5.318 +static void vbd_probe_single(blkif_t *blkif, vdisk_t *vbd_info, vbd_t *vbd)
   5.319  {
   5.320 -    blkif_extent_le_t *x; 
   5.321 -
   5.322 -    vbd_info->device = vbd->vdevice; 
   5.323 -    vbd_info->info   = vbd->type;
   5.324 -    if ( vbd->readonly )
   5.325 -        vbd_info->info |= VDISK_FLAG_RO; 
   5.326 -    vbd_info->capacity = 0ULL;
   5.327 -    for ( x = vbd->extents; x != NULL; x = x->next )
   5.328 -        vbd_info->capacity += x->extent.sector_length; 
   5.329 -        
   5.330 -    return 0;
   5.331 +    vbd_info->device   = vbd->vdevice; 
   5.332 +    vbd_info->info     = vbd->type | (vbd->readonly ? VDISK_FLAG_RO : 0);
   5.333 +    vbd_info->capacity = vbd_sz(vbd);
   5.334  }
   5.335  
   5.336  
   5.337 @@ -380,9 +197,7 @@ int vbd_probe(blkif_t *blkif, vdisk_t *v
   5.338      for ( ; ; )
   5.339      {
   5.340          /* STEP 2. Dealt with left subtree. Now process current node. */
   5.341 -        if ( (rc = vbd_probe_single(blkif, &vbd_info[nr_vbds], 
   5.342 -                                    rb_entry(rb, vbd_t, rb))) != 0 )
   5.343 -            goto out;
   5.344 +        vbd_probe_single(blkif, &vbd_info[nr_vbds], rb_entry(rb, vbd_t, rb));
   5.345          if ( ++nr_vbds == max_vbds )
   5.346              goto out;
   5.347  
   5.348 @@ -417,11 +232,9 @@ int vbd_probe(blkif_t *blkif, vdisk_t *v
   5.349  
   5.350  int vbd_translate(phys_seg_t *pseg, blkif_t *blkif, int operation)
   5.351  {
   5.352 -    blkif_extent_le_t *x; 
   5.353 -    vbd_t             *vbd;
   5.354 -    rb_node_t         *rb;
   5.355 -    blkif_sector_t     sec_off;
   5.356 -    unsigned long      nr_secs;
   5.357 +    vbd_t     *vbd;
   5.358 +    rb_node_t *rb;
   5.359 +    int        rc = -EACCES;
   5.360  
   5.361      /* Take the vbd_lock because another thread could be updating the tree. */
   5.362      spin_lock(&blkif->vbd_lock);
   5.363 @@ -440,138 +253,22 @@ int vbd_translate(phys_seg_t *pseg, blki
   5.364  
   5.365      DPRINTK("vbd_translate; domain %u attempted to access "
   5.366              "non-existent VBD.\n", blkif->domid);
   5.367 -
   5.368 -    spin_unlock(&blkif->vbd_lock);
   5.369 -    return -ENODEV; 
   5.370 +    rc = -ENODEV;
   5.371 +    goto out;
   5.372  
   5.373   found:
   5.374  
   5.375      if ( (operation == WRITE) && vbd->readonly )
   5.376 -    {
   5.377 -        spin_unlock(&blkif->vbd_lock);
   5.378 -        return -EACCES; 
   5.379 -    }
   5.380 -
   5.381 -    /*
   5.382 -     * Now iterate through the list of blkif_extents, working out which should 
   5.383 -     * be used to perform the translation.
   5.384 -     */
   5.385 -    sec_off = pseg->sector_number; 
   5.386 -    nr_secs = pseg->nr_sects;
   5.387 -    for ( x = vbd->extents; x != NULL; x = x->next )
   5.388 -    { 
   5.389 -        if ( sec_off < x->extent.sector_length )
   5.390 -        {
   5.391 -            pseg->dev  = x->extent.device;
   5.392 -            pseg->bdev = x->bdev;
   5.393 -            pseg->sector_number = x->extent.sector_start + sec_off;
   5.394 -            if ( unlikely((sec_off + nr_secs) > x->extent.sector_length) )
   5.395 -                goto overrun;
   5.396 -            spin_unlock(&blkif->vbd_lock);
   5.397 -            return 1;
   5.398 -        } 
   5.399 -        sec_off -= x->extent.sector_length; 
   5.400 -    }
   5.401 -
   5.402 -    DPRINTK("vbd_translate: end of vbd.\n");
   5.403 -    spin_unlock(&blkif->vbd_lock);
   5.404 -    return -EACCES; 
   5.405 +        goto out;
   5.406  
   5.407 -    /*
   5.408 -     * Here we deal with overrun onto the following extent. We don't deal with 
   5.409 -     * overrun of more than one boundary since each request is restricted to 
   5.410 -     * 2^9 512-byte sectors, so it should be trivial for control software to 
   5.411 -     * ensure that extents are large enough to prevent excessive overrun.
   5.412 -     */
   5.413 - overrun:
   5.414 -
   5.415 -    /* Adjust length of first chunk to run to end of first extent. */
   5.416 -    pseg[0].nr_sects = x->extent.sector_length - sec_off;
   5.417 -
   5.418 -    /* Set second chunk buffer and length to start where first chunk ended. */
   5.419 -    pseg[1].buffer   = pseg[0].buffer + (pseg[0].nr_sects << 9);
   5.420 -    pseg[1].nr_sects = nr_secs - pseg[0].nr_sects;
   5.421 -
   5.422 -    /* Now move to the next extent. Check it exists and is long enough! */
   5.423 -    if ( unlikely((x = x->next) == NULL) || 
   5.424 -         unlikely(x->extent.sector_length < pseg[1].nr_sects) )
   5.425 -    {
   5.426 -        DPRINTK("vbd_translate: multiple overruns or end of vbd.\n");
   5.427 -        spin_unlock(&blkif->vbd_lock);
   5.428 -        return -EACCES;
   5.429 -    }
   5.430 -
   5.431 -    /* Store the real device and start sector for the second chunk. */
   5.432 -    pseg[1].dev           = x->extent.device;
   5.433 -    pseg[1].bdev          = x->bdev;
   5.434 -    pseg[1].sector_number = x->extent.sector_start;
   5.435 -    
   5.436 -    spin_unlock(&blkif->vbd_lock);
   5.437 -    return 2;
   5.438 -}
   5.439 -
   5.440 +    if ( unlikely((pseg->sector_number + pseg->nr_sects) > vbd_sz(vbd)) )
   5.441 +        goto out;
   5.442  
   5.443 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
   5.444 -
   5.445 -#define MAJOR_XEN(dev) ((dev)>>8)
   5.446 -#define MINOR_XEN(dev) ((dev) & 0xff)
   5.447 +    pseg->dev  = vbd->pdevice;
   5.448 +    pseg->bdev = vbd->bdev;
   5.449 +    rc = 1;
   5.450  
   5.451 -#ifndef FANCY_REMAPPING
   5.452 -static dev_t vbd_map_devnum(blkif_pdev_t cookie)
   5.453 -{
   5.454 -    int major = MAJOR_XEN(cookie);
   5.455 -    int minor = MINOR_XEN(cookie);
   5.456 -
   5.457 -    return MKDEV(major, minor);
   5.458 + out:
   5.459 +    spin_unlock(&blkif->vbd_lock);
   5.460 +    return rc;
   5.461  }
   5.462 -#else
   5.463 -#define XEN_IDE0_MAJOR IDE0_MAJOR
   5.464 -#define XEN_IDE1_MAJOR IDE1_MAJOR
   5.465 -#define XEN_IDE2_MAJOR IDE2_MAJOR
   5.466 -#define XEN_IDE3_MAJOR IDE3_MAJOR
   5.467 -#define XEN_IDE4_MAJOR IDE4_MAJOR
   5.468 -#define XEN_IDE5_MAJOR IDE5_MAJOR
   5.469 -#define XEN_IDE6_MAJOR IDE6_MAJOR
   5.470 -#define XEN_IDE7_MAJOR IDE7_MAJOR
   5.471 -#define XEN_IDE8_MAJOR IDE8_MAJOR
   5.472 -#define XEN_IDE9_MAJOR IDE9_MAJOR
   5.473 -#define XEN_SCSI_DISK0_MAJOR SCSI_DISK0_MAJOR
   5.474 -#define XEN_SCSI_DISK1_MAJOR SCSI_DISK1_MAJOR
   5.475 -#define XEN_SCSI_DISK2_MAJOR SCSI_DISK2_MAJOR
   5.476 -#define XEN_SCSI_DISK3_MAJOR SCSI_DISK3_MAJOR
   5.477 -#define XEN_SCSI_DISK4_MAJOR SCSI_DISK4_MAJOR
   5.478 -#define XEN_SCSI_DISK5_MAJOR SCSI_DISK5_MAJOR
   5.479 -#define XEN_SCSI_DISK6_MAJOR SCSI_DISK6_MAJOR
   5.480 -#define XEN_SCSI_DISK7_MAJOR SCSI_DISK7_MAJOR
   5.481 -#define XEN_SCSI_CDROM_MAJOR SCSI_CDROM_MAJOR
   5.482 -
   5.483 -static dev_t vbd_map_devnum(blkif_pdev_t cookie)
   5.484 -{
   5.485 -    int new_major;
   5.486 -    int major = MAJOR_XEN(cookie);
   5.487 -    int minor = MINOR_XEN(cookie);
   5.488 -
   5.489 -    switch (major) {
   5.490 -    case XEN_IDE0_MAJOR: new_major = IDE0_MAJOR; break;
   5.491 -    case XEN_IDE1_MAJOR: new_major = IDE1_MAJOR; break;
   5.492 -    case XEN_IDE2_MAJOR: new_major = IDE2_MAJOR; break;
   5.493 -    case XEN_IDE3_MAJOR: new_major = IDE3_MAJOR; break;
   5.494 -    case XEN_IDE4_MAJOR: new_major = IDE4_MAJOR; break;
   5.495 -    case XEN_IDE5_MAJOR: new_major = IDE5_MAJOR; break;
   5.496 -    case XEN_IDE6_MAJOR: new_major = IDE6_MAJOR; break;
   5.497 -    case XEN_IDE7_MAJOR: new_major = IDE7_MAJOR; break;
   5.498 -    case XEN_IDE8_MAJOR: new_major = IDE8_MAJOR; break;
   5.499 -    case XEN_IDE9_MAJOR: new_major = IDE9_MAJOR; break;
   5.500 -    case XEN_SCSI_DISK0_MAJOR: new_major = SCSI_DISK0_MAJOR; break;
   5.501 -    case XEN_SCSI_DISK1_MAJOR ... XEN_SCSI_DISK7_MAJOR:
   5.502 -        new_major = SCSI_DISK1_MAJOR + major - XEN_SCSI_DISK1_MAJOR;
   5.503 -        break;
   5.504 -    case XEN_SCSI_CDROM_MAJOR: new_major = SCSI_CDROM_MAJOR; break;
   5.505 -    default: new_major = 0; break;
   5.506 -    }
   5.507 -
   5.508 -    return MKDEV(new_major, minor);
   5.509 -}
   5.510 -#endif
   5.511 -
   5.512 -#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION_CODE(2,6,0) */
     6.1 --- a/linux-2.6.11-xen-sparse/drivers/xen/blkfront/blkfront.c	Thu Mar 31 09:56:18 2005 +0000
     6.2 +++ b/linux-2.6.11-xen-sparse/drivers/xen/blkfront/blkfront.c	Thu Mar 31 11:00:46 2005 +0000
     6.3 @@ -1322,21 +1322,15 @@ static void blkif_ctrlif_rx(ctrl_msg_t *
     6.4      switch ( msg->subtype )
     6.5      {
     6.6      case CMSG_BLKIF_FE_INTERFACE_STATUS:
     6.7 -        if ( msg->length != sizeof(blkif_fe_interface_status_t) )
     6.8 -            goto parse_error;
     6.9          blkif_status((blkif_fe_interface_status_t *)
    6.10                       &msg->msg[0]);
    6.11 -        break;        
    6.12 +        break;
    6.13      default:
    6.14 -        goto parse_error;
    6.15 +        msg->length = 0;
    6.16 +        break;
    6.17      }
    6.18  
    6.19      ctrl_if_send_response(msg);
    6.20 -    return;
    6.21 -
    6.22 - parse_error:
    6.23 -    msg->length = 0;
    6.24 -    ctrl_if_send_response(msg);
    6.25  }
    6.26  
    6.27  int wait_for_blkif(void)
     7.1 --- a/linux-2.6.11-xen-sparse/drivers/xen/blktap/blktap_controlmsg.c	Thu Mar 31 09:56:18 2005 +0000
     7.2 +++ b/linux-2.6.11-xen-sparse/drivers/xen/blktap/blktap_controlmsg.c	Thu Mar 31 11:00:46 2005 +0000
     7.3 @@ -426,15 +426,15 @@ void blkif_ctrlif_rx(ctrl_msg_t *msg, un
     7.4          switch ( msg->subtype )
     7.5          {
     7.6          case CMSG_BLKIF_FE_INTERFACE_STATUS:
     7.7 -            if ( msg->length != sizeof(blkif_fe_interface_status_t) )
     7.8 -                goto parse_error;
     7.9              blkif_ptbe_status((blkif_fe_interface_status_t *) &msg->msg[0]);
    7.10 -            break;        
    7.11 +            break;
    7.12  
    7.13          default:
    7.14              goto parse_error;
    7.15          }
    7.16  
    7.17 +        break;
    7.18 +
    7.19      case CMSG_BLKIF_BE:
    7.20          
    7.21          /* send a copy of the message to user if wanted */
    7.22 @@ -448,23 +448,15 @@ void blkif_ctrlif_rx(ctrl_msg_t *msg, un
    7.23          switch ( msg->subtype )
    7.24          {
    7.25          case CMSG_BLKIF_BE_CREATE:
    7.26 -            if ( msg->length != sizeof(blkif_be_create_t) )
    7.27 -                goto parse_error;
    7.28              blkif_ptfe_create((blkif_be_create_t *)&msg->msg[0]);
    7.29              break; 
    7.30          case CMSG_BLKIF_BE_DESTROY:
    7.31 -            if ( msg->length != sizeof(blkif_be_destroy_t) )
    7.32 -                goto parse_error;
    7.33              blkif_ptfe_destroy((blkif_be_destroy_t *)&msg->msg[0]);
    7.34              break;        
    7.35          case CMSG_BLKIF_BE_CONNECT:
    7.36 -            if ( msg->length != sizeof(blkif_be_connect_t) )
    7.37 -                goto parse_error;
    7.38              blkif_ptfe_connect((blkif_be_connect_t *)&msg->msg[0]);
    7.39              break;        
    7.40          case CMSG_BLKIF_BE_DISCONNECT:
    7.41 -            if ( msg->length != sizeof(blkif_be_disconnect_t) )
    7.42 -                goto parse_error;
    7.43              if ( !blkif_ptfe_disconnect((blkif_be_disconnect_t *)&msg->msg[0],
    7.44                      msg->id) )
    7.45                  return;
    7.46 @@ -482,19 +474,11 @@ void blkif_ctrlif_rx(ctrl_msg_t *msg, un
    7.47              ((blkif_be_vbd_destroy_t *)&msg->msg[0])->status
    7.48                  = BLKIF_BE_STATUS_OKAY;
    7.49              break;
    7.50 -        case CMSG_BLKIF_BE_VBD_GROW:
    7.51 -            DPRINTK("PT got VBD_GROW\n");
    7.52 -            ((blkif_be_vbd_grow_t *)&msg->msg[0])->status
    7.53 -                = BLKIF_BE_STATUS_OKAY;
    7.54 -            break;
    7.55 -        case CMSG_BLKIF_BE_VBD_SHRINK:
    7.56 -            DPRINTK("PT got VBD_SHRINK\n");
    7.57 -            ((blkif_be_vbd_shrink_t *)&msg->msg[0])->status
    7.58 -                = BLKIF_BE_STATUS_OKAY;
    7.59 -            break;
    7.60          default:
    7.61              goto parse_error;
    7.62          }
    7.63 +
    7.64 +        break;
    7.65      }
    7.66  
    7.67      ctrl_if_send_response(msg);
     8.1 --- a/linux-2.6.11-xen-sparse/drivers/xen/netback/control.c	Thu Mar 31 09:56:18 2005 +0000
     8.2 +++ b/linux-2.6.11-xen-sparse/drivers/xen/netback/control.c	Thu Mar 31 11:00:46 2005 +0000
     8.3 @@ -13,43 +13,29 @@ static void netif_ctrlif_rx(ctrl_msg_t *
     8.4      switch ( msg->subtype )
     8.5      {
     8.6      case CMSG_NETIF_BE_CREATE:
     8.7 -        if ( msg->length != sizeof(netif_be_create_t) )
     8.8 -            goto parse_error;
     8.9          netif_create((netif_be_create_t *)&msg->msg[0]);
    8.10          break;        
    8.11      case CMSG_NETIF_BE_DESTROY:
    8.12 -        if ( msg->length != sizeof(netif_be_destroy_t) )
    8.13 -            goto parse_error;
    8.14          netif_destroy((netif_be_destroy_t *)&msg->msg[0]);
    8.15          break;  
    8.16      case CMSG_NETIF_BE_CREDITLIMIT:
    8.17 -        if ( msg->length != sizeof(netif_be_creditlimit_t) )
    8.18 -            goto parse_error;
    8.19          netif_creditlimit((netif_be_creditlimit_t *)&msg->msg[0]);
    8.20          break;       
    8.21      case CMSG_NETIF_BE_CONNECT:
    8.22 -        if ( msg->length != sizeof(netif_be_connect_t) )
    8.23 -            goto parse_error;
    8.24          netif_connect((netif_be_connect_t *)&msg->msg[0]);
    8.25          break; 
    8.26      case CMSG_NETIF_BE_DISCONNECT:
    8.27 -        if ( msg->length != sizeof(netif_be_disconnect_t) )
    8.28 -            goto parse_error;
    8.29          if ( !netif_disconnect((netif_be_disconnect_t *)&msg->msg[0],msg->id) )
    8.30              return; /* Sending the response is deferred until later. */
    8.31          break;        
    8.32      default:
    8.33 -        goto parse_error;
    8.34 +        DPRINTK("Parse error while reading message subtype %d, len %d\n",
    8.35 +                msg->subtype, msg->length);
    8.36 +        msg->length = 0;
    8.37 +        break;
    8.38      }
    8.39  
    8.40      ctrl_if_send_response(msg);
    8.41 -    return;
    8.42 -
    8.43 - parse_error:
    8.44 -    DPRINTK("Parse error while reading message subtype %d, len %d\n",
    8.45 -            msg->subtype, msg->length);
    8.46 -    msg->length = 0;
    8.47 -    ctrl_if_send_response(msg);
    8.48  }
    8.49  
    8.50  void netif_ctrlif_init(void)
     9.1 --- a/linux-2.6.11-xen-sparse/drivers/xen/netfront/netfront.c	Thu Mar 31 09:56:18 2005 +0000
     9.2 +++ b/linux-2.6.11-xen-sparse/drivers/xen/netfront/netfront.c	Thu Mar 31 11:00:46 2005 +0000
     9.3 @@ -1097,18 +1097,13 @@ static void netif_ctrlif_rx(ctrl_msg_t *
     9.4  
     9.5      switch (msg->subtype) {
     9.6      case CMSG_NETIF_FE_INTERFACE_STATUS:
     9.7 -        if (msg->length != sizeof(netif_fe_interface_status_t))
     9.8 -            goto error;
     9.9          netif_interface_status((netif_fe_interface_status_t *) &msg->msg[0]);
    9.10          break;
    9.11  
    9.12      case CMSG_NETIF_FE_DRIVER_STATUS:
    9.13 -        if (msg->length != sizeof(netif_fe_driver_status_t))
    9.14 -            goto error;
    9.15          netif_driver_status((netif_fe_driver_status_t *) &msg->msg[0]);
    9.16          break;
    9.17  
    9.18 -    error:
    9.19      default:
    9.20          msg->length = 0;
    9.21          break;
    10.1 --- a/linux-2.6.11-xen-sparse/drivers/xen/usbback/control.c	Thu Mar 31 09:56:18 2005 +0000
    10.2 +++ b/linux-2.6.11-xen-sparse/drivers/xen/usbback/control.c	Thu Mar 31 11:00:46 2005 +0000
    10.3 @@ -15,48 +15,32 @@ static void usbif_ctrlif_rx(ctrl_msg_t *
    10.4      switch ( msg->subtype )
    10.5      {
    10.6      case CMSG_USBIF_BE_CREATE:
    10.7 -        if ( msg->length != sizeof(usbif_be_create_t) )
    10.8 -            goto parse_error;
    10.9          usbif_create((usbif_be_create_t *)&msg->msg[0]);
   10.10          break;        
   10.11      case CMSG_USBIF_BE_DESTROY:
   10.12 -        if ( msg->length != sizeof(usbif_be_destroy_t) )
   10.13 -            goto parse_error;
   10.14          usbif_destroy((usbif_be_destroy_t *)&msg->msg[0]);
   10.15          break;        
   10.16      case CMSG_USBIF_BE_CONNECT:
   10.17 -        if ( msg->length != sizeof(usbif_be_connect_t) )
   10.18 -            goto parse_error;
   10.19          usbif_connect((usbif_be_connect_t *)&msg->msg[0]);
   10.20          break;        
   10.21      case CMSG_USBIF_BE_DISCONNECT:
   10.22 -        if ( msg->length != sizeof(usbif_be_disconnect_t) )
   10.23 -            goto parse_error;
   10.24          if ( !usbif_disconnect((usbif_be_disconnect_t *)&msg->msg[0],msg->id) )
   10.25              return; /* Sending the response is deferred until later. */
   10.26          break;        
   10.27      case CMSG_USBIF_BE_CLAIM_PORT:
   10.28 -        if ( msg->length != sizeof(usbif_be_claim_port_t) )
   10.29 -            goto parse_error;
   10.30  	usbif_claim_port((usbif_be_claim_port_t *)&msg->msg[0]);
   10.31          break;
   10.32      case CMSG_USBIF_BE_RELEASE_PORT:
   10.33 -        if ( msg->length != sizeof(usbif_be_release_port_t) )
   10.34 -            goto parse_error;
   10.35          usbif_release_port((usbif_be_release_port_t *)&msg->msg[0]);
   10.36          break;
   10.37      default:
   10.38 -        goto parse_error;
   10.39 +        DPRINTK("Parse error while reading message subtype %d, len %d\n",
   10.40 +                msg->subtype, msg->length);
   10.41 +        msg->length = 0;
   10.42 +        break;
   10.43      }
   10.44  
   10.45      ctrl_if_send_response(msg);
   10.46 -    return;
   10.47 -
   10.48 - parse_error:
   10.49 -    DPRINTK("Parse error while reading message subtype %d, len %d\n",
   10.50 -            msg->subtype, msg->length);
   10.51 -    msg->length = 0;
   10.52 -    ctrl_if_send_response(msg);
   10.53  }
   10.54  
   10.55  void usbif_ctrlif_init(void)
    11.1 --- a/linux-2.6.11-xen-sparse/drivers/xen/usbfront/usbfront.c	Thu Mar 31 09:56:18 2005 +0000
    11.2 +++ b/linux-2.6.11-xen-sparse/drivers/xen/usbfront/usbfront.c	Thu Mar 31 11:00:46 2005 +0000
    11.3 @@ -1629,23 +1629,17 @@ static void usbif_ctrlif_rx(ctrl_msg_t *
    11.4      switch ( msg->subtype )
    11.5      {
    11.6      case CMSG_USBIF_FE_INTERFACE_STATUS_CHANGED:
    11.7 -        if ( msg->length != sizeof(usbif_fe_interface_status_changed_t) )
    11.8 -            goto parse_error;
    11.9          usbif_status_change((usbif_fe_interface_status_changed_t *)
   11.10                              &msg->msg[0]);
   11.11 -        break;        
   11.12 +        break;
   11.13  
   11.14          /* New interface...? */
   11.15      default:
   11.16 -        goto parse_error;
   11.17 +        msg->length = 0;
   11.18 +        break;
   11.19      }
   11.20  
   11.21      ctrl_if_send_response(msg);
   11.22 -    return;
   11.23 -
   11.24 - parse_error:
   11.25 -    msg->length = 0;
   11.26 -    ctrl_if_send_response(msg);
   11.27  }
   11.28  
   11.29  static void send_driver_up(void)
    12.1 --- a/tools/blktap/blkdump.c	Thu Mar 31 09:56:18 2005 +0000
    12.2 +++ b/tools/blktap/blkdump.c	Thu Mar 31 11:00:46 2005 +0000
    12.3 @@ -74,14 +74,6 @@ int control_print(control_msg_t *msg)
    12.4                  ((blkif_be_vbd_grow_t *)msg->msg)->extent.sector_length,
    12.5                  ((blkif_be_vbd_grow_t *)msg->msg)->extent.device);
    12.6          break;
    12.7 -    case CMSG_BLKIF_BE_VBD_SHRINK:
    12.8 -        if ( msg->length != sizeof(blkif_be_vbd_shrink_t) )
    12.9 -            goto parse_error;
   12.10 -        printf("[CONTROL_MSG] CMSG_BLKIF_BE_VBD_SHRINK(d:%d,h:%d,v:%d)\n",
   12.11 -                ((blkif_be_vbd_shrink_t *)msg->msg)->domid,
   12.12 -                ((blkif_be_vbd_shrink_t *)msg->msg)->blkif_handle,
   12.13 -                ((blkif_be_vbd_shrink_t *)msg->msg)->vdevice);
   12.14 -        break;
   12.15      default:
   12.16          goto parse_error;
   12.17      }
    13.1 --- a/tools/python/xen/lowlevel/xu/xu.c	Thu Mar 31 09:56:18 2005 +0000
    13.2 +++ b/tools/python/xen/lowlevel/xu/xu.c	Thu Mar 31 11:00:46 2005 +0000
    13.3 @@ -659,6 +659,7 @@ static PyObject *xu_message_get_payload(
    13.4      case TYPE(CMSG_BLKIF_BE, CMSG_BLKIF_BE_VBD_CREATE):
    13.5          C2P(blkif_be_vbd_create_t, domid,        Int, Long);
    13.6          C2P(blkif_be_vbd_create_t, blkif_handle, Int, Long);
    13.7 +        C2P(blkif_be_vbd_create_t, pdevice,      Int, Long);
    13.8          C2P(blkif_be_vbd_create_t, vdevice,      Int, Long);
    13.9          C2P(blkif_be_vbd_create_t, readonly,     Int, Long);
   13.10          C2P(blkif_be_vbd_create_t, status,       Int, Long);
   13.11 @@ -669,23 +670,6 @@ static PyObject *xu_message_get_payload(
   13.12          C2P(blkif_be_vbd_destroy_t, vdevice,      Int, Long);
   13.13          C2P(blkif_be_vbd_destroy_t, status,       Int, Long);
   13.14          return dict;
   13.15 -    case TYPE(CMSG_BLKIF_BE, CMSG_BLKIF_BE_VBD_GROW):
   13.16 -        C2P(blkif_be_vbd_grow_t, domid,         Int, Long);
   13.17 -        C2P(blkif_be_vbd_grow_t, blkif_handle,  Int, Long);
   13.18 -        C2P(blkif_be_vbd_grow_t, vdevice,       Int, Long);
   13.19 -        C2P(blkif_be_vbd_grow_t, extent.sector_start, 
   13.20 -             Long, UnsignedLongLong);
   13.21 -        C2P(blkif_be_vbd_grow_t, extent.sector_length, 
   13.22 -             Long, UnsignedLongLong);
   13.23 -        C2P(blkif_be_vbd_grow_t, extent.device, Int, Long);
   13.24 -        C2P(blkif_be_vbd_grow_t, status,        Int, Long);
   13.25 -        return dict;
   13.26 -    case TYPE(CMSG_BLKIF_BE, CMSG_BLKIF_BE_VBD_SHRINK):
   13.27 -        C2P(blkif_be_vbd_shrink_t, domid,        Int, Long);
   13.28 -        C2P(blkif_be_vbd_shrink_t, blkif_handle, Int, Long);
   13.29 -        C2P(blkif_be_vbd_shrink_t, vdevice,      Int, Long);
   13.30 -        C2P(blkif_be_vbd_shrink_t, status,       Int, Long);
   13.31 -        return dict;
   13.32      case TYPE(CMSG_BLKIF_BE, CMSG_BLKIF_BE_DRIVER_STATUS):
   13.33          C2P(blkif_be_driver_status_t, status, Int, Long);
   13.34          return dict;
   13.35 @@ -894,6 +878,7 @@ static PyObject *xu_message_new(PyObject
   13.36      case TYPE(CMSG_BLKIF_BE, CMSG_BLKIF_BE_VBD_CREATE):
   13.37          P2C(blkif_be_vbd_create_t, domid,        u32);
   13.38          P2C(blkif_be_vbd_create_t, blkif_handle, u32);
   13.39 +        P2C(blkif_be_vbd_create_t, pdevice,      blkif_pdev_t);
   13.40          P2C(blkif_be_vbd_create_t, vdevice,      blkif_vdev_t);
   13.41          P2C(blkif_be_vbd_create_t, readonly,     u16);
   13.42          break;
   13.43 @@ -902,19 +887,6 @@ static PyObject *xu_message_new(PyObject
   13.44          P2C(blkif_be_vbd_destroy_t, blkif_handle, u32);
   13.45          P2C(blkif_be_vbd_destroy_t, vdevice,      blkif_vdev_t);
   13.46          break;
   13.47 -    case TYPE(CMSG_BLKIF_BE, CMSG_BLKIF_BE_VBD_GROW):
   13.48 -        P2C(blkif_be_vbd_grow_t, domid,                u32);
   13.49 -        P2C(blkif_be_vbd_grow_t, blkif_handle,         u32);
   13.50 -        P2C(blkif_be_vbd_grow_t, vdevice,              blkif_vdev_t);
   13.51 -        P2C(blkif_be_vbd_grow_t, extent.sector_start,  blkif_sector_t);
   13.52 -        P2C(blkif_be_vbd_grow_t, extent.sector_length, blkif_sector_t);
   13.53 -        P2C(blkif_be_vbd_grow_t, extent.device,        blkif_pdev_t);
   13.54 -        break;
   13.55 -    case TYPE(CMSG_BLKIF_BE, CMSG_BLKIF_BE_VBD_SHRINK):
   13.56 -        P2C(blkif_be_vbd_shrink_t, domid,        u32);
   13.57 -        P2C(blkif_be_vbd_shrink_t, blkif_handle, u32);
   13.58 -        P2C(blkif_be_vbd_shrink_t, vdevice,      blkif_vdev_t);
   13.59 -        break;
   13.60      case TYPE(CMSG_NETIF_FE, CMSG_NETIF_FE_INTERFACE_STATUS):
   13.61          P2C(netif_fe_interface_status_t, handle, u32);
   13.62          P2C(netif_fe_interface_status_t, status, u32);
    14.1 --- a/tools/python/xen/xend/server/blkif.py	Thu Mar 31 09:56:18 2005 +0000
    14.2 +++ b/tools/python/xen/xend/server/blkif.py	Thu Mar 31 11:00:46 2005 +0000
    14.3 @@ -449,46 +449,17 @@ class BlkDev(controller.SplitDev):
    14.4          msg = packMsg('blkif_be_vbd_create_t',
    14.5                        { 'domid'        : self.controller.dom,
    14.6                          'blkif_handle' : backend.handle,
    14.7 +                        'pdevice'      : self.device,
    14.8                          'vdevice'      : self.vdev,
    14.9                          'readonly'     : self.readonly() })
   14.10          backend.writeRequest(msg, response=d)
   14.11          return d
   14.12          
   14.13      def respond_be_vbd_create(self, msg):
   14.14 -        """Response handler for a be_vbd_create message.
   14.15 -        Tries to grow the vbd.
   14.16 -
   14.17 -        @param msg: message
   14.18 -        @type  msg: xu message
   14.19 -        """
   14.20          val = unpackMsg('blkif_be_vbd_create_t', msg)
   14.21 -        d = self.send_be_vbd_grow()
   14.22 -        d.addCallback(self.respond_be_vbd_grow)
   14.23 -        return d
   14.24 -    
   14.25 -    def send_be_vbd_grow(self):
   14.26 -        d = defer.Deferred()
   14.27 -        backend = self.getBackendInterface()
   14.28 -        msg = packMsg('blkif_be_vbd_grow_t',
   14.29 -                      { 'domid'                : self.controller.dom,
   14.30 -                        'blkif_handle'         : backend.handle,
   14.31 -                        'vdevice'              : self.vdev,
   14.32 -                        'extent.device'        : self.device,
   14.33 -                        'extent.sector_start'  : self.start_sector,
   14.34 -                        'extent.sector_length' : self.nr_sectors })
   14.35 -        backend.writeRequest(msg, response=d)
   14.36 -        return d
   14.37 -
   14.38 -    def respond_be_vbd_grow(self, msg):
   14.39 -        """Response handler for a be_vbd_grow message.
   14.40 -
   14.41 -        @param msg: message
   14.42 -        @type  msg: xu message
   14.43 -        """
   14.44 -        val = unpackMsg('blkif_be_vbd_grow_t', msg)
   14.45  	status = val['status']
   14.46  	if status != BLKIF_BE_STATUS_OKAY:
   14.47 -            raise XendError("Adding extent to vbd failed: device %s, error %d"
   14.48 +            raise XendError("Creating vbd failed: device %s, error %d"
   14.49                              % (sxp.to_string(self.config), status))
   14.50          return self
   14.51  
    15.1 --- a/tools/python/xen/xend/server/messages.py	Thu Mar 31 09:56:18 2005 +0000
    15.2 +++ b/tools/python/xen/xend/server/messages.py	Thu Mar 31 11:00:46 2005 +0000
    15.3 @@ -41,8 +41,6 @@ CMSG_BLKIF_BE_CONNECT               =  2
    15.4  CMSG_BLKIF_BE_DISCONNECT            =  3
    15.5  CMSG_BLKIF_BE_VBD_CREATE            =  4
    15.6  CMSG_BLKIF_BE_VBD_DESTROY           =  5
    15.7 -CMSG_BLKIF_BE_VBD_GROW              =  6
    15.8 -CMSG_BLKIF_BE_VBD_SHRINK            =  7
    15.9  CMSG_BLKIF_BE_DRIVER_STATUS         = 32
   15.10  
   15.11  BLKIF_DRIVER_STATUS_DOWN            =  0
   15.12 @@ -61,7 +59,7 @@ BLKIF_BE_STATUS_INTERFACE_CONNECTED =  4
   15.13  BLKIF_BE_STATUS_VBD_EXISTS          =  5
   15.14  BLKIF_BE_STATUS_VBD_NOT_FOUND       =  6
   15.15  BLKIF_BE_STATUS_OUT_OF_MEMORY       =  7
   15.16 -BLKIF_BE_STATUS_EXTENT_NOT_FOUND    =  8
   15.17 +BLKIF_BE_STATUS_PHYSDEV_NOT_FOUND   =  8
   15.18  BLKIF_BE_STATUS_MAPPING_ERROR       =  9
   15.19  
   15.20  blkif_formats = {
   15.21 @@ -86,11 +84,6 @@ blkif_formats = {
   15.22      (CMSG_BLKIF_BE, CMSG_BLKIF_BE_VBD_CREATE),
   15.23      # Create a vbd device.
   15.24  
   15.25 -    'blkif_be_vbd_grow_t':
   15.26 -    (CMSG_BLKIF_BE, CMSG_BLKIF_BE_VBD_GROW),
   15.27 -    # Change the size of a vbd device. Remove?
   15.28 -    # Do in one go in blkif_be_vbd_create_t.
   15.29 -
   15.30      'blkif_be_vbd_destroy_t':
   15.31      (CMSG_BLKIF_BE, CMSG_BLKIF_BE_VBD_DESTROY),
   15.32      # Destroy a vbd.
    16.1 --- a/tools/xcs/dump.c	Thu Mar 31 09:56:18 2005 +0000
    16.2 +++ b/tools/xcs/dump.c	Thu Mar 31 11:00:46 2005 +0000
    16.3 @@ -172,6 +172,7 @@ void dump_msg(const control_msg_t *msg, 
    16.4  			debug_begin("BLKIF_BE", "VBD_CREATE");
    16.5  			debug_field(load, domid, "%u");
    16.6  			debug_field(load, blkif_handle, "%u");
    16.7 +			debug_field(load, pdevice, "%u");
    16.8  			debug_field(load, vdevice, "%u");
    16.9  			debug_field(load, readonly, "%u");
   16.10  			debug_field(load, status, "%u");
   16.11 @@ -185,27 +186,6 @@ void dump_msg(const control_msg_t *msg, 
   16.12  			debug_field(load, vdevice, "%u");
   16.13  			debug_field(load, status, "%u");
   16.14  			debug_end("BLKIF_BE", "VBD_DESTROY");
   16.15 -		} else if (msg->subtype == CMSG_BLKIF_BE_VBD_GROW) {
   16.16 -			blkif_be_vbd_grow_t *load;
   16.17 -			load = (blkif_be_vbd_grow_t *)msg->msg;
   16.18 -			debug_begin("BLKIF_BE", "VBD_GROW");
   16.19 -			debug_field(load, domid, "%u");
   16.20 -			debug_field(load, blkif_handle, "%u");
   16.21 -			debug_field(load, extent.sector_start, "%llu");
   16.22 -			debug_field(load, extent.sector_length, "%llu");
   16.23 -			debug_field(load, extent.device, "%u");
   16.24 -			debug_field(load, vdevice, "%u");
   16.25 -			debug_field(load, status, "%u");
   16.26 -			debug_end("BLKIF_BE", "VBD_GROW");
   16.27 -		} else if (msg->subtype == CMSG_BLKIF_BE_VBD_SHRINK) {
   16.28 -			blkif_be_vbd_shrink_t *load;
   16.29 -			load = (blkif_be_vbd_shrink_t *)msg->msg;
   16.30 -			debug_begin("BLKIF_BE", "VBD_SHRINK");
   16.31 -			debug_field(load, domid, "%u");
   16.32 -			debug_field(load, blkif_handle, "%u");
   16.33 -			debug_field(load, vdevice, "%u");
   16.34 -			debug_field(load, status, "%u");
   16.35 -			debug_end("BLKIF_BE", "VBD_SHRINK");
   16.36  		} else if (msg->subtype == CMSG_BLKIF_BE_DRIVER_STATUS) {
   16.37  			blkif_be_driver_status_t *load;
   16.38  			load = (blkif_be_driver_status_t *)msg->msg;
    17.1 --- a/xen/include/public/io/domain_controller.h	Thu Mar 31 09:56:18 2005 +0000
    17.2 +++ b/xen/include/public/io/domain_controller.h	Thu Mar 31 11:00:46 2005 +0000
    17.3 @@ -169,8 +169,6 @@ typedef struct {
    17.4  #define CMSG_BLKIF_BE_DISCONNECT  3  /* Disconnect i/f from remote driver.   */
    17.5  #define CMSG_BLKIF_BE_VBD_CREATE  4  /* Create a new VBD for an interface.   */
    17.6  #define CMSG_BLKIF_BE_VBD_DESTROY 5  /* Delete a VBD from an interface.      */
    17.7 -#define CMSG_BLKIF_BE_VBD_GROW    6  /* Append an extent to a given VBD.     */
    17.8 -#define CMSG_BLKIF_BE_VBD_SHRINK  7  /* Remove last extent from a given VBD. */
    17.9  
   17.10  /* Messages to domain controller. */
   17.11  #define CMSG_BLKIF_BE_DRIVER_STATUS 32
   17.12 @@ -179,12 +177,6 @@ typedef struct {
   17.13   * Message request/response definitions for block-device messages.
   17.14   */
   17.15  
   17.16 -typedef struct {
   17.17 -    blkif_sector_t sector_start;   /*  0 */
   17.18 -    blkif_sector_t sector_length;  /*  8 */
   17.19 -    blkif_pdev_t   device;         /* 16 */
   17.20 -} PACKED blkif_extent_t; /* 20 bytes */
   17.21 -
   17.22  /* Non-specific 'okay' return. */
   17.23  #define BLKIF_BE_STATUS_OKAY                0
   17.24  /* Non-specific 'error' return. */
   17.25 @@ -196,7 +188,7 @@ typedef struct {
   17.26  #define BLKIF_BE_STATUS_VBD_EXISTS          5
   17.27  #define BLKIF_BE_STATUS_VBD_NOT_FOUND       6
   17.28  #define BLKIF_BE_STATUS_OUT_OF_MEMORY       7
   17.29 -#define BLKIF_BE_STATUS_EXTENT_NOT_FOUND    8
   17.30 +#define BLKIF_BE_STATUS_PHYSDEV_NOT_FOUND   8
   17.31  #define BLKIF_BE_STATUS_MAPPING_ERROR       9
   17.32  
   17.33  /* This macro can be used to create an array of descriptive error strings. */
   17.34 @@ -281,11 +273,12 @@ typedef struct {
   17.35      domid_t    domid;         /*  0: Identify blkdev interface.          */
   17.36      u16        __pad;
   17.37      u32        blkif_handle;  /*  4: ...ditto...                         */
   17.38 -    blkif_vdev_t vdevice;     /*  8: Interface-specific id for this VBD. */
   17.39 -    u16        readonly;      /* 10: Non-zero -> VBD isn't writable.     */
   17.40 +    blkif_pdev_t pdevice;     /*  8 */
   17.41 +    blkif_vdev_t vdevice;     /* 12: Interface-specific id for this VBD. */
   17.42 +    u16        readonly;      /* 14: Non-zero -> VBD isn't writable.     */
   17.43      /* OUT */
   17.44 -    u32        status;        /* 12 */
   17.45 -} PACKED blkif_be_vbd_create_t; /* 16 bytes */
   17.46 +    u32        status;        /* 16 */
   17.47 +} PACKED blkif_be_vbd_create_t; /* 20 bytes */
   17.48  
   17.49  /* CMSG_BLKIF_BE_VBD_DESTROY */
   17.50  typedef struct {
   17.51 @@ -299,31 +292,6 @@ typedef struct {
   17.52      u32        status;        /* 12 */
   17.53  } PACKED blkif_be_vbd_destroy_t; /* 16 bytes */
   17.54  
   17.55 -/* CMSG_BLKIF_BE_VBD_GROW */
   17.56 -typedef struct { 
   17.57 -    /* IN */
   17.58 -    domid_t    domid;         /*  0: Identify blkdev interface.          */
   17.59 -    u16        __pad0;        /*  2 */
   17.60 -    u32        blkif_handle;  /*  4: ...ditto...                         */
   17.61 -    blkif_extent_t extent;    /*  8: Physical extent to append to VBD.   */
   17.62 -    blkif_vdev_t vdevice;     /* 28: Interface-specific id of the VBD.   */
   17.63 -    u16        __pad1;        /* 30 */
   17.64 -    /* OUT */
   17.65 -    u32        status;        /* 32 */
   17.66 -} PACKED blkif_be_vbd_grow_t; /* 36 bytes */
   17.67 -
   17.68 -/* CMSG_BLKIF_BE_VBD_SHRINK */
   17.69 -typedef struct { 
   17.70 -    /* IN */
   17.71 -    domid_t    domid;         /*  0: Identify blkdev interface.          */
   17.72 -    u16        __pad0;        /*  2 */
   17.73 -    u32        blkif_handle;  /*  4: ...ditto...                         */
   17.74 -    blkif_vdev_t vdevice;     /*  8: Interface-specific id of the VBD.   */
   17.75 -    u16        __pad1;        /* 10 */
   17.76 -    /* OUT */
   17.77 -    u32        status;        /* 12 */
   17.78 -} PACKED blkif_be_vbd_shrink_t; /* 16 bytes */
   17.79 -
   17.80  /*
   17.81   * CMSG_BLKIF_BE_DRIVER_STATUS:
   17.82   *  Notify the domain controller that the back-end driver is DOWN or UP.