summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorRichard Yao <[email protected]>2015-09-07 12:03:19 -0400
committerBrian Behlendorf <[email protected]>2015-09-09 09:29:24 -0700
commit8198d18ca7e05ec30139e10d658a8b06c0ec4c55 (patch)
tree898e7d611c3a7b1575870c26a4b853cfcbed8e7e /module
parent1e17e910ea315c0c3f732a7e8d31229dbd1e6069 (diff)
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 <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #3741
Diffstat (limited to 'module')
-rw-r--r--module/zfs/zvol.c18
1 files changed, 13 insertions, 5 deletions
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