Output Virtual Block Device requests information ver. 2. Add information to sysfs.
PATCH 1/1 Output Virtual Block Device requests information ver. 2. Add information to sysfs.
This patch adds VBD statistic informations to sysfs.
It creates 'statistics' directory under each VBD directory, and makes a sysfs file for each statistical information of VBD.
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 ~]#
Thanks,
Satoshi UCHIDA
# HG changeset patch
# User Satoshi UCHIDA <[email protected]> # Node ID 7b69444493c10e0ee7fbdd787cb28517a75c77f8 # Parent 161473836da3ccf922f44e910f8b5c01c709d1e6 Output VBD request information into sysfs.
Add group "statistics" and output each information into its group. Output information are oo_req, rd_req, and wr_req.
linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c +50 -1
@@ -40,6 +40,7 @@#include <linux/list.h> #include <xen/balloon.h> #include <asm/hypervisor.h> +#include <xen/xenbus.h> #include "common.h" /*
@@ -191,7 +192,7 @@ static void fast_flush_area(pending_req_static void print_stats (blkif_t *blkif) { -printk (KERN_DEBUG "%s: oo %3d | rd %4d | wr %4d\n" , +printk (KERN_DEBUG "%s: oo %3lu | rd %4lu | wr %4lu\n" , current->comm, blkif->st_oo_req, blkif->st_rd_req, blkif->st_wr_req); blkif->st_print = jiffies +msecs_to_jiffies (10 *1000 );
@@ -463,6 +464,54 @@ static void dispatch_rw_block_io(blkif_tfree_req (pending_req); } + + +/**************************************************************** +* sysfs interface for VBD I/O requests +*/ + +#ifdef CONFIG_SYSFS + +VBD_SHOW (oo_req, fmt_ulong, be->blkif->st_oo_req); +VBD_SHOW (rd_req, fmt_ulong, be->blkif->st_rd_req); +VBD_SHOW (wr_req, fmt_ulong, 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 */ /******************************************************************
linux-2.6-xen-sparse/drivers/xen/blkback/common.h +41 -3
66 lines not on this page · raw message
linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c +3 -11
@@ -27,16 +27,6 @@ #define DPRINTK(fmt, args...) \ pr_debug("blkback/xenbus (%s:%d) " fmt ".\n", \ __FUNCTION__, __LINE__, ##args) - -struct backend_info -{ -struct xenbus_device *dev; -blkif_t *blkif; -struct xenbus_watch backend_watch; -unsigned major; -unsigned minor; -char *mode; -};static void connect (struct backend_info *);static int connect_ring (struct backend_info *);
@@ -114,7 +104,8 @@ 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 ;return 0 ;
@@ -236,6 +227,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