aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoriap10@labyrinth.cl.cam.ac.uk <iap10@labyrinth.cl.cam.ac.uk>2004-07-14 18:52:20 +0000
committeriap10@labyrinth.cl.cam.ac.uk <iap10@labyrinth.cl.cam.ac.uk>2004-07-14 18:52:20 +0000
commit2f249882f1ed006caf545d224638791fbce3d422 (patch)
tree6a0e37c20aa89818813ae430518cdc277c1c7fc4
parent2e2b780e0f2bef1b52a6ff345613cff548709a1d (diff)
downloadxen-2f249882f1ed006caf545d224638791fbce3d422.tar.gz
xen-2f249882f1ed006caf545d224638791fbce3d422.tar.bz2
xen-2f249882f1ed006caf545d224638791fbce3d422.zip
bitkeeper revision 1.1088.1.1 (40f580e4lUYRavz4xXHwSuq0WmwdyA)
Clip vbd size to size of underlying device. A temporary fix until we replace the grow/shrink interface.
-rw-r--r--linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/backend/vbd.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/backend/vbd.c b/linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/backend/vbd.c
index 6704fbb541..134e94ef26 100644
--- a/linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/backend/vbd.c
+++ b/linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/backend/vbd.c
@@ -79,6 +79,8 @@ void vbd_grow(blkif_be_vbd_grow_t *grow)
vbd_t *vbd = NULL;
rb_node_t *rb;
blkif_vdev_t vdevice = grow->vdevice;
+ struct gendisk *gd;
+ struct hd_struct *hd;
blkif = blkif_find_by_handle(grow->domid, grow->blkif_handle);
if ( unlikely(blkif == NULL) )
@@ -123,6 +125,35 @@ void vbd_grow(blkif_be_vbd_grow_t *grow)
x->extent.sector_length = grow->extent.sector_length;
x->next = (blkif_extent_le_t *)NULL;
+ gd = get_gendisk(x->extent.device);
+
+ if (!gd || !gd->part)
+ {
+ grow->status = BLKIF_BE_STATUS_VBD_NOT_FOUND;
+ DPRINTK("vbd_grow: device %08x doesn't exist.\n", x->extent.device);
+ goto out;
+ }
+
+ hd = &gd->part[MINOR(x->extent.device)];
+
+ if (!hd)
+ {
+ grow->status = BLKIF_BE_STATUS_VBD_NOT_FOUND;
+ DPRINTK("vbd_grow: HD device %08x doesn't exist.\n", x->extent.device);
+ goto out;
+ }
+
+ printk("vbd_grow: requested_len %llu actual_len %lu\n",
+ x->extent.sector_length, hd->nr_sects );
+
+ /* this test assumes sector_start is zero, which in the new
+ IO world it always will be -- We need to simpligy the
+ grow/shrink interface as we'll always be deadling with whole
+ devices
+ */
+ if ( x->extent.sector_length > hd->nr_sects )
+ x->extent.sector_length = hd->nr_sects;
+
for ( px = &vbd->extents; *px != NULL; px = &(*px)->next )
continue;