ia64/xen-unstable

changeset 1818:67207b5553cd

bitkeeper revision 1.1107 (40f98794J_mirmJSTPQ1LqjLJj7NTg)

Simplify clipping check and fix to work with non disks devices.
author iap10@labyrinth.cl.cam.ac.uk
date Sat Jul 17 20:09:56 2004 +0000 (2004-07-17)
parents 0366608703aa
children 1a488e40456a
files linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/backend/vbd.c
line diff
     1.1 --- a/linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/backend/vbd.c	Sat Jul 17 13:01:46 2004 +0000
     1.2 +++ b/linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/backend/vbd.c	Sat Jul 17 20:09:56 2004 +0000
     1.3 @@ -79,8 +79,8 @@ void vbd_grow(blkif_be_vbd_grow_t *grow)
     1.4      vbd_t              *vbd = NULL;
     1.5      rb_node_t          *rb;
     1.6      blkif_vdev_t        vdevice = grow->vdevice;
     1.7 -    struct gendisk     *gd;
     1.8 -    struct hd_struct   *hd;
     1.9 +    unsigned long       sz;
    1.10 +    
    1.11  
    1.12      blkif = blkif_find_by_handle(grow->domid, grow->blkif_handle);
    1.13      if ( unlikely(blkif == NULL) )
    1.14 @@ -119,45 +119,48 @@ void vbd_grow(blkif_be_vbd_grow_t *grow)
    1.15          grow->status = BLKIF_BE_STATUS_OUT_OF_MEMORY;
    1.16          goto out;
    1.17      }
    1.18 - 
    1.19 +    
    1.20      x->extent.device        = grow->extent.device; 
    1.21      x->extent.sector_start  = grow->extent.sector_start; 
    1.22      x->extent.sector_length = grow->extent.sector_length; 
    1.23      x->next                 = (blkif_extent_le_t *)NULL; 
    1.24 -
    1.25 -    gd = get_gendisk(x->extent.device);
    1.26 -    if ( (gd == NULL) || (gd->part == NULL) )
    1.27 +    
    1.28 +    if( !blk_size[MAJOR(x->extent.device)] )
    1.29      {
    1.30 -        grow->status = BLKIF_BE_STATUS_VBD_NOT_FOUND; 
    1.31          DPRINTK("vbd_grow: device %08x doesn't exist.\n", x->extent.device);
    1.32 -        goto out;
    1.33 +	grow->status = BLKIF_BE_STATUS_EXTENT_NOT_FOUND;
    1.34 +	goto out;
    1.35      }
    1.36 -
    1.37 -    if ( (hd = &gd->part[MINOR(x->extent.device)]) == NULL )
    1.38 +    
    1.39 +    /* convert blocks (1KB) to sectors */
    1.40 +    sz = blk_size[MAJOR(x->extent.device)][MINOR(x->extent.device)] * 2;    
    1.41 +    
    1.42 +    if ( x->extent.sector_start > 0 )
    1.43      {
    1.44 -        grow->status = BLKIF_BE_STATUS_VBD_NOT_FOUND; 
    1.45 -        DPRINTK("vbd_grow: HD device %08x doesn't exist.\n", x->extent.device);
    1.46 -        goto out;
    1.47 +        DPRINTK("vbd_grow: device %08x start not zero!\n", x->extent.device);
    1.48 +	grow->status = BLKIF_BE_STATUS_EXTENT_NOT_FOUND;
    1.49 +	goto out;
    1.50      }
    1.51 -
    1.52 -    DPRINTK("vbd_grow: requested_len %llu actual_len %lu\n", 
    1.53 -            x->extent.sector_length, hd->nr_sects);
    1.54 -
    1.55 +    
    1.56      /*
    1.57       * NB. This test assumes sector_start == 0, which is always the case
    1.58       * in Xen 1.3. In fact the whole grow/shrink interface could do with
    1.59       * some simplification.
    1.60       */
    1.61 -    if ( x->extent.sector_length > hd->nr_sects )
    1.62 -        x->extent.sector_length = hd->nr_sects;    
    1.63 +    if ( x->extent.sector_length > sz )
    1.64 +        x->extent.sector_length = sz;
    1.65 +    
    1.66 +    DPRINTK("vbd_grow: requested_len %llu actual_len %lu\n", 
    1.67 +            x->extent.sector_length, sz);
    1.68  
    1.69      for ( px = &vbd->extents; *px != NULL; px = &(*px)->next ) 
    1.70          continue;
    1.71 -
    1.72 +    
    1.73      *px = x;
    1.74  
    1.75      DPRINTK("Successful grow of vdev=%04x (dom=%u)\n",
    1.76              vdevice, grow->domid);
    1.77 +    
    1.78      grow->status = BLKIF_BE_STATUS_OKAY;
    1.79  
    1.80   out: