direct-io.hg

changeset 2013:5a95b145ae4c

bitkeeper revision 1.1108.45.1 (410c1a5ciBWG2JsmEjIJbaQp8U-jtg)

Avoid use of /sbin/sfdisk in determining blk dev size.
author iap10@labyrinth.cl.cam.ac.uk
date Sat Jul 31 22:17:00 2004 +0000 (2004-07-31)
parents 15b95c4931e0
children c10963d13006
files linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/backend/common.h linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/backend/vbd.c tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/server/blkif.py
line diff
     1.1 --- a/linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/backend/common.h	Fri Jul 30 19:57:28 2004 +0000
     1.2 +++ b/linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/backend/common.h	Sat Jul 31 22:17:00 2004 +0000
     1.3 @@ -26,6 +26,9 @@
     1.4  #define DPRINTK(_f, _a...) ((void)0)
     1.5  #endif
     1.6  
     1.7 +#define PRINTK(_f, _a...) printk(KERN_ALERT "(file=%s, line=%d) " _f, \
     1.8 +                           __FILE__ , __LINE__ , ## _a )
     1.9 +
    1.10  typedef struct blkif_st {
    1.11      /* Unique identifier for this interface. */
    1.12      domid_t          domid;
     2.1 --- a/linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/backend/vbd.c	Fri Jul 30 19:57:28 2004 +0000
     2.2 +++ b/linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/backend/vbd.c	Sat Jul 31 22:17:00 2004 +0000
     2.3 @@ -18,7 +18,7 @@ void vbd_create(blkif_be_vbd_create_t *c
     2.4      blkif = blkif_find_by_handle(create->domid, create->blkif_handle);
     2.5      if ( unlikely(blkif == NULL) )
     2.6      {
     2.7 -        DPRINTK("vbd_create attempted for non-existent blkif (%u,%u)\n", 
     2.8 +        PRINTK("vbd_create attempted for non-existent blkif (%u,%u)\n", 
     2.9                  create->domid, create->blkif_handle); 
    2.10          create->status = BLKIF_BE_STATUS_INTERFACE_NOT_FOUND;
    2.11          return;
    2.12 @@ -41,7 +41,7 @@ void vbd_create(blkif_be_vbd_create_t *c
    2.13          }
    2.14          else
    2.15          {
    2.16 -            DPRINTK("vbd_create attempted for already existing vbd\n");
    2.17 +            PRINTK("vbd_create attempted for already existing vbd\n");
    2.18              create->status = BLKIF_BE_STATUS_VBD_EXISTS;
    2.19              goto out;
    2.20          }
    2.21 @@ -49,7 +49,7 @@ void vbd_create(blkif_be_vbd_create_t *c
    2.22  
    2.23      if ( unlikely((vbd = kmalloc(sizeof(vbd_t), GFP_KERNEL)) == NULL) )
    2.24      {
    2.25 -        DPRINTK("vbd_create: out of memory\n");
    2.26 +        PRINTK("vbd_create: out of memory\n");
    2.27          create->status = BLKIF_BE_STATUS_OUT_OF_MEMORY;
    2.28          goto out;
    2.29      }
    2.30 @@ -85,7 +85,7 @@ void vbd_grow(blkif_be_vbd_grow_t *grow)
    2.31      blkif = blkif_find_by_handle(grow->domid, grow->blkif_handle);
    2.32      if ( unlikely(blkif == NULL) )
    2.33      {
    2.34 -        DPRINTK("vbd_grow attempted for non-existent blkif (%u,%u)\n", 
    2.35 +        PRINTK("vbd_grow attempted for non-existent blkif (%u,%u)\n", 
    2.36                  grow->domid, grow->blkif_handle); 
    2.37          grow->status = BLKIF_BE_STATUS_INTERFACE_NOT_FOUND;
    2.38          return;
    2.39 @@ -107,7 +107,7 @@ void vbd_grow(blkif_be_vbd_grow_t *grow)
    2.40  
    2.41      if ( unlikely(vbd == NULL) || unlikely(vbd->vdevice != vdevice) )
    2.42      {
    2.43 -        DPRINTK("vbd_grow: attempted to append extent to non-existent VBD.\n");
    2.44 +        PRINTK("vbd_grow: attempted to append extent to non-existent VBD.\n");
    2.45          grow->status = BLKIF_BE_STATUS_VBD_NOT_FOUND;
    2.46          goto out;
    2.47      } 
    2.48 @@ -115,7 +115,7 @@ void vbd_grow(blkif_be_vbd_grow_t *grow)
    2.49      if ( unlikely((x = kmalloc(sizeof(blkif_extent_le_t), 
    2.50                                 GFP_KERNEL)) == NULL) )
    2.51      {
    2.52 -        DPRINTK("vbd_grow: out of memory\n");
    2.53 +        PRINTK("vbd_grow: out of memory\n");
    2.54          grow->status = BLKIF_BE_STATUS_OUT_OF_MEMORY;
    2.55          goto out;
    2.56      }
    2.57 @@ -127,7 +127,7 @@ void vbd_grow(blkif_be_vbd_grow_t *grow)
    2.58      
    2.59      if( !blk_size[MAJOR(x->extent.device)] )
    2.60      {
    2.61 -        DPRINTK("vbd_grow: device %08x doesn't exist.\n", x->extent.device);
    2.62 +        PRINTK("vbd_grow: device %08x doesn't exist.\n", x->extent.device);
    2.63  	grow->status = BLKIF_BE_STATUS_EXTENT_NOT_FOUND;
    2.64  	goto out;
    2.65      }
    2.66 @@ -135,9 +135,16 @@ void vbd_grow(blkif_be_vbd_grow_t *grow)
    2.67      /* convert blocks (1KB) to sectors */
    2.68      sz = blk_size[MAJOR(x->extent.device)][MINOR(x->extent.device)] * 2;    
    2.69      
    2.70 +    if ( sz == 0 )
    2.71 +    {
    2.72 +        PRINTK("vbd_grow: device %08x zero size!\n", x->extent.device);
    2.73 +	grow->status = BLKIF_BE_STATUS_EXTENT_NOT_FOUND;
    2.74 +	goto out;
    2.75 +    }
    2.76 +
    2.77      if ( x->extent.sector_start > 0 )
    2.78      {
    2.79 -        DPRINTK("vbd_grow: device %08x start not zero!\n", x->extent.device);
    2.80 +        PRINTK("vbd_grow: device %08x start not zero!\n", x->extent.device);
    2.81  	grow->status = BLKIF_BE_STATUS_EXTENT_NOT_FOUND;
    2.82  	goto out;
    2.83      }
    2.84 @@ -237,7 +244,7 @@ void vbd_destroy(blkif_be_vbd_destroy_t 
    2.85      blkif = blkif_find_by_handle(destroy->domid, destroy->blkif_handle);
    2.86      if ( unlikely(blkif == NULL) )
    2.87      {
    2.88 -        DPRINTK("vbd_destroy attempted for non-existent blkif (%u,%u)\n", 
    2.89 +        PRINTK("vbd_destroy attempted for non-existent blkif (%u,%u)\n", 
    2.90                  destroy->domid, destroy->blkif_handle); 
    2.91          destroy->status = BLKIF_BE_STATUS_INTERFACE_NOT_FOUND;
    2.92          return;
     3.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Fri Jul 30 19:57:28 2004 +0000
     3.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Sat Jul 31 22:17:00 2004 +0000
     3.3 @@ -83,9 +83,18 @@ def blkdev_name_to_number(name):
     3.4      'hda') and return the device number used by the OS. """
     3.5  
     3.6      if not re.match( '^/dev/', name ):
     3.7 -        name = '/dev/' + name
     3.8 +        n = '/dev/' + name
     3.9          
    3.10 -    return os.stat(name).st_rdev
    3.11 +    try:
    3.12 +	return os.stat(n).st_rdev
    3.13 +    except:
    3.14 +	pass
    3.15 +
    3.16 +    # see if this is a hex device number
    3.17 +    if re.match( '^(0x)?[0-9a-fA-F]+$', name ):
    3.18 +	return string.atoi(name,16)
    3.19 +	
    3.20 +    return None
    3.21  
    3.22  def lookup_raw_partn(name):
    3.23      """Take the given block-device name (e.g., '/dev/sda1', 'hda')
    3.24 @@ -97,27 +106,14 @@ def lookup_raw_partn(name):
    3.25          type:         'Disk' or identifying name for partition type
    3.26      """
    3.27  
    3.28 -    p = name
    3.29 -
    3.30 -    if not re.match( '^/dev/', name ):
    3.31 -        p = '/dev/' + name
    3.32 -	        
    3.33 -    fd = os.popen( '/sbin/sfdisk -s ' + p + ' 2>/dev/null' )
    3.34 -    line = _readline(fd)
    3.35 -    if line:
    3.36 -	return [ { 'device' : blkdev_name_to_number(p),
    3.37 +    n = blkdev_name_to_number(name)
    3.38 +    if n:
    3.39 +	return [ { 'device' : n,
    3.40  		   'start_sector' : long(0),
    3.41  		   'nr_sectors' : long(1L<<63),
    3.42  		   'type' : 'Disk' } ]
    3.43      else:
    3.44 -	# see if this is a hex device number
    3.45 -	if re.match( '^(0x)?[0-9a-fA-F]+$', name ):
    3.46 -	    return [ { 'device' : string.atoi(name,16),
    3.47 -		   'start_sector' : long(0),
    3.48 -		   'nr_sectors' : long(1L<<63),
    3.49 -		   'type' : 'Disk' } ]
    3.50 -	
    3.51 -    return None
    3.52 +	return None
    3.53  
    3.54  def lookup_disk_uname(uname):
    3.55      """Lookup a list of segments for a physical device.
     4.1 --- a/tools/python/xen/xend/server/blkif.py	Fri Jul 30 19:57:28 2004 +0000
     4.2 +++ b/tools/python/xen/xend/server/blkif.py	Sat Jul 31 22:17:00 2004 +0000
     4.3 @@ -194,6 +194,12 @@ class BlkifControllerFactory(controller.
     4.4          """
     4.5          val = unpackMsg('blkif_be_vbd_grow_t', msg)
     4.6          # Check status?
     4.7 +	status = val['status']
     4.8 +	if status != BLKIF_BE_STATUS_OKAY:
     4.9 +            log.debug("Error: Adding extent to vbd failed! (device %x)",
    4.10 +		      val['extent.device'])
    4.11 +            # what to do here to abort????
    4.12 +
    4.13          if self.attached:
    4.14              if d:
    4.15                  d.callback(dev)