Output Virtual Block Device requests information ver. 3
PATCH RESEND 1/1 Output Virtual Block Device requests information ver. 3
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.
[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)
Thanks,
Satoshi UCHIDA
# HG changeset patch
# User [email protected]
# Node ID 1a29b07abc6303f016d828070a8e4327fe8f53e9 # Parent 161473836da3ccf922f44e910f8b5c01c709d1e6 Output VBD requests information into sysfs.
Add group "statistics" under /sys/device/xen-backed/vbd-x-xxxx and output VBD statistics information -- oo_req, rd_req, and wr_req -- into its group.
linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c +69 -0
@@ -43,6 +43,13 @@ static void backend_changed(struct xenbustatic void backend_changed (struct xenbus_watch *,const char **,unsigned int ); +#ifdef CONFIG_SYSFS +int xenvbd_sysfs_addif (struct xenbus_device *dev); +void xenvbd_sysfs_delif (struct xenbus_device *dev); +#else +#define xenvbd_sysfs_addif (dev) (0) +#define xenvbd_sysfs_delif (dev) do { } while(0) +#endif static void update_blkif_status (blkif_t *blkif) {
@@ -73,6 +80,66 @@ static void update_blkif_status(blkif_t } + +/**************************************************************** +* sysfs interface for VBD I/O requests +*/ + +#ifdef CONFIG_SYSFS + +#define VBD_SHOW(name, format, args...) \ + static ssize_t show_##name(struct device *_dev, \ + struct device_attribute *attr, \ + char *buf) \ + { \ + struct xenbus_device *dev = to_xenbus_device(_dev); \ + struct backend_info *be = dev->dev.driver_data; \ + \ + return sprintf(buf, format, ##args); \ + } \ + DEVICE_ATTR(name, S_IRUGO, show_##name, NULL); + +VBD_SHOW (oo_req,"%d\n" , be->blkif->st_oo_req); +VBD_SHOW (rd_req,"%d\n" , be->blkif->st_rd_req); +VBD_SHOW (wr_req,"%d\n" , be->blkif->st_wr_req); + +static struct attribute *vbdstat_attrs[] = { + &dev_attr_oo_req.attr, + &dev_attr_rd_req.attr, + &dev_attr_wr_req.attr, +NULL +}; + +static struct attribute_group vbdstat_group = { + .name ="statistics" , + .attrs = vbdstat_attrs, +}; + +int xenvbd_sysfs_addif (struct xenbus_device *dev) +{ +int error =0 ; + + error =sysfs_create_group (&dev->dev.kobj, + &vbdstat_group); +if (error) + goto fail; + +return 0 ; + +fail: +sysfs_remove_group (&dev->dev.kobj, + &vbdstat_group); +return error; +} + +void xenvbd_sysfs_delif (struct xenbus_device *dev) +{ +sysfs_remove_group (&dev->dev.kobj, + &vbdstat_group); +} + +#endif /* CONFIG_SYSFS */ +static ssize_t show_physical_device (struct device *_dev,struct device_attribute *attr,char *buf) {
@@ -114,6 +181,7 @@ static int blkback_remove(struct xenbus_device_remove_file (&dev->dev, &dev_attr_physical_device);device_remove_file (&dev->dev, &dev_attr_mode); +xenvbd_sysfs_delif (dev);kfree (be); dev->dev.driver_data =NULL ;
@@ -236,6 +304,7 @@ static void backend_changed(struct xenbudevice_create_file (&dev->dev, &dev_attr_physical_device);device_create_file (&dev->dev, &dev_attr_mode); +xenvbd_sysfs_addif (dev);/* We're potentially connected now */ update_blkif_status (be->blkif);
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel