mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
Reintroduce IO accounting on zvols on Linux 3.19+
zfsonlinux/zfs@e20cd6f7a8 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@394ffa503b 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 <ryao@gentoo.org> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #3741
This commit is contained in:
committed by
Brian Behlendorf
parent
1e17e910ea
commit
8198d18ca7
+13
-5
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user