From c71a2bb52fd3ec4db44890e05c071b137ec420b3 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Wed, 26 May 2021 14:14:26 -0400 Subject: [PATCH] FreeBSD: Update dataset_kstats for zvols in dev mode Previous commit added accounting for geom mode, but not for dev. In geom mode we actually have GEOM statistics, while in dev mode additional accounting actually makes more sense. Reviewed-by: Brian Behlendorf Reviewed-by: Ryan Moeller Signed-off-by: Alexander Motin Closes #12097 --- module/os/freebsd/zfs/zvol_os.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/module/os/freebsd/zfs/zvol_os.c b/module/os/freebsd/zfs/zvol_os.c index 1993ca5630..34aad72fbb 100644 --- a/module/os/freebsd/zfs/zvol_os.c +++ b/module/os/freebsd/zfs/zvol_os.c @@ -767,6 +767,7 @@ zvol_cdev_read(struct cdev *dev, struct uio *uio_s, int ioflag) (zfs_uio_offset(&uio) < 0 || zfs_uio_offset(&uio) > volsize)) return (SET_ERROR(EIO)); + ssize_t start_resid = zfs_uio_resid(&uio); lr = zfs_rangelock_enter(&zv->zv_rangelock, zfs_uio_offset(&uio), zfs_uio_resid(&uio), RL_READER); while (zfs_uio_resid(&uio) > 0 && zfs_uio_offset(&uio) < volsize) { @@ -785,6 +786,8 @@ zvol_cdev_read(struct cdev *dev, struct uio *uio_s, int ioflag) } } zfs_rangelock_exit(lr); + int64_t nread = start_resid - zfs_uio_resid(&uio); + dataset_kstats_update_read_kstats(&zv->zv_kstat, nread); return (error); } @@ -809,6 +812,7 @@ zvol_cdev_write(struct cdev *dev, struct uio *uio_s, int ioflag) (zfs_uio_offset(&uio) < 0 || zfs_uio_offset(&uio) > volsize)) return (SET_ERROR(EIO)); + ssize_t start_resid = zfs_uio_resid(&uio); sync = (ioflag & IO_SYNC) || (zv->zv_objset->os_sync == ZFS_SYNC_ALWAYS); @@ -840,6 +844,8 @@ zvol_cdev_write(struct cdev *dev, struct uio *uio_s, int ioflag) break; } zfs_rangelock_exit(lr); + int64_t nwritten = start_resid - zfs_uio_resid(&uio); + dataset_kstats_update_write_kstats(&zv->zv_kstat, nwritten); if (sync) zil_commit(zv->zv_zilog, ZVOL_OBJ); rw_exit(&zv->zv_suspend_lock);