Commit 0c6f0e79 authored by ecashin@coraid.com's avatar ecashin@coraid.com Committed by Greg KH

[PATCH] aoe 11/12: add support for disk statistics

add support for disk statistics
Signed-off-by: default avatarEd L. Cashin <ecashin@coraid.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent e3b7df65
...@@ -90,6 +90,7 @@ enum { ...@@ -90,6 +90,7 @@ enum {
struct buf { struct buf {
struct list_head bufs; struct list_head bufs;
ulong start_time; /* for disk stats */
ulong flags; ulong flags;
ulong nframesout; ulong nframesout;
char *bufaddr; char *bufaddr;
......
...@@ -125,6 +125,7 @@ aoeblk_make_request(request_queue_t *q, struct bio *bio) ...@@ -125,6 +125,7 @@ aoeblk_make_request(request_queue_t *q, struct bio *bio)
} }
memset(buf, 0, sizeof(*buf)); memset(buf, 0, sizeof(*buf));
INIT_LIST_HEAD(&buf->bufs); INIT_LIST_HEAD(&buf->bufs);
buf->start_time = jiffies;
buf->bio = bio; buf->bio = bio;
buf->resid = bio->bi_size; buf->resid = bio->bi_size;
buf->sector = bio->bi_sector; buf->sector = bio->bi_sector;
......
...@@ -456,6 +456,20 @@ aoecmd_ata_rsp(struct sk_buff *skb) ...@@ -456,6 +456,20 @@ aoecmd_ata_rsp(struct sk_buff *skb)
if (buf) { if (buf) {
buf->nframesout -= 1; buf->nframesout -= 1;
if (buf->nframesout == 0 && buf->resid == 0) { if (buf->nframesout == 0 && buf->resid == 0) {
unsigned long duration = jiffies - buf->start_time;
unsigned long n_sect = buf->bio->bi_size >> 9;
struct gendisk *disk = d->gd;
if (bio_data_dir(buf->bio) == WRITE) {
disk_stat_inc(disk, writes);
disk_stat_add(disk, write_ticks, duration);
disk_stat_add(disk, write_sectors, n_sect);
} else {
disk_stat_inc(disk, reads);
disk_stat_add(disk, read_ticks, duration);
disk_stat_add(disk, read_sectors, n_sect);
}
disk_stat_add(disk, io_ticks, duration);
n = (buf->flags & BUFFL_FAIL) ? -EIO : 0; n = (buf->flags & BUFFL_FAIL) ? -EIO : 0;
bio_endio(buf->bio, buf->bio->bi_size, n); bio_endio(buf->bio, buf->bio->bi_size, n);
mempool_free(buf, d->bufpool); mempool_free(buf, d->bufpool);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment