From: Pasi =?iso-8859-1?Q?K=E4rkk=E4inen?= Subject: Re: [PATCH]: Support dynamic resizing of vbds / print additional information patch Date: Sun, 15 Aug 2010 19:20:49 +0300 Message-ID: <20100815162049.GN2804@reaktio.net> References: <4B96456B0200003000080E91@sinclair.provo.novell.com> <20100720185017.GS17817@reaktio.net> <4C459C0B0200003000089AEB@sinclair.provo.novell.com> <201007202100.40466.joost@antarean.org> <20100720190656.GT17817@reaktio.net> <4C5029CC020000300008A3D0@sinclair.provo.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline In-Reply-To: <4C5029CC020000300008A3D0@sinclair.provo.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ky Srinivasan Cc: Jeremy Fitzhardinge , "J. Roeleveld" , xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org On Wed, Jul 28, 2010 at 12:59:56PM -0600, Ky Srinivasan wrote: > Pasi, >=20 > I am attaching a patch that prints additional information when a vbd is= resized. Note that on the domu side, the generic block layer already pri= nts information on the device that is being resized. >=20 > Signed-off-by: K. Y. Srinivasan >=20 Thanks. Jeremy: Please merge this patch. -- Pasi >=20 > >>> On 7/20/2010 at 3:06 PM, in message <20100720190656.GT17817@reakti= o.net>, Pasi > K=E4rkk=E4inen 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= trees. > >=20 > > -- Pasi > >=20 > >>=20 > >> The attached patch supports dynamic resizing of vbds. This patch fix= es a bug=20 > > in=20 > >> the previous version of this patch that was sent out. With this patc= h you=20 > > can=20 > >> perform "online" resizing of file systems that support online resiz= ing. > >>=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 suppor= ts > >> 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.000= 000000 -0600 > >> +++ linux/drivers/xen/blkback/blkback.c 2010-03-18 14:17:33.00000000= 0 -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.0000000= 00 -0600 > >> +++ linux/drivers/xen/blkback/vbd.c 2010-03-18 14:17:33.000000000 -0= 600 > >> @@ -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->stat= e); > >> + 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.0000= 00000 -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 i= nt=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.0= 00000000 -0600 > >> +++ linux/drivers/xen/blkfront/blkfront.c 2010-03-18 14:17:33.000000= 000 -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 >=20 > Subject: Print additional information when a vbd is resized. >=20 > Signed-off-by: K. Y. Srinivasan >=20 >=20 > 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-05-20 04:07:00.000000000 = -0600 > +++ linux/drivers/xen/blkback/vbd.c 2010-07-28 11:26:06.000000000 -0600 > @@ -130,6 +130,8 @@ void vbd_resize(blkif_t *blkif) > struct xenbus_device *dev =3D blkif->be->dev; > unsigned long long new_size =3D vbd_size(vbd); > =20 > + printk(KERN_INFO "VBD Resize: Domid: %d, Device: (%d, %d)\n", > + blkif->domid, MAJOR(vbd->pdevice), MINOR(vbd->pdevice)); > printk(KERN_INFO "VBD Resize: new size %Lu\n", new_size); > vbd->size =3D new_size; > again: > 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-05-20 04:07:00.0000= 00000 -0600 > +++ linux/drivers/xen/blkfront/blkfront.c 2010-07-28 12:10:26.000000000= -0600 > @@ -340,7 +340,7 @@ static void connect(struct blkfront_info > "sectors", "%Lu", §ors); > if (XENBUS_EXIST_ERR(err)) > return; > - printk(KERN_INFO "Setting capacity to %Lu\n", > + printk(KERN_INFO "Changing capacity to %Lu sectors\n", > sectors); > set_capacity(info->gd, sectors); > revalidate_disk(info->gd);