Update zfs_freebsd_need_inactive to fix mmapped writes

`zfs_freebsd_need_inactive` appears to been based on an unfinished
version of https://reviews.freebsd.org/D22130 which had a bug where
files written via mmap wouldn't actually persist.

Update the function to match the final version committed to FreeBSD.

Authored-by: Mateusz Guzik <mjg@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #10527 
Closes #10528
This commit is contained in:
Ryan Moeller 2020-07-03 14:30:04 -04:00 committed by GitHub
parent 9a49d3f3d3
commit 8a3d9186ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5749,10 +5749,13 @@ zfs_freebsd_need_inactive(struct vop_need_inactive_args *ap)
vnode_t *vp = ap->a_vp;
znode_t *zp = VTOZ(vp);
zfsvfs_t *zfsvfs = zp->z_zfsvfs;
bool need;
int need;
if (vn_need_pageq_flush(vp))
return (1);
if (!rw_tryenter(&zfsvfs->z_teardown_inactive_lock, RW_READER))
return (true);
return (1);
need = (zp->z_sa_hdl == NULL || zp->z_unlinked || zp->z_atime_dirty);
rw_exit(&zfsvfs->z_teardown_inactive_lock);