Skip to content

Commit

Permalink
Add dataset_kstats_update.. to mmap read/write paths
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Ryan Moeller <[email protected]>
Signed-off-by: Matthias Blankertz <[email protected]>
Closes #12994 
Closes #13044
  • Loading branch information
drowfx authored Feb 9, 2022
1 parent 68ddc06 commit 3819aaa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions module/os/freebsd/zfs/zfs_vnops_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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]);
}
Expand Down
4 changes: 4 additions & 0 deletions module/os/linux/zfs/zfs_vnops_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 3819aaa

Please sign in to comment.