Index: sys/kern/vfs_subr.c =================================================================== --- sys/kern/vfs_subr.c +++ sys/kern/vfs_subr.c @@ -3098,6 +3098,7 @@ vflush(struct mount *mp, int rootrefs, int flags, struct thread *td) { struct vnode *vp, *mvp, *rootvp = NULL; + struct vm_object *obj; struct vattr vattr; int busy = 0, error; @@ -3140,10 +3141,12 @@ * vnodes open for writing. */ if (flags & WRITECLOSE) { - if (vp->v_object != NULL) { - VM_OBJECT_WLOCK(vp->v_object); - vm_object_page_clean(vp->v_object, 0, 0, 0); - VM_OBJECT_WUNLOCK(vp->v_object); + obj = vp->v_object; + if (obj != NULL && + (obj->flags & OBJ_MIGHTBEDIRTY) != 0) { + VM_OBJECT_WLOCK(obj); + vm_object_page_clean(obj, 0, 0, 0); + VM_OBJECT_WUNLOCK(obj); } error = VOP_FSYNC(vp, MNT_WAIT, td); if (error != 0) {