From 8198d18ca7e05ec30139e10d658a8b06c0ec4c55 Mon Sep 17 00:00:00 2001 From: Richard Yao Date: Mon, 7 Sep 2015 12:03:19 -0400 Subject: Reintroduce IO accounting on zvols on Linux 3.19+ zfsonlinux/zfs@e20cd6f7a8922709b1aa2ecefd783390102d79e0 caused us to lose IO accounting on zvols. When I originally wrote that last year, the symbols we needed to maintain IO accounting were GPL exported, but torvalds/linux@394ffa503bc40e32d7f54a9b817264e81ce131b4 provided suitable symbols for restoring this functionality 4 months later. We can call them to restore the IO accounting on Linux 3.19 and later as well as any older kernels where that patch is backported. Signed-off-by: Richard Yao Signed-off-by: Brian Behlendorf Closes #3741 --- module/zfs/zvol.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'module/zfs/zvol.c') diff --git a/module/zfs/zvol.c b/module/zfs/zvol.c index 492f8ff87..7c1f024ca 100644 --- a/module/zfs/zvol.c +++ b/module/zfs/zvol.c @@ -713,6 +713,10 @@ zvol_request(struct request_queue *q, struct bio *bio) fstrans_cookie_t cookie = spl_fstrans_mark(); uint64_t offset = BIO_BI_SECTOR(bio); unsigned int sectors = bio_sectors(bio); + int rw = bio_data_dir(bio); +#ifdef HAVE_GENERIC_IO_ACCT + unsigned long start = jiffies; +#endif int error = 0; if (bio_has_data(bio) && offset + sectors > @@ -723,25 +727,29 @@ zvol_request(struct request_queue *q, struct bio *bio) (long long unsigned)offset, (long unsigned)sectors); error = SET_ERROR(EIO); - goto out; + goto out1; } - if (bio_data_dir(bio) == WRITE) { + generic_start_io_acct(rw, sectors, &zv->zv_disk->part0); + + if (rw == WRITE) { if (unlikely(zv->zv_flags & ZVOL_RDONLY)) { error = SET_ERROR(EROFS); - goto out; + goto out2; } if (bio->bi_rw & VDEV_REQ_DISCARD) { error = zvol_discard(bio); - goto out; + goto out2; } error = zvol_write(bio); } else error = zvol_read(bio); -out: +out2: + generic_end_io_acct(rw, &zv->zv_disk->part0, start); +out1: bio_endio(bio, -error); spl_fstrans_unmark(cookie); #ifdef HAVE_MAKE_REQUEST_FN_RET_INT -- cgit v1.2.3