diff options
author | kaf24@labyrinth.cl.cam.ac.uk <kaf24@labyrinth.cl.cam.ac.uk> | 2003-03-06 16:54:15 +0000 |
---|---|---|
committer | kaf24@labyrinth.cl.cam.ac.uk <kaf24@labyrinth.cl.cam.ac.uk> | 2003-03-06 16:54:15 +0000 |
commit | 796305db16ed924df9d4061b70ba110e5978b226 (patch) | |
tree | 99fa4a1fe2f7b38485172dfe7720924f0178c9dc /xen/drivers/block | |
parent | 454a736db481ae4527360d5630ca9cd4148567c9 (diff) | |
parent | 8e06473cff7350a2ea62c5406cf2a733ebe82478 (diff) | |
download | xen-796305db16ed924df9d4061b70ba110e5978b226.tar.gz xen-796305db16ed924df9d4061b70ba110e5978b226.tar.bz2 xen-796305db16ed924df9d4061b70ba110e5978b226.zip |
bitkeeper revision 1.109 (3e677d37B9PCxHLX7a1Iufrz4eSUqA)
Manual merge of SMH + ACH worlds.
Diffstat (limited to 'xen/drivers/block')
-rw-r--r-- | xen/drivers/block/genhd.c | 61 | ||||
-rw-r--r-- | xen/drivers/block/grok.c | 39 | ||||
-rw-r--r-- | xen/drivers/block/xen_block.c | 118 |
3 files changed, 160 insertions, 58 deletions
diff --git a/xen/drivers/block/genhd.c b/xen/drivers/block/genhd.c index 427c2cb312..89d892ad47 100644 --- a/xen/drivers/block/genhd.c +++ b/xen/drivers/block/genhd.c @@ -193,6 +193,67 @@ out: } #endif +/* XXX SMH: stuff from fs/partitions dumped here temporarily */ + + +/* + * This function will re-read the partition tables for a given device, + * and set things back up again. There are some important caveats, + * however. You must ensure that no one is using the device, and no one + * can start using the device while this function is being executed. + * + * Much of the cleanup from the old partition tables should have already been + * done + */ +void register_disk(struct gendisk *gdev, kdev_t dev, unsigned minors, + struct block_device_operations *ops, long size) +{ + if (!gdev) + return; + grok_partitions(gdev, MINOR(dev)>>gdev->minor_shift, minors, size); +} + +void grok_partitions(struct gendisk *dev, int drive, unsigned minors, long size) +{ + int i; + int first_minor = drive << dev->minor_shift; + int end_minor = first_minor + dev->max_p; + + if(!dev->sizes) + blk_size[dev->major] = NULL; + + dev->part[first_minor].nr_sects = size; +#ifdef DEVFS_MUST_DIE + /* No such device or no minors to use for partitions */ + if ( !size && dev->flags && (dev->flags[drive] & GENHD_FL_REMOVABLE) ) + devfs_register_partitions (dev, first_minor, 0); +#endif + + if (!size || minors == 1) + return; + + if (dev->sizes) { + dev->sizes[first_minor] = size >> (BLOCK_SIZE_BITS - 9); + for (i = first_minor + 1; i < end_minor; i++) + dev->sizes[i] = 0; + } + blk_size[dev->major] = dev->sizes; +#if 0 + /* XXX SMH: don't actually check partition details yet */ + check_partition(dev, MKDEV(dev->major, first_minor), 1 + first_minor); +#endif + + /* + * We need to set the sizes array before we will be able to access + * any of the partitions on this device. + */ + if (dev->sizes != NULL) { /* optional safeguard in ll_rw_blk.c */ + for (i = first_minor; i < end_minor; i++) + dev->sizes[i] = dev->part[i].nr_sects >> (BLOCK_SIZE_BITS - 9); + } +} + + extern int blk_dev_init(void); extern int net_dev_init(void); diff --git a/xen/drivers/block/grok.c b/xen/drivers/block/grok.c new file mode 100644 index 0000000000..94f6df8869 --- /dev/null +++ b/xen/drivers/block/grok.c @@ -0,0 +1,39 @@ +void grok_partitions(struct gendisk *dev, int drive, unsigned minors, long size) +{ + int i; + int first_minor = drive << dev->minor_shift; + int end_minor = first_minor + dev->max_p; + + if(!dev->sizes) + blk_size[dev->major] = NULL; + + dev->part[first_minor].nr_sects = size; +#ifdef DEVFS_MUST_DIE + /* No such device or no minors to use for partitions */ + if ( !size && dev->flags && (dev->flags[drive] & GENHD_FL_REMOVABLE) ) + devfs_register_partitions (dev, first_minor, 0); +#endif + + if (!size || minors == 1) + return; + + if (dev->sizes) { + dev->sizes[first_minor] = size >> (BLOCK_SIZE_BITS - 9); + for (i = first_minor + 1; i < end_minor; i++) + dev->sizes[i] = 0; + } + blk_size[dev->major] = dev->sizes; +#if 0 + /* XXX SMH: don't actually check partition details yet */ + check_partition(dev, MKDEV(dev->major, first_minor), 1 + first_minor); +#endif + + /* + * We need to set the sizes array before we will be able to access + * any of the partitions on this device. + */ + if (dev->sizes != NULL) { /* optional safeguard in ll_rw_blk.c */ + for (i = first_minor; i < end_minor; i++) + dev->sizes[i] = dev->part[i].nr_sects >> (BLOCK_SIZE_BITS - 9); + } +} diff --git a/xen/drivers/block/xen_block.c b/xen/drivers/block/xen_block.c index 0e6a82ccc3..a0e3d51059 100644 --- a/xen/drivers/block/xen_block.c +++ b/xen/drivers/block/xen_block.c @@ -240,23 +240,23 @@ static void dispatch_debug_block_io(struct task_struct *p, int index) static void dispatch_create_segment(struct task_struct *p, int index) { - blk_ring_t *blk_ring = p->blk_ring_base; - xv_disk_t *xvd; - int result; - - if (p->domain != 0) - { - printk (KERN_ALERT "dispatch_create_segment called by dom%d\n", p->domain); - make_response(p, blk_ring->ring[index].req.id, XEN_BLOCK_SEG_CREATE, 1); - return; - } + blk_ring_t *blk_ring = p->blk_ring_base; + xv_disk_t *xvd; + int result; + + if (p->domain != 0) + { + DPRINTK("dispatch_create_segment called by dom%d\n", p->domain); + make_response(p, blk_ring->ring[index].req.id, XEN_BLOCK_SEG_CREATE, 1); + return; + } - xvd = phys_to_virt((unsigned long)blk_ring->ring[index].req.buffer); - result = xen_segment_create(xvd); + xvd = phys_to_virt((unsigned long)blk_ring->ring[index].req.buffer); + result = xen_segment_create(xvd); - make_response(p, blk_ring->ring[index].req.id, - XEN_BLOCK_SEG_CREATE, result); - return; + make_response(p, blk_ring->ring[index].req.id, + XEN_BLOCK_SEG_CREATE, result); + return; } static void dispatch_delete_segment(struct task_struct *p, int index) @@ -268,12 +268,16 @@ static void dispatch_probe_blk(struct task_struct *p, int index) { extern void ide_probe_devices(xen_disk_info_t *xdi, int *count, drive_t xdrives[]); + extern void scsi_probe_devices(xen_disk_info_t *xdi, int *count, + drive_t xdrives[]); + blk_ring_t *blk_ring = p->blk_ring_base; xen_disk_info_t *xdi; xdi = phys_to_virt((unsigned long)blk_ring->ring[index].req.buffer); + ide_probe_devices(xdi, &num_xdrives, xdrives); - /* scsi_probe_devices(xdi, &num_xdrives, xdrives); */ /* future */ + scsi_probe_devices(xdi, &num_xdrives, xdrives); make_response(p, blk_ring->ring[index].req.id, XEN_BLOCK_PROBE_BLK, 0); } @@ -371,39 +375,38 @@ static void dispatch_rw_block_io(struct task_struct *p, int index) xen_device = blk_ring->ring[index].req.device; if (IS_XHD_MAJOR(xen_device)) { - if (xen_device == XHDA_MAJOR) phys_device = MKDEV(IDE0_MAJOR, 0); - else if (xen_device == XHDB_MAJOR) phys_device = MKDEV(IDE1_MAJOR, 0); - else if (xen_device == XHDC_MAJOR) phys_device = MKDEV(IDE2_MAJOR, 0); - else if (xen_device == XHDD_MAJOR) phys_device = MKDEV(IDE3_MAJOR, 0); - else - { - printk (KERN_ALERT "dispatch_rw_block_io: unknown device %d\n", - xen_device); - BUG(); - } - - block_number = blk_ring->ring[index].req.block_number; - sector_number = blk_ring->ring[index].req.sector_number; + if (xen_device == XHDA_MAJOR) phys_device = MKDEV(IDE0_MAJOR, 0); + else if (xen_device == XHDB_MAJOR) phys_device = MKDEV(IDE1_MAJOR, 0); + else if (xen_device == XHDC_MAJOR) phys_device = MKDEV(IDE2_MAJOR, 0); + else if (xen_device == XHDD_MAJOR) phys_device = MKDEV(IDE3_MAJOR, 0); + else + { + printk(KERN_ALERT "dispatch_rw_block_io: unknown device %d\n", + xen_device); + BUG(); + } + + block_number = blk_ring->ring[index].req.block_number; + sector_number = blk_ring->ring[index].req.sector_number; } else if (IS_VHD_MAJOR(xen_device)) { - int s; - if (s = xen_segment_map_request(&phys_device, &block_number, - §or_number, - p, operation, xen_device, - blk_ring->ring[index].req.block_number, - blk_ring->ring[index].req.sector_number)) - { - printk ("dispatch_rw_block_io: xen_segment_map_request status: %d\n", - s); - goto bad_descriptor; - } + int s; + if (s = xen_segment_map_request(&phys_device, &block_number, + §or_number, + p, operation, xen_device, + blk_ring->ring[index].req.block_number, + blk_ring->ring[index].req.sector_number)) + { + DPRINTK("dispatch_rw_block_io: xen_seg_map_request status: %d\n", s); + goto bad_descriptor; + } } else { - printk (KERN_ALERT "dispatch_rw_block_io: unknown device %d\n", - xen_device); - BUG(); + printk (KERN_ALERT "dispatch_rw_block_io: unknown device %d\n", + xen_device); + BUG(); } bh->b_blocknr = block_number; @@ -433,9 +436,8 @@ static void dispatch_rw_block_io(struct task_struct *p, int index) return; bad_descriptor: - printk (KERN_ALERT "dispatch rw blockio bad descriptor\n"); + DPRINTK("dispatch rw blockio bad descriptor\n"); make_response(p, blk_ring->ring[index].req.id, XEN_BLOCK_READ, 1); - return; } @@ -468,23 +470,23 @@ static void make_response(struct task_struct *p, void *id, static void dump_blockq(u_char key, void *dev_id, struct pt_regs *regs) { - struct task_struct *p; - blk_ring_t *blk_ring ; + struct task_struct *p; + blk_ring_t *blk_ring ; - printk("Dumping block queue stats: nr_pending = %d\n", - atomic_read(&nr_pending)); + printk("Dumping block queue stats: nr_pending = %d\n", + atomic_read(&nr_pending)); - p = current->next_task; - do - { - printk (KERN_ALERT "Domain: %d\n", p->domain); - blk_ring = p->blk_ring_base; + p = current->next_task; + do + { + printk (KERN_ALERT "Domain: %d\n", p->domain); + blk_ring = p->blk_ring_base; - printk(" req_prod:%d, resp_prod:%d, req_cons:%d\n", - blk_ring->req_prod, blk_ring->resp_prod, p->blk_req_cons); + printk(" req_prod:%d, resp_prod:%d, req_cons:%d\n", + blk_ring->req_prod, blk_ring->resp_prod, p->blk_req_cons); - p = p->next_task; - } while (p != current); + p = p->next_task; + } while (p != current); } /* Start-of-day initialisation for a new domain. */ |