direct-io.hg
changeset 10514:b217e03e1db5
[BLKBACK] Output statistics to sysfs.
The location is 'statistics' directory under each VBD directory, for
example, /sys/devices/xen-backend/vbd-x-xxxx/statistics.
The 'statistics' directory includes the following three statistical
information:
oo_req
is the number of requests held up due to full pipeline.
rd_req
is the number of processed READ requests.
wr_req
is the number of processed WRITE requests.
Signed-off-by: Satoshi UCHIDA <s-uchida@ap.jp.nec.com>
The location is 'statistics' directory under each VBD directory, for
example, /sys/devices/xen-backend/vbd-x-xxxx/statistics.
The 'statistics' directory includes the following three statistical
information:
oo_req
is the number of requests held up due to full pipeline.
rd_req
is the number of processed READ requests.
wr_req
is the number of processed WRITE requests.
Signed-off-by: Satoshi UCHIDA <s-uchida@ap.jp.nec.com>
author | kfraser@dhcp93.uk.xensource.com |
---|---|
date | Wed Jun 28 10:32:43 2006 +0100 (2006-06-28) |
parents | 7a7066ae2e77 |
children | 6e7027a2abca |
files | linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c |
line diff
1.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Wed Jun 28 10:24:05 2006 +0100 1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Wed Jun 28 10:32:43 2006 +0100 1.3 @@ -43,7 +43,6 @@ static int connect_ring(struct backend_i 1.4 static void backend_changed(struct xenbus_watch *, const char **, 1.5 unsigned int); 1.6 1.7 - 1.8 static void update_blkif_status(blkif_t *blkif) 1.9 { 1.10 int err; 1.11 @@ -73,6 +72,70 @@ static void update_blkif_status(blkif_t 1.12 } 1.13 1.14 1.15 +/**************************************************************** 1.16 + * sysfs interface for VBD I/O requests 1.17 + */ 1.18 + 1.19 +#ifdef CONFIG_SYSFS 1.20 + 1.21 +#define VBD_SHOW(name, format, args...) \ 1.22 + static ssize_t show_##name(struct device *_dev, \ 1.23 + struct device_attribute *attr, \ 1.24 + char *buf) \ 1.25 + { \ 1.26 + struct xenbus_device *dev = to_xenbus_device(_dev); \ 1.27 + struct backend_info *be = dev->dev.driver_data; \ 1.28 + \ 1.29 + return sprintf(buf, format, ##args); \ 1.30 + } \ 1.31 + DEVICE_ATTR(name, S_IRUGO, show_##name, NULL) 1.32 + 1.33 +VBD_SHOW(oo_req, "%d\n", be->blkif->st_oo_req); 1.34 +VBD_SHOW(rd_req, "%d\n", be->blkif->st_rd_req); 1.35 +VBD_SHOW(wr_req, "%d\n", be->blkif->st_wr_req); 1.36 + 1.37 +static struct attribute *vbdstat_attrs[] = { 1.38 + &dev_attr_oo_req.attr, 1.39 + &dev_attr_rd_req.attr, 1.40 + &dev_attr_wr_req.attr, 1.41 + NULL 1.42 +}; 1.43 + 1.44 +static struct attribute_group vbdstat_group = { 1.45 + .name = "statistics", 1.46 + .attrs = vbdstat_attrs, 1.47 +}; 1.48 + 1.49 +int xenvbd_sysfs_addif(struct xenbus_device *dev) 1.50 +{ 1.51 + int error = 0; 1.52 + 1.53 + error = sysfs_create_group(&dev->dev.kobj, 1.54 + &vbdstat_group); 1.55 + if (error) 1.56 + goto fail; 1.57 + 1.58 + return 0; 1.59 + 1.60 +fail: 1.61 + sysfs_remove_group(&dev->dev.kobj, 1.62 + &vbdstat_group); 1.63 + return error; 1.64 +} 1.65 + 1.66 +void xenvbd_sysfs_delif(struct xenbus_device *dev) 1.67 +{ 1.68 + sysfs_remove_group(&dev->dev.kobj, 1.69 + &vbdstat_group); 1.70 +} 1.71 + 1.72 +#else 1.73 + 1.74 +#define xenvbd_sysfs_addif(dev) (0) 1.75 +#define xenvbd_sysfs_delif(dev) ((void)0) 1.76 + 1.77 +#endif /* CONFIG_SYSFS */ 1.78 + 1.79 static ssize_t show_physical_device(struct device *_dev, 1.80 struct device_attribute *attr, char *buf) 1.81 { 1.82 @@ -115,6 +178,7 @@ static int blkback_remove(struct xenbus_ 1.83 1.84 device_remove_file(&dev->dev, &dev_attr_physical_device); 1.85 device_remove_file(&dev->dev, &dev_attr_mode); 1.86 + xenvbd_sysfs_delif(dev); 1.87 1.88 kfree(be); 1.89 dev->dev.driver_data = NULL; 1.90 @@ -237,6 +301,7 @@ static void backend_changed(struct xenbu 1.91 1.92 device_create_file(&dev->dev, &dev_attr_physical_device); 1.93 device_create_file(&dev->dev, &dev_attr_mode); 1.94 + xenvbd_sysfs_addif(dev); 1.95 1.96 /* We're potentially connected now */ 1.97 update_blkif_status(be->blkif);