From 3819aaaff921733a58e091b37b5e87b740356542 Mon Sep 17 00:00:00 2001 From: drowfx Date: Wed, 9 Feb 2022 23:41:42 +0100 Subject: [PATCH] Add dataset_kstats_update.. to mmap read/write paths This allows reads/writes caused by accesses to mmap files to be accounted correctly in the per-dataset kstats for both Linux and FreeBSD. Reviewed-by: Brian Behlendorf Reviewed-by: Ryan Moeller Signed-off-by: Matthias Blankertz Closes #12994 Closes #13044 --- module/os/freebsd/zfs/zfs_vnops_os.c | 6 ++++++ module/os/linux/zfs/zfs_vnops_os.c | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/module/os/freebsd/zfs/zfs_vnops_os.c b/module/os/freebsd/zfs/zfs_vnops_os.c index 90314f7df4fa..e2f52029d9cd 100644 --- a/module/os/freebsd/zfs/zfs_vnops_os.c +++ b/module/os/freebsd/zfs/zfs_vnops_os.c @@ -4129,6 +4129,9 @@ zfs_getpages(struct vnode *vp, vm_page_t *ma, int count, int *rbehind, if (lr != NULL) zfs_rangelock_exit(lr); ZFS_ACCESSTIME_STAMP(zfsvfs, zp); + + dataset_kstats_update_read_kstats(&zfsvfs->z_kstat, count*PAGE_SIZE); + ZFS_EXIT(zfsvfs); if (error != 0) @@ -4306,6 +4309,9 @@ zfs_putpages(struct vnode *vp, vm_page_t *ma, size_t len, int flags, if ((flags & (zfs_vm_pagerput_sync | zfs_vm_pagerput_inval)) != 0 || zfsvfs->z_os->os_sync == ZFS_SYNC_ALWAYS) zil_commit(zfsvfs->z_log, zp->z_id); + + dataset_kstats_update_write_kstats(&zfsvfs->z_kstat, len); + ZFS_EXIT(zfsvfs); return (rtvals[0]); } diff --git a/module/os/linux/zfs/zfs_vnops_os.c b/module/os/linux/zfs/zfs_vnops_os.c index c6115b530ff5..3cc0e69cc4b5 100644 --- a/module/os/linux/zfs/zfs_vnops_os.c +++ b/module/os/linux/zfs/zfs_vnops_os.c @@ -3610,6 +3610,8 @@ zfs_putpage(struct inode *ip, struct page *pp, struct writeback_control *wbc) zil_commit(zfsvfs->z_log, zp->z_id); } + dataset_kstats_update_write_kstats(&zfsvfs->z_kstat, pglen); + ZFS_EXIT(zfsvfs); return (err); } @@ -3805,6 +3807,8 @@ zfs_getpage(struct inode *ip, struct page *pl[], int nr_pages) err = zfs_fillpage(ip, pl, nr_pages); + dataset_kstats_update_read_kstats(&zfsvfs->z_kstat, nr_pages*PAGESIZE); + ZFS_EXIT(zfsvfs); return (err); }