diff --git a/sys/fs/nfsclient/nfs_clbio.c b/sys/fs/nfsclient/nfs_clbio.c index c3339617acce..06b51c050d34 100644 --- a/sys/fs/nfsclient/nfs_clbio.c +++ b/sys/fs/nfsclient/nfs_clbio.c @@ -1001,12 +1001,24 @@ ncl_write(struct vop_write_args *ap) if (uio->uio_resid == 0) return (0); + /* + * If the file in not mmap()'d, do IO_APPEND writing via a + * synchronous direct write. This can result in a significant + * performance improvement. + * If the file is mmap()'d, this cannot be done, since there + * is no way to maintain consistency between the file on the + * NFS server and the file's mmap()'d pages. + */ + NFSLOCKNODE(np); if (vp->v_type == VREG && ((newnfs_directio_enable && (ioflag & - IO_DIRECT)) || (ioflag & IO_APPEND))) { + IO_DIRECT)) || ((ioflag & IO_APPEND) && + (vp->v_object == NULL || !vm_object_is_active(vp->v_object))))) { + NFSUNLOCKNODE(np); if ((ioflag & IO_APPEND) != 0) ioflag |= IO_SYNC; return nfs_directio_write(vp, uio, cred, ioflag); } + NFSUNLOCKNODE(np); /* * Maybe this should be above the vnode op call, but so long as