ia64/xen-unstable
changeset 1037:cb364c545252
bitkeeper revision 1.676 (400729e82e-mItLcWlTMg37ECD5kFQ)
xl_vbd.c, xl_block.c:
Fix VBD managament in Xenolinux.
xl_vbd.c, xl_block.c:
Fix VBD managament in Xenolinux.
author | kaf24@scramble.cl.cam.ac.uk |
---|---|
date | Fri Jan 16 00:01:44 2004 +0000 (2004-01-16) |
parents | 7c6c07befbdc |
children | dd6955d72ff5 |
files | xenolinux-2.4.24-sparse/arch/xeno/drivers/block/xl_block.c xenolinux-2.4.24-sparse/arch/xeno/drivers/block/xl_vbd.c |
line diff
1.1 --- a/xenolinux-2.4.24-sparse/arch/xeno/drivers/block/xl_block.c Thu Jan 15 23:31:05 2004 +0000 1.2 +++ b/xenolinux-2.4.24-sparse/arch/xeno/drivers/block/xl_block.c Fri Jan 16 00:01:44 2004 +0000 1.3 @@ -231,8 +231,8 @@ int xenolinux_block_revalidate(kdev_t de 1.4 struct block_device *bd; 1.5 struct gendisk *gd; 1.6 xl_disk_t *disk; 1.7 - unsigned long flags, capacity; 1.8 - int i, rc = 0, disk_nr = MINOR(dev) >> gd->minor_shift; 1.9 + unsigned long capacity; 1.10 + int i, rc = 0; 1.11 1.12 if ( (bd = bdget(dev)) == NULL ) 1.13 return -EINVAL; 1.14 @@ -257,16 +257,20 @@ int xenolinux_block_revalidate(kdev_t de 1.15 goto out; 1.16 } 1.17 1.18 - for ( i = gd->max_p - 1; i >= 0; i-- ) 1.19 + /* Only reread partition table if VBDs aren't mapped to partitions. */ 1.20 + if ( !(gd->flags[MINOR(dev) >> gd->minor_shift] & GENHD_FL_VIRT_PARTNS) ) 1.21 { 1.22 - invalidate_device(dev+i, 1); 1.23 - gd->part[MINOR(dev+i)].start_sect = 0; 1.24 - gd->part[MINOR(dev+i)].nr_sects = 0; 1.25 - gd->sizes[MINOR(dev+i)] = 0; 1.26 + for ( i = gd->max_p - 1; i >= 0; i-- ) 1.27 + { 1.28 + invalidate_device(dev+i, 1); 1.29 + gd->part[MINOR(dev+i)].start_sect = 0; 1.30 + gd->part[MINOR(dev+i)].nr_sects = 0; 1.31 + gd->sizes[MINOR(dev+i)] = 0; 1.32 + } 1.33 + 1.34 + grok_partitions(gd, MINOR(dev)>>gd->minor_shift, gd->max_p, capacity); 1.35 } 1.36 1.37 - grok_partitions(gd, disk_nr, gd->max_p, capacity); 1.38 - 1.39 out: 1.40 up(&bd->bd_sem); 1.41 bdput(bd);
2.1 --- a/xenolinux-2.4.24-sparse/arch/xeno/drivers/block/xl_vbd.c Thu Jan 15 23:31:05 2004 +0000 2.2 +++ b/xenolinux-2.4.24-sparse/arch/xeno/drivers/block/xl_vbd.c Fri Jan 16 00:01:44 2004 +0000 2.3 @@ -244,10 +244,16 @@ static int xlvbd_init_device(xen_disk_t 2.4 * up partition-table information. Virtual partitions override 2.5 * 'real' partitions, and the two cannot coexist on a device. 2.6 */ 2.7 - if ( gd->sizes[minor & ~(max_part-1)] != 0 ) 2.8 + if ( !(gd->flags[minor >> gd->minor_shift] & GENHD_FL_VIRT_PARTNS) && 2.9 + (gd->sizes[minor & ~(max_part-1)] != 0) ) 2.10 { 2.11 + /* 2.12 + * Any non-zero sub-partition entries must be cleaned out before 2.13 + * installing 'virtual' partition entries. The two types cannot 2.14 + * coexist, and virtual partitions are favoured. 2.15 + */ 2.16 kdev_t dev = device & ~(max_part-1); 2.17 - for ( i = max_part - 1; i >= 0; i-- ) 2.18 + for ( i = max_part - 1; i > 0; i-- ) 2.19 { 2.20 invalidate_device(dev+i, 1); 2.21 gd->part[MINOR(dev+i)].start_sect = 0; 2.22 @@ -269,14 +275,15 @@ static int xlvbd_init_device(xen_disk_t 2.23 } 2.24 else 2.25 { 2.26 + gd->part[minor].nr_sects = xd->capacity; 2.27 + gd->sizes[minor] = xd->capacity>>(BLOCK_SIZE_BITS-9); 2.28 + 2.29 /* Some final fix-ups depending on the device type */ 2.30 switch ( XD_TYPE(xd->info) ) 2.31 { 2.32 case XD_TYPE_CDROM: 2.33 case XD_TYPE_FLOPPY: 2.34 case XD_TYPE_TAPE: 2.35 - gd->part[minor].nr_sects = xd->capacity; 2.36 - gd->sizes[minor] = xd->capacity>>(BLOCK_SIZE_BITS-9); 2.37 gd->flags[minor >> gd->minor_shift] |= GENHD_FL_REMOVABLE; 2.38 printk(KERN_ALERT 2.39 "Skipping partition check on %s /dev/%s\n", 2.40 @@ -323,10 +330,10 @@ static int xlvbd_init_device(xen_disk_t 2.41 */ 2.42 static int xlvbd_remove_device(int device) 2.43 { 2.44 - int i, rc = 0, max_part, minor = MINOR(device); 2.45 + int i, rc = 0, minor = MINOR(device); 2.46 struct gendisk *gd; 2.47 struct block_device *bd; 2.48 - xl_disk_t *disk; 2.49 + xl_disk_t *disk = NULL; 2.50 2.51 if ( (bd = bdget(device)) == NULL ) 2.52 return -1; 2.53 @@ -347,15 +354,8 @@ static int xlvbd_remove_device(int devic 2.54 rc = -1; 2.55 goto out; 2.56 } 2.57 - 2.58 - if ( IDE_DISK_MAJOR(MAJOR(device)) ) 2.59 - max_part = XLIDE_MAX_PART; 2.60 - else if ( SCSI_BLK_MAJOR(MAJOR(device)) ) 2.61 - max_part = XLSCSI_MAX_PART; 2.62 - else 2.63 - max_part = XLVBD_MAX_PART; 2.64 2.65 - if ( (minor & (max_part-1)) != 0 ) 2.66 + if ( (minor & (gd->max_p-1)) != 0 ) 2.67 { 2.68 /* 1: The VBD is mapped to a partition rather than a whole unit. */ 2.69 invalidate_device(device, 1); 2.70 @@ -365,19 +365,42 @@ static int xlvbd_remove_device(int devic 2.71 2.72 /* Clear the consists-of-virtual-partitions flag if possible. */ 2.73 gd->flags[minor >> gd->minor_shift] &= ~GENHD_FL_VIRT_PARTNS; 2.74 - for ( i = 0; i < max_part; i++ ) 2.75 - if ( gd->sizes[(minor & ~(max_part-1)) + i] != 0 ) 2.76 + for ( i = 0; i < gd->max_p; i++ ) 2.77 + if ( gd->sizes[(minor & ~(gd->max_p-1)) + i] != 0 ) 2.78 gd->flags[minor >> gd->minor_shift] |= GENHD_FL_VIRT_PARTNS; 2.79 + 2.80 + /* 2.81 + * If all virtual partitions are now gone, and a 'whole unit' VBD is 2.82 + * present, then we can try to grok the unit's real partition table. 2.83 + */ 2.84 + if ( !(gd->flags[minor >> gd->minor_shift] & GENHD_FL_VIRT_PARTNS) && 2.85 + (gd->sizes[minor & ~(gd->max_p-1)] != 0) && 2.86 + !(gd->flags[minor >> gd->minor_shift] & GENHD_FL_REMOVABLE) ) 2.87 + { 2.88 + register_disk(gd, 2.89 + device&~(gd->max_p-1), 2.90 + gd->max_p, 2.91 + &xlvbd_block_fops, 2.92 + gd->part[minor&~(gd->max_p-1)].nr_sects); 2.93 + } 2.94 } 2.95 else 2.96 { 2.97 - /* 2: The VBD is mapped to an entire 'unit'. Clear all partitions. */ 2.98 - for ( i = max_part - 1; i >= 0; i-- ) 2.99 + /* 2.100 + * 2: The VBD is mapped to an entire 'unit'. Clear all partitions. 2.101 + * NB. The partition entries are only cleared if there are no VBDs 2.102 + * mapped to individual partitions on this unit. 2.103 + */ 2.104 + i = gd->max_p - 1; /* Default: clear subpartitions as well. */ 2.105 + if ( gd->flags[minor >> gd->minor_shift] & GENHD_FL_VIRT_PARTNS ) 2.106 + i = 0; /* 'Virtual' mode: only clear the 'whole unit' entry. */ 2.107 + while ( i >= 0 ) 2.108 { 2.109 invalidate_device(device+i, 1); 2.110 gd->part[minor+i].start_sect = 0; 2.111 gd->part[minor+i].nr_sects = 0; 2.112 gd->sizes[minor+i] = 0; 2.113 + i--; 2.114 } 2.115 } 2.116