From 04f1983aab16d378be376768275856bc38be48bd Mon Sep 17 00:00:00 2001 From: Andriy Gapon Date: Thu, 27 Oct 2022 01:00:58 +0300 Subject: [PATCH] FreeBSD: vn_flush_cached_data: observe vnode locking contract vm_object_page_clean() expects that the associated vnode is locked as VOP_PUTPAGES() may get called on the vnode. Reviewed-by: Ryan Moeller Signed-off-by: Andriy Gapon Closes #14079 (cherry picked from commit 41133c97949af43daadee0503a9842a8dce8f0fd) --- include/os/freebsd/spl/sys/vnode.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/os/freebsd/spl/sys/vnode.h b/include/os/freebsd/spl/sys/vnode.h index bcfc177a47..b7ac12f3d6 100644 --- a/include/os/freebsd/spl/sys/vnode.h +++ b/include/os/freebsd/spl/sys/vnode.h @@ -95,9 +95,11 @@ vn_flush_cached_data(vnode_t *vp, boolean_t sync) if (vp->v_object->flags & OBJ_MIGHTBEDIRTY) { #endif int flags = sync ? OBJPC_SYNC : 0; + vn_lock(vp, LK_SHARED | LK_RETRY); zfs_vmobject_wlock(vp->v_object); vm_object_page_clean(vp->v_object, 0, 0, flags); zfs_vmobject_wunlock(vp->v_object); + VOP_UNLOCK(vp); } }