From: "Ky Srinivasan" Subject: [PATCH]: Support dynamic resizing of vbds Date: Thu, 18 Mar 2010 14:28:37 -0600 Message-ID: <4BA23895020000300008184F@sinclair.provo.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartE8C20CE5.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --=__PartE8C20CE5.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline The attached patch supports dynamic resizing of vbds. This patch fixes a = bug in the previous version of this patch that was sent out. With this = patch you can perform "online" resizing of file systems that support = online resizing. Signed-off-by: K. Y. Srinivasan --=__PartE8C20CE5.0__= Content-Type: text/plain; name="xen-vbd-resize.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="xen-vbd-resize.patch" Subject: Propagate changed size of VBDs=0AReferences: bnc#583677=0APatch-ma= inline: n/a=0A=0ASupport dynamic resizing of virtual block devices. This = patch supports=0Aboth file backed block devices as well as physical = devices that can be=0Adynamically resized on the host side.=0A=0ASigned-off= -by: K. Y. Srinivasan =0A=0AIndex: linux/drivers/xe= n/blkback/blkback.c=0A=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =0A--- linux.orig/drivers/xen/blkback/blkback.c 2010-03-18 14:17:28.0000000= 00 -0600=0A+++ linux/drivers/xen/blkback/blkback.c 2010-03-18 = 14:17:33.000000000 -0600=0A@@ -209,6 +209,7 @@ static void print_stats(blki= f_t *blkif)=0A int blkif_schedule(void *arg)=0A {=0A blkif_t *blkif =3D = arg;=0A+ struct vbd *vbd =3D &blkif->vbd;=0A =0A blkif_get(b= lkif);=0A =0A@@ -218,6 +219,8 @@ int blkif_schedule(void *arg)=0A = while (!kthread_should_stop()) {=0A if (try_to_freeze())=0A = continue;=0A+ if (unlikely(vbd->size !=3D = vbd_size(vbd)))=0A+ vbd_resize(blkif);=0A =0A = wait_event_interruptible(=0A blkif->wq,=0AIndex: = linux/drivers/xen/blkback/vbd.c=0A=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=0A--- linux.orig/drivers/xen/blkback/vbd.c 2010-03-18 = 14:17:28.000000000 -0600=0A+++ linux/drivers/xen/blkback/vbd.c 2010-03-18 = 14:17:33.000000000 -0600=0A@@ -73,6 +73,7 @@ int vbd_create(blkif_t = *blkif, blkif_vde=0A }=0A =0A vbd->bdev =3D bdev;=0A+ vbd->size = =3D vbd_size(vbd);=0A =0A if (vbd->bdev->bd_disk =3D=3D NULL) {=0A = DPRINTK("vbd_creat: device %08x doesn't exist.\n",=0A@@ -120,3 = +121,45 @@ int vbd_translate(struct phys_req *req,=0A out:=0A return = rc;=0A }=0A+=0A+void vbd_resize(blkif_t *blkif)=0A+{=0A+ struct vbd = *vbd =3D &blkif->vbd;=0A+ struct xenbus_transaction xbt;=0A+ = int err;=0A+ struct xenbus_device *dev =3D blkif->be->dev;=0A+ = unsigned long long new_size =3D vbd_size(vbd);=0A+=0A+ printk(KERN_INFO = "VBD Resize: new size %Lu\n", new_size);=0A+ vbd->size =3D new_size;=0A+= again:=0A+ err =3D xenbus_transaction_start(&xbt);=0A+ if (err) = {=0A+ printk(KERN_WARNING "Error starting transaction");=0A+ = return;=0A+ }=0A+ err =3D xenbus_printf(xbt, dev->nodename, = "sectors", "%Lu",=0A+ vbd_size(vbd));=0A+ if (err) = {=0A+ printk(KERN_WARNING "Error writing new size");=0A+ = goto abort;=0A+ }=0A+ /*=0A+ * Write the current state; we will use = this to synchronize=0A+ * the front-end. If the current state is = "connected" the=0A+ * front-end will get the new size information = online.=0A+ */=0A+ err =3D xenbus_printf(xbt, dev->nodename, "state", = "%d", dev->state);=0A+ if (err) {=0A+ printk(KERN_WARNING "Error = writing the state");=0A+ goto abort;=0A+ }=0A+=0A+ = err =3D xenbus_transaction_end(xbt, 0);=0A+ if (err =3D=3D -EAGAIN)=0A+= goto again;=0A+ if (err)=0A+ printk(KERN_WARNING= "Error ending transaction");=0A+abort:=0A+ xenbus_transaction_end(xbt,= 1);=0A+}=0AIndex: linux/drivers/xen/blkback/common.h=0A=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A--- linux.orig/drivers/xen/blkback/comm= on.h 2010-03-18 14:17:28.000000000 -0600=0A+++ linux/drivers/xen/blkback= /common.h 2010-03-18 14:17:33.000000000 -0600=0A@@ -56,6 +56,7 @@ = struct vbd {=0A unsigned char type; /* VDISK_xxx */=0A = u32 pdevice; /* phys device that this vbd maps to */=0A = struct block_device *bdev;=0A+ sector_t size; /* Cached size = parameter */=0A };=0A =0A struct backend_info;=0A@@ -116,6 +117,7 @@ = blkif_t *blkif_alloc(domid_t domid);=0A void blkif_disconnect(blkif_t = *blkif);=0A void blkif_free(blkif_t *blkif);=0A int blkif_map(blkif_t = *blkif, unsigned long shared_page, unsigned int evtchn);=0A+void vbd_resize= (blkif_t *blkif);=0A =0A #define blkif_get(_b) (atomic_inc(&(_b)->refcnt))= =0A #define blkif_put(_b) \=0AIndex: = linux/drivers/xen/blkfront/blkfront.c=0A=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=0A--- linux.orig/drivers/xen/blkfront/blkfront.c = 2010-03-18 14:17:28.000000000 -0600=0A+++ linux/drivers/xen/blkfront/blkfro= nt.c 2010-03-18 14:17:33.000000000 -0600=0A@@ -328,9 +328,25 @@ static = void connect(struct blkfront_info=0A unsigned int binfo;=0A int = err;=0A =0A- if ((info->connected =3D=3D BLKIF_STATE_CONNECTED) ||=0A- = (info->connected =3D=3D BLKIF_STATE_SUSPENDED) )=0A+ switch = (info->connected) {=0A+ case BLKIF_STATE_CONNECTED:=0A+ /*=0A+ = * Potentially, the back-end may be signalling=0A+ * a = capacity change; update the capacity.=0A+ */=0A+ = err =3D xenbus_scanf(XBT_NIL, info->xbdev->otherend,=0A+ = "sectors", "%Lu", §ors);=0A+ if (XENBUS_EXIST_ER= R(err))=0A+ return;=0A+ printk(KERN_INFO = "Setting capacity to %Lu\n",=0A+ sectors);=0A+ = set_capacity(info->gd, sectors);=0A+ revalidate_disk(info->gd);= =0A+=0A+ /* fall through */=0A+ case BLKIF_STATE_SUSPENDED:= =0A return;=0A+ }=0A =0A DPRINTK("blkfront.c:connect= :%s.\n", info->xbdev->otherend);=0A =0A --=__PartE8C20CE5.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=__PartE8C20CE5.0__=--