diff options
author | Brian Behlendorf <[email protected]> | 2020-12-22 12:17:13 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2020-12-27 16:20:24 -0800 |
commit | a970f0594e9f67363dece8e0ed066e3eb7725bb4 (patch) | |
tree | 4c4c9df0627b2f4dbcb09e819ce02d5313d06d05 /module/os | |
parent | b7281c88bcbba0525e8b55607145956320d103f0 (diff) |
Linux 5.11 compat: bio_start_io_acct() / bio_end_io_acct()
The generic IO accounting functions have been removed in favor of the
bio_start_io_acct() and bio_end_io_acct() functions which provide a
better interface. These new functions were introduced in the 5.8
kernels but it wasn't until the 5.11 kernel that the previous generic
IO accounting interfaces were removed.
This commit updates the blk_generic_*_io_acct() wrappers to provide
and interface similar to the updated kernel interface. It's slightly
different because for older kernels we need to pass the request queue
as well as the bio.
Reviewed-by: Rafael Kitover <[email protected]>
Reviewed-by: Coleman Kane <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #11387
Closes #11390
Diffstat (limited to 'module/os')
-rw-r--r-- | module/os/linux/zfs/zvol_os.c | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/module/os/linux/zfs/zvol_os.c b/module/os/linux/zfs/zvol_os.c index 29ad67368..9a9a721ce 100644 --- a/module/os/linux/zfs/zvol_os.c +++ b/module/os/linux/zfs/zvol_os.c @@ -106,10 +106,14 @@ zvol_write(void *arg) return; } + struct request_queue *q = zv->zv_zso->zvo_queue; + struct gendisk *disk = zv->zv_zso->zvo_disk; ssize_t start_resid = uio.uio_resid; - unsigned long start_jif = jiffies; - blk_generic_start_io_acct(zv->zv_zso->zvo_queue, WRITE, - bio_sectors(bio), &zv->zv_zso->zvo_disk->part0); + unsigned long start_time; + + boolean_t acct = blk_queue_io_stat(q); + if (acct) + start_time = blk_generic_start_io_acct(q, disk, WRITE, bio); boolean_t sync = bio_is_fua(bio) || zv->zv_objset->os_sync == ZFS_SYNC_ALWAYS; @@ -153,8 +157,10 @@ zvol_write(void *arg) zil_commit(zv->zv_zilog, ZVOL_OBJ); rw_exit(&zv->zv_suspend_lock); - blk_generic_end_io_acct(zv->zv_zso->zvo_queue, - WRITE, &zv->zv_zso->zvo_disk->part0, start_jif); + + if (acct) + blk_generic_end_io_acct(q, disk, WRITE, bio, start_time); + BIO_END_IO(bio, -error); kmem_free(zvr, sizeof (zv_request_t)); } @@ -171,15 +177,18 @@ zvol_discard(void *arg) boolean_t sync; int error = 0; dmu_tx_t *tx; - unsigned long start_jif; ASSERT3P(zv, !=, NULL); ASSERT3U(zv->zv_open_count, >, 0); ASSERT3P(zv->zv_zilog, !=, NULL); - start_jif = jiffies; - blk_generic_start_io_acct(zv->zv_zso->zvo_queue, WRITE, - bio_sectors(bio), &zv->zv_zso->zvo_disk->part0); + struct request_queue *q = zv->zv_zso->zvo_queue; + struct gendisk *disk = zv->zv_zso->zvo_disk; + unsigned long start_time; + + boolean_t acct = blk_queue_io_stat(q); + if (acct) + start_time = blk_generic_start_io_acct(q, disk, WRITE, bio); sync = bio_is_fua(bio) || zv->zv_objset->os_sync == ZFS_SYNC_ALWAYS; @@ -224,8 +233,10 @@ zvol_discard(void *arg) unlock: rw_exit(&zv->zv_suspend_lock); - blk_generic_end_io_acct(zv->zv_zso->zvo_queue, WRITE, - &zv->zv_zso->zvo_disk->part0, start_jif); + + if (acct) + blk_generic_end_io_acct(q, disk, WRITE, bio, start_time); + BIO_END_IO(bio, -error); kmem_free(zvr, sizeof (zv_request_t)); } @@ -244,10 +255,14 @@ zvol_read(void *arg) ASSERT3P(zv, !=, NULL); ASSERT3U(zv->zv_open_count, >, 0); + struct request_queue *q = zv->zv_zso->zvo_queue; + struct gendisk *disk = zv->zv_zso->zvo_disk; ssize_t start_resid = uio.uio_resid; - unsigned long start_jif = jiffies; - blk_generic_start_io_acct(zv->zv_zso->zvo_queue, READ, bio_sectors(bio), - &zv->zv_zso->zvo_disk->part0); + unsigned long start_time; + + boolean_t acct = blk_queue_io_stat(q); + if (acct) + start_time = blk_generic_start_io_acct(q, disk, READ, bio); zfs_locked_range_t *lr = zfs_rangelock_enter(&zv->zv_rangelock, uio.uio_loffset, uio.uio_resid, RL_READER); @@ -275,8 +290,10 @@ zvol_read(void *arg) task_io_account_read(nread); rw_exit(&zv->zv_suspend_lock); - blk_generic_end_io_acct(zv->zv_zso->zvo_queue, READ, - &zv->zv_zso->zvo_disk->part0, start_jif); + + if (acct) + blk_generic_end_io_acct(q, disk, READ, bio, start_time); + BIO_END_IO(bio, -error); kmem_free(zvr, sizeof (zv_request_t)); } |