From: "Ky Srinivasan" Subject: Re: [PATCH]: Support dynamic resizing of vbds Date: Wed, 28 Jul 2010 12:59:56 -0600 Message-ID: <4C5029CC020000300008A3D0@sinclair.provo.novell.com> References: <4B96456B0200003000080E91@sinclair.provo.novell.com> <20100720185017.GS17817@reaktio.net> <4C459C0B0200003000089AEB@sinclair.provo.novell.com> <201007202100.40466.joost@antarean.org> <20100720190656.GT17817@reaktio.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part361B273C.2__=" Return-path: In-Reply-To: <20100720190656.GT17817@reaktio.net> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "J. Roeleveld" , =?UTF-8?B?UGFzaSBLw6Rya2vDpGluZW4=?= Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --=__Part361B273C.2__= Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Pasi, I am attaching a patch that prints additional information when a vbd is r= esized. Note that on the domu side, the generic block layer already print= s information on the device that is being resized. Signed-off-by: K. Y. Srinivasan >>> On 7/20/2010 at 3:06 PM, in message <20100720190656.GT17817@reaktio.= net>, Pasi K=C3=A4rkk=C3=A4inen wrote:=20 > On Tue, Jul 20, 2010 at 09:00:39PM +0200, J. Roeleveld wrote: >> > > >> > > Hmm.. I don't seem to be able to find them. >> > > Care to send them again? >> > > >> > > -- Pasi >> >=20 >> > I will dig this up and send it out. >> >=20 >> > Regards, >> >=20 >> > K. Y >> >=20 >>=20 >>=20 >> found this in my archives: >>=20 >=20 > Thanks, but unfortunately this is not the patch that adds useful=20 > status/resize information printing.. >=20 > The patch you attached is already merged into Jeremy's xen.git kernel t= rees. >=20 > -- Pasi >=20 >>=20 >> The attached patch supports dynamic resizing of vbds. This patch fixes= a bug=20 > in=20 >> the previous version of this patch that was sent out. With this patch = you=20 > can=20 >> perform "online" resizing of file systems that support online resizin= g. >>=20 >> Signed-off-by: K. Y. Srinivasan >=20 >> Subject: Propagate changed size of VBDs >> References: bnc#583677 >> Patch-mainline: n/a >>=20 >> 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. >>=20 >> Signed-off-by: K. Y. Srinivasan >>=20 >> Index: linux/drivers/xen/blkback/blkback.c >> =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 >> --- linux.orig/drivers/xen/blkback/blkback.c 2010-03-18 14:17:28.00000= 0000 -0600 >> +++ linux/drivers/xen/blkback/blkback.c 2010-03-18 14:17:33.000000000 = -0600 >> @@ -209,6 +209,7 @@ static void print_stats(blkif_t *blkif) >> int blkif_schedule(void *arg) >> { >> blkif_t *blkif =3D arg; >> + struct vbd *vbd =3D &blkif->vbd; >> =20 >> blkif_get(blkif); >> =20 >> @@ -218,6 +219,8 @@ int blkif_schedule(void *arg) >> while (!kthread_should_stop()) { >> if (try_to_freeze()) >> continue; >> + if (unlikely(vbd->size !=3D vbd_size(vbd))) >> + vbd_resize(blkif); >> =20 >> wait_event_interruptible( >> blkif->wq, >> Index: linux/drivers/xen/blkback/vbd.c >> =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 >> --- linux.orig/drivers/xen/blkback/vbd.c 2010-03-18 14:17:28.000000000= -0600 >> +++ linux/drivers/xen/blkback/vbd.c 2010-03-18 14:17:33.000000000 -060= 0 >> @@ -73,6 +73,7 @@ int vbd_create(blkif_t *blkif, blkif_vde >> } >> =20 >> vbd->bdev =3D bdev; >> + vbd->size =3D vbd_size(vbd); >> =20 >> if (vbd->bdev->bd_disk =3D=3D NULL) { >> DPRINTK("vbd_creat: device %08x doesn't exist.\n", >> @@ -120,3 +121,45 @@ int vbd_translate(struct phys_req *req, >> out: >> return rc; >> } >> + >> +void vbd_resize(blkif_t *blkif) >> +{ >> + struct vbd *vbd =3D &blkif->vbd; >> + struct xenbus_transaction xbt; >> + int err; >> + struct xenbus_device *dev =3D blkif->be->dev; >> + unsigned long long new_size =3D vbd_size(vbd); >> + >> + printk(KERN_INFO "VBD Resize: new size %Lu\n", new_size); >> + vbd->size =3D new_size; >> +again: >> + err =3D xenbus_transaction_start(&xbt); >> + if (err) { >> + printk(KERN_WARNING "Error starting transaction"); >> + return; >> + } >> + err =3D xenbus_printf(xbt, dev->nodename, "sectors", "%Lu", >> + vbd_size(vbd)); >> + if (err) { >> + printk(KERN_WARNING "Error writing new size"); >> + goto abort; >> + } >> + /* >> + * Write the current state; we will use this to synchronize >> + * the front-end. If the current state is "connected" the >> + * front-end will get the new size information online. >> + */ >> + err =3D xenbus_printf(xbt, dev->nodename, "state", "%d", dev->state)= ; >> + if (err) { >> + printk(KERN_WARNING "Error writing the state"); >> + goto abort; >> + } >> + >> + err =3D xenbus_transaction_end(xbt, 0); >> + if (err =3D=3D -EAGAIN) >> + goto again; >> + if (err) >> + printk(KERN_WARNING "Error ending transaction"); >> +abort: >> + xenbus_transaction_end(xbt, 1); >> +} >> Index: linux/drivers/xen/blkback/common.h >> =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 >> --- linux.orig/drivers/xen/blkback/common.h 2010-03-18 14:17:28.000000= 000 -0600 >> +++ linux/drivers/xen/blkback/common.h 2010-03-18 14:17:33.000000000 -= 0600 >> @@ -56,6 +56,7 @@ struct vbd { >> unsigned char type; /* VDISK_xxx */ >> u32 pdevice; /* phys device that this vbd maps to */ >> struct block_device *bdev; >> + sector_t size; /* Cached size parameter */ >> }; >> =20 >> struct backend_info; >> @@ -116,6 +117,7 @@ blkif_t *blkif_alloc(domid_t domid); >> void blkif_disconnect(blkif_t *blkif); >> void blkif_free(blkif_t *blkif); >> int blkif_map(blkif_t *blkif, unsigned long shared_page, unsigned int= =20 > evtchn); >> +void vbd_resize(blkif_t *blkif); >> =20 >> #define blkif_get(_b) (atomic_inc(&(_b)->refcnt)) >> #define blkif_put(_b) \ >> Index: linux/drivers/xen/blkfront/blkfront.c >> =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 >> --- linux.orig/drivers/xen/blkfront/blkfront.c 2010-03-18 14:17:28.000= 000000 -0600 >> +++ linux/drivers/xen/blkfront/blkfront.c 2010-03-18 14:17:33.00000000= 0 -0600 >> @@ -328,9 +328,25 @@ static void connect(struct blkfront_info >> unsigned int binfo; >> int err; >> =20 >> - if ((info->connected =3D=3D BLKIF_STATE_CONNECTED) || >> - (info->connected =3D=3D BLKIF_STATE_SUSPENDED) ) >> + switch (info->connected) { >> + case BLKIF_STATE_CONNECTED: >> + /* >> + * Potentially, the back-end may be signalling >> + * a capacity change; update the capacity. >> + */ >> + err =3D xenbus_scanf(XBT_NIL, info->xbdev->otherend, >> + "sectors", "%Lu", §ors); >> + if (XENBUS_EXIST_ERR(err)) >> + return; >> + printk(KERN_INFO "Setting capacity to %Lu\n", >> + sectors); >> + set_capacity(info->gd, sectors); >> + revalidate_disk(info->gd); >> + >> + /* fall through */ >> + case BLKIF_STATE_SUSPENDED: >> return; >> + } >> =20 >> DPRINTK("blkfront.c:connect:%s.\n", info->xbdev->otherend); >> =20 >=20 >> _______________________________________________ >> Xen-devel mailing list >> Xen-devel@lists.xensource.com >> http://lists.xensource.com/xen-devel >=20 >=20 > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel --=__Part361B273C.2__= Content-Type: text/plain; name="online_resize_info.PATCH" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="online_resize_info.PATCH" Subject: Print additional information when a vbd is resized.=0A=0ASigned-of= f-by: K. Y. Srinivasan =0A=0A=0AIndex: linux/driver= s/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-05-20 04:07:00.0000000= 00 -0600=0A+++ linux/drivers/xen/blkback/vbd.c 2010-07-28 11:26:06.0000000= 00 -0600=0A@@ -130,6 +130,8 @@ void vbd_resize(blkif_t *blkif)=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: = Domid: %d, Device: (%d, %d)\n",=0A+ blkif->domid, MAJOR(vbd->pd= evice), MINOR(vbd->pdevice));=0A printk(KERN_INFO "VBD Resize: new = size %Lu\n", new_size);=0A vbd->size =3D new_size;=0A again:=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-05-20 04:07:00.000000000 -0600=0A+++ linux/drivers/xen/blkfront/blkfro= nt.c 2010-07-28 12:10:26.000000000 -0600=0A@@ -340,7 +340,7 @@ static = void connect(struct blkfront_info=0A = "sectors", "%Lu", §ors);=0A if (XENBUS_EXIST_ERR(err))= =0A return;=0A- printk(KERN_INFO "Setting = capacity to %Lu\n",=0A+ printk(KERN_INFO "Changing capacity to %Lu = sectors\n",=0A sectors);=0A set_capacity(info->= gd, sectors);=0A revalidate_disk(info->gd);=0A --=__Part361B273C.2__= 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 --=__Part361B273C.2__=--