From: "Satoshi Uchida" Subject: [PATCH][Resend] Output Virtual Block Device requests information ver. 3 Date: Wed, 28 Jun 2006 16:26:06 +0900 Message-ID: <000c01c69a84$1e787850$4c87380a@ad.spf.cl.nec.co.jp> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_000D_01C69ACF.8E602050" 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 This is a multi-part message in MIME format. ------=_NextPart_000_000D_01C69ACF.8E602050 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable Hi. These patches provide the function to output the information to sysfs. I changed the location to outputs statistical information of virtual = block device (VBD) from the /proc file system to the sysfs. The location is 'statstics' directory under each VBD directory, for = example, /sys/devices/xen-backend/vbd-x-xxxx/statistics. The 'statistics' directory includes the following three statistical = informations. oo_req is the number of Out of(?) requests. rd_req is the number of pended READ requests. wr_req is the number of pended WRITE requests. Examples are as follows. By applying this patch, sysfs creates "statistics" directory under the = "vbd-*" directory. The "statistics" directory includes three statistical information files = of VBD; oo_req, rd_req, wr_req.=20 [root@Domain-0 ~]# ls /sys/devices/xen-backend/vbd-1-2049/ bus driver nodename power uevent devtype mode physical_device statistics [root@Domain-0 ~]# ls /sys/devices/xen-backend/vbd-1-2049/statistics/ oo_req rd_req wr_req [root@Domain-0 ~]# cat = /sys/devices/xen-backend/vbd-1-2049/statistics/oo_req 0 [root@Domain-0 ~]# cat = /sys/devices/xen-backend/vbd-1-2049/statistics/rd_req 1592 [root@Domain-0 ~]# cat = /sys/devices/xen-backend/vbd-1-2049/statistics/wr_req 565 [root@Domain-0 ~]# Changing from ver. 2 is a following. - Code is clearly by moving xenbus.c - Do not change the type of each information. (It may be more desirable to change into unsigned into or = unsigned long) (But it is not essence for this mechanism) - Macro changes not using fmt representation (use like printf) =20 Thanks, Satoshi UCHIDA ------=_NextPart_000_000D_01C69ACF.8E602050 Content-Type: application/octet-stream; name="Add_VBD_info_to_sysfs_v3.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="Add_VBD_info_to_sysfs_v3.patch" # HG changeset patch=0A= # User root@mercury.spf.cl.nec.co.jp=0A= # Node ID 1a29b07abc6303f016d828070a8e4327fe8f53e9=0A= # Parent 161473836da3ccf922f44e910f8b5c01c709d1e6=0A= Output VBD requests information into sysfs.=0A= =0A= Add group "statistics" under /sys/device/xen-backed/vbd-x-xxxx=0A= and output VBD statistics information -- oo_req, rd_req, and wr_req --=0A= into its group.=0A= =0A= Signed-off-by: Satoshi UCHIDA =0A= =0A= diff -r 161473836da3 linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c=0A= --- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Wed Jun 14 = 22:15:13 2006 +0100=0A= +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Wed Jun 28 = 16:29:46 2006 +0900=0A= @@ -43,6 +43,13 @@ static void backend_changed(struct xenbu=0A= static void backend_changed(struct xenbus_watch *, const char **,=0A= unsigned int);=0A= =0A= +#ifdef CONFIG_SYSFS=0A= +int xenvbd_sysfs_addif(struct xenbus_device *dev);=0A= +void xenvbd_sysfs_delif(struct xenbus_device *dev);=0A= +#else=0A= +#define xenvbd_sysfs_addif(dev) (0)=0A= +#define xenvbd_sysfs_delif(dev) do { } while(0)=0A= +#endif=0A= =0A= static void update_blkif_status(blkif_t *blkif)=0A= { =0A= @@ -73,6 +80,66 @@ static void update_blkif_status(blkif_t =0A= }=0A= =0A= =0A= +=0A= +/****************************************************************=0A= + * sysfs interface for VBD I/O requests=0A= + */=0A= +=0A= +#ifdef CONFIG_SYSFS=0A= +=0A= +#define VBD_SHOW(name, format, args...) \=0A= + static ssize_t show_##name(struct device *_dev, \=0A= + struct device_attribute *attr, \=0A= + char *buf) \=0A= + { \=0A= + struct xenbus_device *dev =3D to_xenbus_device(_dev); \=0A= + struct backend_info *be =3D dev->dev.driver_data; \=0A= + \=0A= + return sprintf(buf, format, ##args); \=0A= + } \=0A= + DEVICE_ATTR(name, S_IRUGO, show_##name, NULL);=0A= +=0A= +VBD_SHOW(oo_req, "%d\n", be->blkif->st_oo_req);=0A= +VBD_SHOW(rd_req, "%d\n", be->blkif->st_rd_req);=0A= +VBD_SHOW(wr_req, "%d\n", be->blkif->st_wr_req);=0A= +=0A= +static struct attribute *vbdstat_attrs[] =3D {=0A= + &dev_attr_oo_req.attr,=0A= + &dev_attr_rd_req.attr,=0A= + &dev_attr_wr_req.attr,=0A= + NULL=0A= +};=0A= +=0A= +static struct attribute_group vbdstat_group =3D {=0A= + .name =3D "statistics",=0A= + .attrs =3D vbdstat_attrs,=0A= +};=0A= +=0A= +int xenvbd_sysfs_addif(struct xenbus_device *dev)=0A= +{=0A= + int error =3D 0;=0A= + =0A= + error =3D sysfs_create_group(&dev->dev.kobj,=0A= + &vbdstat_group);=0A= + if (error)=0A= + goto fail;=0A= + =0A= + return 0;=0A= + =0A= +fail:=0A= + sysfs_remove_group(&dev->dev.kobj,=0A= + &vbdstat_group);=0A= + return error;=0A= +}=0A= +=0A= +void xenvbd_sysfs_delif(struct xenbus_device *dev)=0A= +{=0A= + sysfs_remove_group(&dev->dev.kobj,=0A= + &vbdstat_group);=0A= +}=0A= +=0A= +#endif /* CONFIG_SYSFS */=0A= +=0A= static ssize_t show_physical_device(struct device *_dev,=0A= struct device_attribute *attr, char *buf)=0A= {=0A= @@ -114,6 +181,7 @@ static int blkback_remove(struct xenbus_=0A= =0A= device_remove_file(&dev->dev, &dev_attr_physical_device);=0A= device_remove_file(&dev->dev, &dev_attr_mode);=0A= + xenvbd_sysfs_delif(dev);=0A= =0A= kfree(be);=0A= dev->dev.driver_data =3D NULL;=0A= @@ -236,6 +304,7 @@ static void backend_changed(struct xenbu=0A= =0A= device_create_file(&dev->dev, &dev_attr_physical_device);=0A= device_create_file(&dev->dev, &dev_attr_mode);=0A= + xenvbd_sysfs_addif(dev);=0A= =0A= /* We're potentially connected now */=0A= update_blkif_status(be->blkif); =0A= ------=_NextPart_000_000D_01C69ACF.8E602050 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 ------=_NextPart_000_000D_01C69ACF.8E602050--