diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -5897,6 +5897,8 @@ static void vop_fsync_debugprepost(struct vnode *vp, const char *name) { + struct mount *mp; + if (vp->v_type == VCHR) ; /* @@ -5914,10 +5916,16 @@ * should still be caught when the stacked filesystem * invokes VOP_FSYNC() on the underlying filesystem. */ - else if (MNT_SHARED_WRITES(vp->v_mount)) - ASSERT_VOP_LOCKED(vp, name); - else - ASSERT_VOP_ELOCKED(vp, name); + else { + mp = NULL; + VOP_GETWRITEMOUNT(vp, &mp); + if (vn_lktype_write(mp, vp) == LK_SHARED) + ASSERT_VOP_LOCKED(vp, name); + else + ASSERT_VOP_ELOCKED(vp, name); + if (mp != NULL) + vfs_rel(mp); + } } void