ia64/xen-unstable

changeset 905:a758526e0e84

bitkeeper revision 1.569.1.1 (3fabd0d6F65H-1bT1S8jMoUe53DAEA)

bug fixes for multiple devices
author smh22@labyrinth.cl.cam.ac.uk
date Fri Nov 07 17:05:26 2003 +0000 (2003-11-07)
parents 53a122a3c2b5
children f8e22c28741a
files BitKeeper/etc/ignore xen/drivers/block/xen_block.c xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_vbd.c
line diff
     1.1 --- a/BitKeeper/etc/ignore	Thu Nov 06 20:52:51 2003 +0000
     1.2 +++ b/BitKeeper/etc/ignore	Fri Nov 07 17:05:26 2003 +0000
     1.3 @@ -481,3 +481,5 @@ tools/misc/xen_refresh_dev
     1.4  xenolinux-2.4.22-sparse/arch/xeno/drivers/block/device
     1.5  xen/common/debug.c~
     1.6  xen/common/debug.o
     1.7 +tools/internal/xi_restore_linux
     1.8 +tools/internal/xi_save_linux
     2.1 --- a/xen/drivers/block/xen_block.c	Thu Nov 06 20:52:51 2003 +0000
     2.2 +++ b/xen/drivers/block/xen_block.c	Fri Nov 07 17:05:26 2003 +0000
     2.3 @@ -255,7 +255,7 @@ long do_block_io_op(block_io_op_t *u_blo
     2.4  	break; 
     2.5  
     2.6      case BLOCK_IO_OP_VBD_REMOVE:  
     2.7 -	/* remove an extnet from a VBD; caller must be privileged  */
     2.8 +	/* remove an extent from a VBD; caller must be privileged  */
     2.9  	if(!IS_PRIV(p))
    2.10  	    return -EPERM; 
    2.11  	ret = vbd_remove(&op.u.remove_info); 
     3.1 --- a/xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_vbd.c	Thu Nov 06 20:52:51 2003 +0000
     3.2 +++ b/xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_vbd.c	Fri Nov 07 17:05:26 2003 +0000
     3.3 @@ -31,27 +31,25 @@ struct gendisk *xlvbd_gendisk[XLVBD_MAX_
     3.4  
     3.5  
     3.6  #define XLIDE_PARTN_SHIFT  6    /* amount to shift minor to get 'real' minor */
     3.7 -#define XLIDE_MAX_MINORS  (1 << XLIDE_PARTN_SHIFT)     /* minors per ide vbd */
     3.8 +#define XLIDE_MAX_PART    (1 << XLIDE_PARTN_SHIFT)     /* minors per ide vbd */
     3.9  
    3.10 -#define XLSCSI_PARTN_SHIFT 6    /* amount to shift minor to get 'real' minor */
    3.11 -#define XLSCSI_MAX_MINORS (1 << XLSCSI_PARTN_SHIFT)   /* minors per scsi vbd */
    3.12 +#define XLSCSI_PARTN_SHIFT 4    /* amount to shift minor to get 'real' minor */
    3.13 +#define XLSCSI_MAX_PART   (1 << XLSCSI_PARTN_SHIFT)   /* minors per scsi vbd */
    3.14  
    3.15  #define XLVBD_PARTN_SHIFT  6    /* amount to shift minor to get 'real' minor */
    3.16 -#define XLVBD_MAX_MINORS  (1 << XLVBD_PARTN_SHIFT) /* minors per 'other' vbd */
    3.17 +#define XLVBD_MAX_PART    (1 << XLVBD_PARTN_SHIFT) /* minors per 'other' vbd */
    3.18  
    3.19  
    3.20  /* the below are for the use of the generic drivers/block/ll_rw_block.c code */
    3.21 -static int xlide_blksize_size[XLIDE_MAX_MINORS];
    3.22 -static int xlide_hardsect_size[XLIDE_MAX_MINORS];
    3.23 -static int xlide_max_sectors[XLIDE_MAX_MINORS];
    3.24 -
    3.25 -static int xlscsi_blksize_size[XLSCSI_MAX_MINORS];
    3.26 -static int xlscsi_hardsect_size[XLSCSI_MAX_MINORS];
    3.27 -static int xlscsi_max_sectors[XLSCSI_MAX_MINORS];
    3.28 -
    3.29 -static int xlvbd_blksize_size[XLVBD_MAX_MINORS];
    3.30 -static int xlvbd_hardsect_size[XLVBD_MAX_MINORS];
    3.31 -static int xlvbd_max_sectors[XLVBD_MAX_MINORS];
    3.32 +static int xlide_blksize_size[256];
    3.33 +static int xlide_hardsect_size[256];
    3.34 +static int xlide_max_sectors[256];
    3.35 +static int xlscsi_blksize_size[256];
    3.36 +static int xlscsi_hardsect_size[256];
    3.37 +static int xlscsi_max_sectors[256];
    3.38 +static int xlvbd_blksize_size[256];
    3.39 +static int xlvbd_hardsect_size[256];
    3.40 +static int xlvbd_max_sectors[256];
    3.41  
    3.42  
    3.43  static struct block_device_operations xlvbd_block_fops = 
    3.44 @@ -76,10 +74,10 @@ typedef unsigned char bool;
    3.45  */
    3.46  int __init xlvbd_init(xen_disk_info_t *xdi)
    3.47  {
    3.48 -    int i, result, nminors; 
    3.49 +    int i, result, max_part; 
    3.50      struct gendisk *gd = NULL;
    3.51      kdev_t device; 
    3.52 -    unsigned short major, minor, real_minor; 
    3.53 +    unsigned short major, minor, partno; 
    3.54      bool is_ide, is_scsi; 
    3.55      char *major_name; 
    3.56      unsigned char buf[64]; 
    3.57 @@ -88,30 +86,25 @@ int __init xlvbd_init(xen_disk_info_t *x
    3.58      SET_MODULE_OWNER(&xlvbd_block_fops);
    3.59  
    3.60      /* Initialize the global arrays. */
    3.61 -    for (i = 0; i < XLIDE_MAX_MINORS; i++) 
    3.62 +    for (i = 0; i < 256; i++) 
    3.63      {
    3.64  	/* from the generic ide code (drivers/ide/ide-probe.c, etc) */
    3.65  	xlide_blksize_size[i]  = 1024;
    3.66  	xlide_hardsect_size[i] = 512;
    3.67  	xlide_max_sectors[i]   = 128;  /* 'hwif->rqsize' if we knew it */
    3.68 -    }
    3.69 -    
    3.70 -    for (i = 0; i < XLSCSI_MAX_MINORS; i++) 
    3.71 -    {
    3.72 +
    3.73  	/* from the generic scsi disk code (drivers/scsi/sd.c) */
    3.74  	xlscsi_blksize_size[i]  = 1024; //XXX 512;
    3.75  	xlscsi_hardsect_size[i] = 512;
    3.76  	xlscsi_max_sectors[i]   = 128*8; //XXX 128;
    3.77 -    }
    3.78 -    
    3.79 -    for (i = 0; i < XLVBD_MAX_MINORS; i++) 
    3.80 -    {
    3.81 +
    3.82  	/* we don't really know what to set these too since it depends */
    3.83  	xlvbd_blksize_size[i]  = 512;
    3.84  	xlvbd_hardsect_size[i] = 512;
    3.85  	xlvbd_max_sectors[i]   = 128;
    3.86      }
    3.87  
    3.88 +
    3.89      /* keep track of which majors we've seen so far */
    3.90      for (i = 0; i < 256; i++) 
    3.91  	majors[i] = 0; 
    3.92 @@ -135,13 +128,13 @@ int __init xlvbd_init(xen_disk_info_t *x
    3.93  	
    3.94  	if(is_ide) { 
    3.95  	    major_name = XLIDE_MAJOR_NAME; 
    3.96 -	    nminors    = XLIDE_MAX_MINORS; 
    3.97 +	    max_part   = XLIDE_MAX_PART;
    3.98  	} else if(is_scsi) { 
    3.99  	    major_name = XLSCSI_MAJOR_NAME;
   3.100 -	    nminors    = XLSCSI_MAX_MINORS; 
   3.101 +	    max_part   = XLSCSI_MAX_PART;
   3.102  	} else { 
   3.103  	    major_name = XLVBD_MAJOR_NAME;
   3.104 -	    nminors    = XLVBD_MAX_MINORS; 
   3.105 +	    max_part   = XLVBD_MAX_PART;
   3.106  	}
   3.107  
   3.108  	/* 
   3.109 @@ -150,7 +143,7 @@ int __init xlvbd_init(xen_disk_info_t *x
   3.110  	** minor devices require slightly different handling than 
   3.111  	** 'full' devices (e.g. in terms of partition table handling). 
   3.112  	*/
   3.113 -	real_minor = minor & (nminors - 1); 
   3.114 +	partno = minor & (max_part - 1); 
   3.115  
   3.116  	if(!majors[major]) {
   3.117  
   3.118 @@ -188,13 +181,10 @@ int __init xlvbd_init(xen_disk_info_t *x
   3.119  
   3.120  	    /* Construct an appropriate gendisk structure. */
   3.121  	    gd             = kmalloc(sizeof(struct gendisk), GFP_KERNEL);
   3.122 -	    gd->sizes      = kmalloc(nminors*sizeof(int), GFP_KERNEL);
   3.123 -	    gd->part       = kmalloc(nminors*sizeof(struct hd_struct), 
   3.124 -				     GFP_KERNEL);
   3.125  	    gd->major      = major;
   3.126  	    gd->major_name = major_name; 
   3.127  	    
   3.128 -	    gd->max_p      = nminors; 
   3.129 +	    gd->max_p      = max_part; 
   3.130  	    if(is_ide) { 
   3.131  		gd->minor_shift  = XLIDE_PARTN_SHIFT; 
   3.132  		gd->nr_real      = XLIDE_DEVS_PER_MAJOR; 
   3.133 @@ -205,19 +195,33 @@ int __init xlvbd_init(xen_disk_info_t *x
   3.134  		gd->minor_shift  = XLVBD_PARTN_SHIFT; 
   3.135  		gd->nr_real      = XLVBD_DEVS_PER_MAJOR; 
   3.136  	    }
   3.137 +
   3.138 +	    /* 
   3.139 +	    ** The sizes[] and part[] arrays hold the sizes and other 
   3.140 +	    ** information about every partition with this 'major' (i.e. 
   3.141 +	    ** every disk sharing the 8 bit prefix * max partns per disk) 
   3.142 +	    */
   3.143 +	    gd->sizes = kmalloc(max_part*gd->nr_real*sizeof(int), GFP_KERNEL);
   3.144 +	    gd->part  = kmalloc(max_part*gd->nr_real*sizeof(struct hd_struct), 
   3.145 +				     GFP_KERNEL);
   3.146 +	    memset(gd->sizes, 0, max_part * gd->nr_real * sizeof(int));
   3.147 +	    memset(gd->part,  0, max_part * gd->nr_real 
   3.148 +		   * sizeof(struct hd_struct));
   3.149 +
   3.150 +
   3.151  	    gd->real_devices = kmalloc(gd->nr_real * sizeof(xl_disk_t), 
   3.152  				       GFP_KERNEL);
   3.153 +	    memset(gd->real_devices, 0, gd->nr_real * sizeof(xl_disk_t));
   3.154 +
   3.155  	    gd->next   = NULL;            
   3.156  	    gd->fops   = &xlvbd_block_fops;
   3.157 +
   3.158  	    gd->de_arr = kmalloc(gd->nr_real * sizeof(*gd->de_arr), 
   3.159  				 GFP_KERNEL);
   3.160  	    gd->flags  = kmalloc(gd->nr_real * sizeof(*gd->flags), GFP_KERNEL);
   3.161  	    
   3.162 -	    memset(gd->sizes, 0, nminors * sizeof(int));
   3.163 -	    memset(gd->part,  0, nminors * sizeof(struct hd_struct));
   3.164  	    memset(gd->de_arr, 0, gd->nr_real * sizeof(*gd->de_arr));
   3.165  	    memset(gd->flags, 0, gd->nr_real *  sizeof(*gd->flags));
   3.166 -	    memset(gd->real_devices, 0, gd->nr_real * sizeof(xl_disk_t));
   3.167  
   3.168  	    /* 
   3.169  	    ** Keep track of gendisk both locally and in the global array. 
   3.170 @@ -235,20 +239,22 @@ int __init xlvbd_init(xen_disk_info_t *x
   3.171  	    
   3.172  	    /* remember that we've done this major */
   3.173  	    majors[major] = 1; 
   3.174 -	}
   3.175 +	} else 
   3.176 +	    /* Continue the setup of this gendisk */
   3.177 +	    gd = get_gendisk(device); 
   3.178  
   3.179  	if(XD_READONLY(xdi->disks[i].info)) 
   3.180  	    set_device_ro(device, 1); 
   3.181  
   3.182 -	if(real_minor) { 
   3.183 +	if(partno) { 
   3.184  
   3.185  	    /* Need to skankily setup 'partition' information */
   3.186 -	    gd->part[real_minor].start_sect = 0; 
   3.187 -	    gd->part[real_minor].nr_sects   = xdi->disks[i].capacity; 
   3.188 -	    gd->sizes[real_minor]           = xdi->disks[i].capacity; 
   3.189 +	    gd->part[partno].start_sect = 0; 
   3.190 +	    gd->part[partno].nr_sects   = xdi->disks[i].capacity; 
   3.191 +	    gd->sizes[partno]           = xdi->disks[i].capacity; 
   3.192  
   3.193  	} else { 
   3.194 -	
   3.195 +
   3.196  	    /* Some final fix-ups depending on the device type */
   3.197  	    switch (XD_TYPE(xdi->disks[i].info)) 
   3.198  	    { 
   3.199 @@ -256,7 +262,7 @@ int __init xlvbd_init(xen_disk_info_t *x
   3.200  	    case XD_TYPE_CDROM:
   3.201  	    case XD_TYPE_FLOPPY: 
   3.202  	    case XD_TYPE_TAPE:
   3.203 -		gd->flags[0] = GENHD_FL_REMOVABLE; 
   3.204 +		gd->flags[minor >> gd->minor_shift] = GENHD_FL_REMOVABLE; 
   3.205  		printk(KERN_ALERT 
   3.206  		       "Skipping partition check on %s /dev/%s\n", 
   3.207  		       XD_TYPE(xdi->disks[i].info)==XD_TYPE_CDROM ? "cdrom" : 
   3.208 @@ -265,6 +271,9 @@ int __init xlvbd_init(xen_disk_info_t *x
   3.209  		break; 
   3.210  		
   3.211  	    case XD_TYPE_DISK: 
   3.212 +		printk(KERN_ALERT 
   3.213 +		       "Calling register_disk for device %04x [gd=%p]\n", 
   3.214 +		       device, gd); 
   3.215  		register_disk(gd, device, gd->nr_real, &xlvbd_block_fops, 
   3.216  			      xdi->disks[i].capacity);
   3.217  		break;