ia64/xen-unstable

changeset 906:f8e22c28741a

bitkeeper revision 1.573 (3fabd10f_-HPTkLPE6J9ARwOzz2XCQ)

tweak bk thing
author smh22@labyrinth.cl.cam.ac.uk
date Fri Nov 07 17:06:23 2003 +0000 (2003-11-07)
parents 90ae2bc0ebee a758526e0e84
children 0ea332de05e6
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	Fri Nov 07 16:37:15 2003 +0000
     1.2 +++ b/BitKeeper/etc/ignore	Fri Nov 07 17:06:23 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	Fri Nov 07 16:37:15 2003 +0000
     2.2 +++ b/xen/drivers/block/xen_block.c	Fri Nov 07 17:06:23 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	Fri Nov 07 16:37:15 2003 +0000
     3.2 +++ b/xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_vbd.c	Fri Nov 07 17:06:23 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 4    /* 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_MAX_PART   (1 << XLSCSI_PARTN_SHIFT)   /* minors per scsi vbd */
    3.13  
    3.14  #define XLVBD_PARTN_SHIFT  6    /* amount to shift minor to get 'real' minor */
    3.15 -#define XLVBD_MAX_MINORS  (1 << XLVBD_PARTN_SHIFT) /* minors per 'other' vbd */
    3.16 +#define XLVBD_MAX_PART    (1 << XLVBD_PARTN_SHIFT) /* minors per 'other' vbd */
    3.17  
    3.18  
    3.19  /* the below are for the use of the generic drivers/block/ll_rw_block.c code */
    3.20 -static int xlide_blksize_size[XLIDE_MAX_MINORS];
    3.21 -static int xlide_hardsect_size[XLIDE_MAX_MINORS];
    3.22 -static int xlide_max_sectors[XLIDE_MAX_MINORS];
    3.23 -
    3.24 -static int xlscsi_blksize_size[XLSCSI_MAX_MINORS];
    3.25 -static int xlscsi_hardsect_size[XLSCSI_MAX_MINORS];
    3.26 -static int xlscsi_max_sectors[XLSCSI_MAX_MINORS];
    3.27 -
    3.28 -static int xlvbd_blksize_size[XLVBD_MAX_MINORS];
    3.29 -static int xlvbd_hardsect_size[XLVBD_MAX_MINORS];
    3.30 -static int xlvbd_max_sectors[XLVBD_MAX_MINORS];
    3.31 +static int xlide_blksize_size[256];
    3.32 +static int xlide_hardsect_size[256];
    3.33 +static int xlide_max_sectors[256];
    3.34 +static int xlscsi_blksize_size[256];
    3.35 +static int xlscsi_hardsect_size[256];
    3.36 +static int xlscsi_max_sectors[256];
    3.37 +static int xlvbd_blksize_size[256];
    3.38 +static int xlvbd_hardsect_size[256];
    3.39 +static int xlvbd_max_sectors[256];
    3.40  
    3.41  
    3.42  static struct block_device_operations xlvbd_block_fops = 
    3.43 @@ -76,10 +74,10 @@ typedef unsigned char bool;
    3.44  */
    3.45  int __init xlvbd_init(xen_disk_info_t *xdi)
    3.46  {
    3.47 -    int i, result, nminors; 
    3.48 +    int i, result, max_part; 
    3.49      struct gendisk *gd = NULL;
    3.50      kdev_t device; 
    3.51 -    unsigned short major, minor, real_minor; 
    3.52 +    unsigned short major, minor, partno; 
    3.53      bool is_ide, is_scsi; 
    3.54      char *major_name; 
    3.55      unsigned char buf[64]; 
    3.56 @@ -88,30 +86,25 @@ int __init xlvbd_init(xen_disk_info_t *x
    3.57      SET_MODULE_OWNER(&xlvbd_block_fops);
    3.58  
    3.59      /* Initialize the global arrays. */
    3.60 -    for (i = 0; i < XLIDE_MAX_MINORS; i++) 
    3.61 +    for (i = 0; i < 256; i++) 
    3.62      {
    3.63  	/* from the generic ide code (drivers/ide/ide-probe.c, etc) */
    3.64  	xlide_blksize_size[i]  = 1024;
    3.65  	xlide_hardsect_size[i] = 512;
    3.66  	xlide_max_sectors[i]   = 128;  /* 'hwif->rqsize' if we knew it */
    3.67 -    }
    3.68 -    
    3.69 -    for (i = 0; i < XLSCSI_MAX_MINORS; i++) 
    3.70 -    {
    3.71 +
    3.72  	/* from the generic scsi disk code (drivers/scsi/sd.c) */
    3.73  	xlscsi_blksize_size[i]  = 1024; //XXX 512;
    3.74  	xlscsi_hardsect_size[i] = 512;
    3.75  	xlscsi_max_sectors[i]   = 128*8; //XXX 128;
    3.76 -    }
    3.77 -    
    3.78 -    for (i = 0; i < XLVBD_MAX_MINORS; i++) 
    3.79 -    {
    3.80 +
    3.81  	/* we don't really know what to set these too since it depends */
    3.82  	xlvbd_blksize_size[i]  = 512;
    3.83  	xlvbd_hardsect_size[i] = 512;
    3.84  	xlvbd_max_sectors[i]   = 128;
    3.85      }
    3.86  
    3.87 +
    3.88      /* keep track of which majors we've seen so far */
    3.89      for (i = 0; i < 256; i++) 
    3.90  	majors[i] = 0; 
    3.91 @@ -135,13 +128,13 @@ int __init xlvbd_init(xen_disk_info_t *x
    3.92  	
    3.93  	if(is_ide) { 
    3.94  	    major_name = XLIDE_MAJOR_NAME; 
    3.95 -	    nminors    = XLIDE_MAX_MINORS; 
    3.96 +	    max_part   = XLIDE_MAX_PART;
    3.97  	} else if(is_scsi) { 
    3.98  	    major_name = XLSCSI_MAJOR_NAME;
    3.99 -	    nminors    = XLSCSI_MAX_MINORS; 
   3.100 +	    max_part   = XLSCSI_MAX_PART;
   3.101  	} else { 
   3.102  	    major_name = XLVBD_MAJOR_NAME;
   3.103 -	    nminors    = XLVBD_MAX_MINORS; 
   3.104 +	    max_part   = XLVBD_MAX_PART;
   3.105  	}
   3.106  
   3.107  	/* 
   3.108 @@ -150,7 +143,7 @@ int __init xlvbd_init(xen_disk_info_t *x
   3.109  	** minor devices require slightly different handling than 
   3.110  	** 'full' devices (e.g. in terms of partition table handling). 
   3.111  	*/
   3.112 -	real_minor = minor & (nminors - 1); 
   3.113 +	partno = minor & (max_part - 1); 
   3.114  
   3.115  	if(!majors[major]) {
   3.116  
   3.117 @@ -188,13 +181,10 @@ int __init xlvbd_init(xen_disk_info_t *x
   3.118  
   3.119  	    /* Construct an appropriate gendisk structure. */
   3.120  	    gd             = kmalloc(sizeof(struct gendisk), GFP_KERNEL);
   3.121 -	    gd->sizes      = kmalloc(nminors*sizeof(int), GFP_KERNEL);
   3.122 -	    gd->part       = kmalloc(nminors*sizeof(struct hd_struct), 
   3.123 -				     GFP_KERNEL);
   3.124  	    gd->major      = major;
   3.125  	    gd->major_name = major_name; 
   3.126  	    
   3.127 -	    gd->max_p      = nminors; 
   3.128 +	    gd->max_p      = max_part; 
   3.129  	    if(is_ide) { 
   3.130  		gd->minor_shift  = XLIDE_PARTN_SHIFT; 
   3.131  		gd->nr_real      = XLIDE_DEVS_PER_MAJOR; 
   3.132 @@ -205,19 +195,33 @@ int __init xlvbd_init(xen_disk_info_t *x
   3.133  		gd->minor_shift  = XLVBD_PARTN_SHIFT; 
   3.134  		gd->nr_real      = XLVBD_DEVS_PER_MAJOR; 
   3.135  	    }
   3.136 +
   3.137 +	    /* 
   3.138 +	    ** The sizes[] and part[] arrays hold the sizes and other 
   3.139 +	    ** information about every partition with this 'major' (i.e. 
   3.140 +	    ** every disk sharing the 8 bit prefix * max partns per disk) 
   3.141 +	    */
   3.142 +	    gd->sizes = kmalloc(max_part*gd->nr_real*sizeof(int), GFP_KERNEL);
   3.143 +	    gd->part  = kmalloc(max_part*gd->nr_real*sizeof(struct hd_struct), 
   3.144 +				     GFP_KERNEL);
   3.145 +	    memset(gd->sizes, 0, max_part * gd->nr_real * sizeof(int));
   3.146 +	    memset(gd->part,  0, max_part * gd->nr_real 
   3.147 +		   * sizeof(struct hd_struct));
   3.148 +
   3.149 +
   3.150  	    gd->real_devices = kmalloc(gd->nr_real * sizeof(xl_disk_t), 
   3.151  				       GFP_KERNEL);
   3.152 +	    memset(gd->real_devices, 0, gd->nr_real * sizeof(xl_disk_t));
   3.153 +
   3.154  	    gd->next   = NULL;            
   3.155  	    gd->fops   = &xlvbd_block_fops;
   3.156 +
   3.157  	    gd->de_arr = kmalloc(gd->nr_real * sizeof(*gd->de_arr), 
   3.158  				 GFP_KERNEL);
   3.159  	    gd->flags  = kmalloc(gd->nr_real * sizeof(*gd->flags), GFP_KERNEL);
   3.160  	    
   3.161 -	    memset(gd->sizes, 0, nminors * sizeof(int));
   3.162 -	    memset(gd->part,  0, nminors * sizeof(struct hd_struct));
   3.163  	    memset(gd->de_arr, 0, gd->nr_real * sizeof(*gd->de_arr));
   3.164  	    memset(gd->flags, 0, gd->nr_real *  sizeof(*gd->flags));
   3.165 -	    memset(gd->real_devices, 0, gd->nr_real * sizeof(xl_disk_t));
   3.166  
   3.167  	    /* 
   3.168  	    ** Keep track of gendisk both locally and in the global array. 
   3.169 @@ -230,27 +234,27 @@ int __init xlvbd_init(xen_disk_info_t *x
   3.170  	       hence using unit number for now but in old code was 'disk' aka 
   3.171  	       sequence number assigned by xen during probe = barfle? */
   3.172  	    ((xl_disk_t *)gd->real_devices)[minor>>gd->minor_shift].capacity =
   3.173 -                xdi->disks[i].capacity;
   3.174 +	    xdi->disks[i].capacity;
   3.175  
   3.176  	    
   3.177  	    /* remember that we've done this major */
   3.178  	    majors[major] = 1; 
   3.179 -	} else {
   3.180 +	} else 
   3.181 +	    /* Continue the setup of this gendisk */
   3.182  	    gd = get_gendisk(device); 
   3.183 -	}
   3.184  
   3.185  	if(XD_READONLY(xdi->disks[i].info)) 
   3.186  	    set_device_ro(device, 1); 
   3.187  
   3.188 -	if(real_minor) { 
   3.189 +	if(partno) { 
   3.190  
   3.191  	    /* Need to skankily setup 'partition' information */
   3.192 -	    gd->part[real_minor].start_sect = 0; 
   3.193 -	    gd->part[real_minor].nr_sects   = xdi->disks[i].capacity; 
   3.194 -	    gd->sizes[real_minor]           = xdi->disks[i].capacity; 
   3.195 +	    gd->part[partno].start_sect = 0; 
   3.196 +	    gd->part[partno].nr_sects   = xdi->disks[i].capacity; 
   3.197 +	    gd->sizes[partno]           = xdi->disks[i].capacity; 
   3.198  
   3.199  	} else { 
   3.200 -	
   3.201 +
   3.202  	    /* Some final fix-ups depending on the device type */
   3.203  	    switch (XD_TYPE(xdi->disks[i].info)) 
   3.204  	    { 
   3.205 @@ -258,7 +262,7 @@ int __init xlvbd_init(xen_disk_info_t *x
   3.206  	    case XD_TYPE_CDROM:
   3.207  	    case XD_TYPE_FLOPPY: 
   3.208  	    case XD_TYPE_TAPE:
   3.209 -		gd->flags[0] = GENHD_FL_REMOVABLE; 
   3.210 +		gd->flags[minor >> gd->minor_shift] = GENHD_FL_REMOVABLE; 
   3.211  		printk(KERN_ALERT 
   3.212  		       "Skipping partition check on %s /dev/%s\n", 
   3.213  		       XD_TYPE(xdi->disks[i].info)==XD_TYPE_CDROM ? "cdrom" : 
   3.214 @@ -267,6 +271,9 @@ int __init xlvbd_init(xen_disk_info_t *x
   3.215  		break; 
   3.216  		
   3.217  	    case XD_TYPE_DISK: 
   3.218 +		printk(KERN_ALERT 
   3.219 +		       "Calling register_disk for device %04x [gd=%p]\n", 
   3.220 +		       device, gd); 
   3.221  		register_disk(gd, device, gd->nr_real, &xlvbd_block_fops, 
   3.222  			      xdi->disks[i].capacity);
   3.223  		break;