From: ecashin@coraid.com Date: Tue, 19 Apr 2005 05:00:22 +0000 (-0700) Subject: [PATCH] aoe 11/12: add support for disk statistics X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=0c6f0e7920f39b28bdbe5f134f3e592542332d87;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git [PATCH] aoe 11/12: add support for disk statistics add support for disk statistics Signed-off-by: Ed L. Cashin Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/block/aoe/aoe.h b/drivers/block/aoe/aoe.h index d3b0e2ca151a..2e92cfb4997c 100644 --- a/drivers/block/aoe/aoe.h +++ b/drivers/block/aoe/aoe.h @@ -90,6 +90,7 @@ enum { struct buf { struct list_head bufs; + ulong start_time; /* for disk stats */ ulong flags; ulong nframesout; char *bufaddr; diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c index 63561b280bc5..a2735d975846 100644 --- a/drivers/block/aoe/aoeblk.c +++ b/drivers/block/aoe/aoeblk.c @@ -125,6 +125,7 @@ aoeblk_make_request(request_queue_t *q, struct bio *bio) } memset(buf, 0, sizeof(*buf)); INIT_LIST_HEAD(&buf->bufs); + buf->start_time = jiffies; buf->bio = bio; buf->resid = bio->bi_size; buf->sector = bio->bi_sector; diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c index f810bd6bf87f..60beb8db4612 100644 --- a/drivers/block/aoe/aoecmd.c +++ b/drivers/block/aoe/aoecmd.c @@ -456,6 +456,20 @@ aoecmd_ata_rsp(struct sk_buff *skb) if (buf) { buf->nframesout -= 1; 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; bio_endio(buf->bio, buf->bio->bi_size, n); mempool_free(buf, d->bufpool);