ia64/xen-unstable
changeset 1029:7de4b6630bf4
bitkeeper revision 1.669 (3ff9eb5e0IQ4kkvTcwivJg9RViDQ6g)
xl_vbd.c, xl_block.h, xl_block.c, xen_block.c:
Fix device numbers passed to Xen from Xenolinux - strip partition bits when appropriate.
xl_vbd.c, xl_block.h, xl_block.c, xen_block.c:
Fix device numbers passed to Xen from Xenolinux - strip partition bits when appropriate.
author | kaf24@scramble.cl.cam.ac.uk |
---|---|
date | Mon Jan 05 22:55:26 2004 +0000 (2004-01-05) |
parents | 54f65792d612 |
children | 079ff40b60d2 |
files | xen/drivers/block/xen_block.c xenolinux-2.4.23-sparse/arch/xeno/drivers/block/xl_block.c xenolinux-2.4.23-sparse/arch/xeno/drivers/block/xl_block.h xenolinux-2.4.23-sparse/arch/xeno/drivers/block/xl_vbd.c |
line diff
1.1 --- a/xen/drivers/block/xen_block.c Mon Jan 05 17:56:11 2004 +0000 1.2 +++ b/xen/drivers/block/xen_block.c Mon Jan 05 22:55:26 2004 +0000 1.3 @@ -463,13 +463,6 @@ static void dispatch_rw_block_io(struct 1.4 req->device); 1.5 goto bad_descriptor; 1.6 } 1.7 - 1.8 - /* 1.9 - * Clear any 'partition' bits in the device id. This works because 1.10 - * IDE ignores the partition bits anyway. Only SCSI needs this 1.11 - * hack, and we know that always requires the four LSBs cleared. 1.12 - */ 1.13 - phys_seg[nr_psegs].dev = req->device & 0xFFF0; 1.14 new_segs = 1; 1.15 } 1.16
2.1 --- a/xenolinux-2.4.23-sparse/arch/xeno/drivers/block/xl_block.c Mon Jan 05 17:56:11 2004 +0000 2.2 +++ b/xenolinux-2.4.23-sparse/arch/xeno/drivers/block/xl_block.c Mon Jan 05 22:55:26 2004 +0000 2.3 @@ -223,16 +223,17 @@ int xenolinux_block_revalidate(kdev_t de 2.4 } 2.5 spin_unlock_irqrestore(&io_request_lock, flags); 2.6 2.7 - for ( i = gd->nr_real - 1; i >= 0; i-- ) 2.8 + for ( i = gd->max_p - 1; i >= 0; i-- ) 2.9 { 2.10 invalidate_device(dev+i, 1); 2.11 gd->part[MINOR(dev+i)].start_sect = 0; 2.12 - gd->part[MINOR(dev+i)].nr_sects = 0; 2.13 + gd->part[MINOR(dev+i)].nr_sects = 0; 2.14 + gd->sizes[MINOR(dev+i)] = 0; 2.15 } 2.16 2.17 /* XXX Should perhaps revalidate VBDs here */ 2.18 2.19 - grok_partitions(gd, disk_nr, gd->nr_real, capacity); 2.20 + grok_partitions(gd, disk_nr, gd->max_p, capacity); 2.21 2.22 return 0; 2.23 } 2.24 @@ -282,6 +283,14 @@ static int hypervisor_request(unsigned l 2.25 */ 2.26 sector_number += gd->part[MINOR(device)].start_sect; 2.27 2.28 + /* 2.29 + * If this unit doesn't consist of virtual (i.e., Xen-specified) 2.30 + * partitions then we clear the partn bits from the device number. 2.31 + */ 2.32 + if ( !(gd->flags[MINOR(device)>>gd->minor_shift] & 2.33 + GENHD_FL_VIRT_PARTNS) ) 2.34 + device &= ~(gd->max_p - 1); 2.35 + 2.36 if ( (sg_operation == operation) && 2.37 (sg_dev == device) && 2.38 (sg_next_sect == sector_number) )
3.1 --- a/xenolinux-2.4.23-sparse/arch/xeno/drivers/block/xl_block.h Mon Jan 05 17:56:11 2004 +0000 3.2 +++ b/xenolinux-2.4.23-sparse/arch/xeno/drivers/block/xl_block.h Mon Jan 05 22:55:26 2004 +0000 3.3 @@ -39,6 +39,9 @@ 3.4 #define DPRINTK_IOCTL(_f, _a...) ((void)0) 3.5 #endif 3.6 3.7 +/* Private gendisk->flags[] values. */ 3.8 +#define GENHD_FL_XENO 2 /* Is unit a Xen block device? */ 3.9 +#define GENHD_FL_VIRT_PARTNS 4 /* Are unit partitions virtual? */ 3.10 3.11 /* 3.12 * We have one of these per vbd, whether ide, scsi or 'other'.
4.1 --- a/xenolinux-2.4.23-sparse/arch/xeno/drivers/block/xl_vbd.c Mon Jan 05 17:56:11 2004 +0000 4.2 +++ b/xenolinux-2.4.23-sparse/arch/xeno/drivers/block/xl_vbd.c Mon Jan 05 22:55:26 2004 +0000 4.3 @@ -8,12 +8,11 @@ 4.4 #include "xl_block.h" 4.5 #include <linux/blk.h> 4.6 4.7 -#define GENHD_FL_XENO 2 4.8 - 4.9 -/* For convenience we distinguish between ide, scsi and 'other' (i.e. 4.10 -** potentially combinations of the two) in the naming scheme and in a 4.11 -** few other places (like default readahead, etc). 4.12 -*/ 4.13 +/* 4.14 + * For convenience we distinguish between ide, scsi and 'other' (i.e. 4.15 + * potentially combinations of the two) in the naming scheme and in a few 4.16 + * other places (like default readahead, etc). 4.17 + */ 4.18 #define XLIDE_MAJOR_NAME "hd" 4.19 #define XLSCSI_MAJOR_NAME "sd" 4.20 #define XLVBD_MAJOR_NAME "xvd" 4.21 @@ -31,7 +30,7 @@ 4.22 #define XLVBD_PARTN_SHIFT 6 /* amount to shift minor to get 'real' minor */ 4.23 #define XLVBD_MAX_PART (1 << XLVBD_PARTN_SHIFT) /* minors per 'other' vbd */ 4.24 4.25 -/* the below are for the use of the generic drivers/block/ll_rw_block.c code */ 4.26 +/* The below are for the generic drivers/block/ll_rw_block.c code. */ 4.27 static int xlide_blksize_size[256]; 4.28 static int xlide_hardsect_size[256]; 4.29 static int xlide_max_sectors[256]; 4.30 @@ -61,7 +60,7 @@ static struct block_device_operations xl 4.31 */ 4.32 int __init xlvbd_init(xen_disk_info_t *xdi) 4.33 { 4.34 - int i, result, max_part; 4.35 + int i, j, result, max_part; 4.36 struct gendisk *gd = NULL; 4.37 kdev_t device; 4.38 unsigned short major, minor, partno; 4.39 @@ -134,7 +133,7 @@ int __init xlvbd_init(xen_disk_info_t *x 4.40 continue; 4.41 } 4.42 4.43 - if( is_ide ) 4.44 + if ( is_ide ) 4.45 { 4.46 blksize_size[major] = xlide_blksize_size; 4.47 hardsect_size[major] = xlide_hardsect_size; 4.48 @@ -224,14 +223,37 @@ int __init xlvbd_init(xen_disk_info_t *x 4.49 gd->flags[minor >> gd->minor_shift] |= GENHD_FL_XENO; 4.50 4.51 if ( partno != 0 ) 4.52 - { 4.53 + { 4.54 + /* 4.55 + * If this was previously set up as a real disc we will have set 4.56 + * up partition-table information. Virtual partitions override 4.57 + * 'real' partitions, and the two cannot coexist on a device. 4.58 + */ 4.59 + if ( gd->sizes[minor & ~(max_part-1)] != 0 ) 4.60 + { 4.61 + kdev_t dev = device & ~(max_part-1); 4.62 + for ( j = max_part - 1; j >= 0; j-- ) 4.63 + { 4.64 + invalidate_device(dev+j, 1); 4.65 + gd->part[MINOR(dev+j)].start_sect = 0; 4.66 + gd->part[MINOR(dev+j)].nr_sects = 0; 4.67 + gd->sizes[MINOR(dev+j)] = 0; 4.68 + } 4.69 + printk(KERN_ALERT 4.70 + "Virtual partitions found for /dev/%s - ignoring any " 4.71 + "real partition information we may have found.\n", 4.72 + disk_name(gd, MINOR(device), buf)); 4.73 + } 4.74 + 4.75 /* Need to skankily setup 'partition' information */ 4.76 - gd->part[partno].start_sect = 0; 4.77 - gd->part[partno].nr_sects = xdi->disks[i].capacity; 4.78 - gd->sizes[partno] = xdi->disks[i].capacity; 4.79 + gd->part[minor].start_sect = 0; 4.80 + gd->part[minor].nr_sects = xdi->disks[i].capacity; 4.81 + gd->sizes[minor] = xdi->disks[i].capacity; 4.82 + 4.83 + gd->flags[minor >> gd->minor_shift] |= GENHD_FL_VIRT_PARTNS; 4.84 } 4.85 else 4.86 - { 4.87 + { 4.88 /* Some final fix-ups depending on the device type */ 4.89 switch ( XD_TYPE(xdi->disks[i].info) ) 4.90 { 4.91 @@ -248,8 +270,16 @@ int __init xlvbd_init(xen_disk_info_t *x 4.92 "floppy"), disk_name(gd, MINOR(device), buf)); 4.93 break; 4.94 4.95 - case XD_TYPE_DISK: 4.96 - register_disk(gd, device, gd->nr_real, &xlvbd_block_fops, 4.97 + case XD_TYPE_DISK: 4.98 + /* Only check partitions on real discs (not virtual!). */ 4.99 + if ( gd->flags[minor>>gd->minor_shift] & GENHD_FL_VIRT_PARTNS ) 4.100 + { 4.101 + printk(KERN_ALERT 4.102 + "Skipping partition check on virtual /dev/%s\n", 4.103 + disk_name(gd, MINOR(device), buf)); 4.104 + break; 4.105 + } 4.106 + register_disk(gd, device, gd->max_p, &xlvbd_block_fops, 4.107 xdi->disks[i].capacity); 4.108 break; 4.109