xen/front: Propagate changed size of VBDs
authorK. Y. Srinivasan <ksrinivasan@novell.com>
Thu, 11 Mar 2010 21:42:26 +0000 (13:42 -0800)
committerJens Axboe <jaxboe@fusionio.com>
Sat, 7 Aug 2010 16:31:27 +0000 (18:31 +0200)
Support dynamic resizing of virtual block devices. This patch supports
both file backed block devices as well as physical devices that can be
dynamically resized on the host side.

Signed-off-by: K. Y. Srinivasan <ksrinivasan@novell.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
drivers/block/xen-blkfront.c

index 60006b7..f47b096 100644 (file)
@@ -930,9 +930,24 @@ static void blkfront_connect(struct blkfront_info *info)
        unsigned int binfo;
        int err;
 
-       if ((info->connected == BLKIF_STATE_CONNECTED) ||
-           (info->connected == BLKIF_STATE_SUSPENDED) )
+       switch (info->connected) {
+       case BLKIF_STATE_CONNECTED:
+               /*
+                * Potentially, the back-end may be signalling
+                * a capacity change; update the capacity.
+                */
+               err = xenbus_scanf(XBT_NIL, info->xbdev->otherend,
+                                  "sectors", "%Lu", &sectors);
+               if (XENBUS_EXIST_ERR(err))
+                       return;
+               printk(KERN_INFO "Setting capacity to %Lu\n",
+                      sectors);
+               set_capacity(info->gd, sectors);
+
+               /* fall through */
+       case BLKIF_STATE_SUSPENDED:
                return;
+       }
 
        dev_dbg(&info->xbdev->dev, "%s:%s.\n",
                __func__, info->xbdev->otherend);