aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Senozhatsky <sergey.senozhatsky@gmail.com>2015-04-15 19:15:57 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-04-15 19:35:21 -0400
commit8811a9421b325b06a2456ae1b8fe23e838cbfe33 (patch)
tree892c5226ea92e00dffe24cd4bcb128ce5f7d9c50
parentc72c6160d967ed26a0b136dbab337f821d233509 (diff)
zram: use generic start/end io accounting
Use bio generic_start_io_acct() and generic_end_io_acct() to account device's block layer statistics. This will let users to monitor zram activities using sysstat and similar packages/tools. Apart from the usual per-stat sysfs attr, zram IO stats are now also available in '/sys/block/zram<id>/stat' and '/proc/diskstats' files. We will slowly get rid of per-stat sysfs files. Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Acked-by: Minchan Kim <minchan@kernel.org> Cc: Nitin Gupta <ngupta@vflare.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/block/zram/zram_drv.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 871bd3550cb0..35dafd9a0350 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -670,8 +670,12 @@ out:
670static int zram_bvec_rw(struct zram *zram, struct bio_vec *bvec, u32 index, 670static int zram_bvec_rw(struct zram *zram, struct bio_vec *bvec, u32 index,
671 int offset, int rw) 671 int offset, int rw)
672{ 672{
673 unsigned long start_time = jiffies;
673 int ret; 674 int ret;
674 675
676 generic_start_io_acct(rw, bvec->bv_len >> SECTOR_SHIFT,
677 &zram->disk->part0);
678
675 if (rw == READ) { 679 if (rw == READ) {
676 atomic64_inc(&zram->stats.num_reads); 680 atomic64_inc(&zram->stats.num_reads);
677 ret = zram_bvec_read(zram, bvec, index, offset); 681 ret = zram_bvec_read(zram, bvec, index, offset);
@@ -680,6 +684,8 @@ static int zram_bvec_rw(struct zram *zram, struct bio_vec *bvec, u32 index,
680 ret = zram_bvec_write(zram, bvec, index, offset); 684 ret = zram_bvec_write(zram, bvec, index, offset);
681 } 685 }
682 686
687 generic_end_io_acct(rw, &zram->disk->part0, start_time);
688
683 if (unlikely(ret)) { 689 if (unlikely(ret)) {
684 if (rw == READ) 690 if (rw == READ)
685 atomic64_inc(&zram->stats.failed_reads); 691 atomic64_inc(&zram->stats.failed_reads);