]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
zram: use generic start/end io accounting
authorSergey Senozhatsky <sergey.senozhatsky@gmail.com>
Tue, 7 Apr 2015 23:44:48 +0000 (09:44 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 7 Apr 2015 23:44:48 +0000 (09:44 +1000)
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>
drivers/block/zram/zram_drv.c

index 2d5848a83bf30e5027f38f05031bce224fffd524..6adccdfd6e078acf09e916a62ceb4ab03b629c7d 100644 (file)
@@ -743,8 +743,12 @@ static void zram_bio_discard(struct zram *zram, u32 index,
 static int zram_bvec_rw(struct zram *zram, struct bio_vec *bvec, u32 index,
                        int offset, int rw)
 {
+       unsigned long start_time = jiffies;
        int ret;
 
+       generic_start_io_acct(rw, bvec->bv_len >> SECTOR_SHIFT,
+                       &zram->disk->part0);
+
        if (rw == READ) {
                atomic64_inc(&zram->stats.num_reads);
                ret = zram_bvec_read(zram, bvec, index, offset);
@@ -753,6 +757,8 @@ static int zram_bvec_rw(struct zram *zram, struct bio_vec *bvec, u32 index,
                ret = zram_bvec_write(zram, bvec, index, offset);
        }
 
+       generic_end_io_acct(rw, &zram->disk->part0, start_time);
+
        if (unlikely(ret)) {
                if (rw == READ)
                        atomic64_inc(&zram->stats.failed_reads);