aboutsummaryrefslogtreecommitdiff
path: root/sys/fs/nfsclient/nfs_clbio.c
diff options
context:
space:
mode:
authorRick Macklem <rmacklem@FreeBSD.org>2021-12-15 16:35:48 +0000
committerRick Macklem <rmacklem@FreeBSD.org>2021-12-15 16:35:48 +0000
commit867c27c23a5c469b27611cf53cc2390b5a193fa5 (patch)
tree1e40a535f61b0aa4496a44ecf7e8a701cafe1d4e /sys/fs/nfsclient/nfs_clbio.c
parent7835925aa420ae3046b5f13899a0c208741d0ad4 (diff)
downloadsrc-867c27c23a5c469b27611cf53cc2390b5a193fa5.tar.gz
src-867c27c23a5c469b27611cf53cc2390b5a193fa5.zip
nfscl: Change IO_APPEND writes to direct I/O
IO_APPEND writes have always been very slow over NFS, due to the need to acquire an up to date file size after flushing all writes to the NFS server. This patch switches the IO_APPEND writes to use direct I/O, bypassing the buffer cache. As such, flushing of writes normally only occurs when the open(..O_APPEND..) is done. It does imply that all writes must be done synchronously and must be committed to stable storage on the file server (NFSWRITE_FILESYNC). For a simple test program that does 10,000 IO_APPEND writes in a loop, performance improved significantly with this patch. For a UFS exported file system, the test ran 12x faster. This drops to 3x faster when the open(2)/close(2) are done for each loop iteration. For a ZFS exported file system, the test ran 40% faster. The much smaller improvement may have been because the ZFS file system I tested against does not have a ZIL log and does have "sync" enabled. Note that IO_APPEND write performance is still much slower than when done on local file systems. Although this is a simple patch, it does result in a significant semantics change, so I have given it a large MFC time. Tested by: otis MFC after: 3 months
Diffstat (limited to 'sys/fs/nfsclient/nfs_clbio.c')
-rw-r--r--sys/fs/nfsclient/nfs_clbio.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/fs/nfsclient/nfs_clbio.c b/sys/fs/nfsclient/nfs_clbio.c
index 29bc66669dfb..c3339617acce 100644
--- a/sys/fs/nfsclient/nfs_clbio.c
+++ b/sys/fs/nfsclient/nfs_clbio.c
@@ -1001,8 +1001,12 @@ ncl_write(struct vop_write_args *ap)
if (uio->uio_resid == 0)
return (0);
- if (newnfs_directio_enable && (ioflag & IO_DIRECT) && vp->v_type == VREG)
+ if (vp->v_type == VREG && ((newnfs_directio_enable && (ioflag &
+ IO_DIRECT)) || (ioflag & IO_APPEND))) {
+ if ((ioflag & IO_APPEND) != 0)
+ ioflag |= IO_SYNC;
return nfs_directio_write(vp, uio, cred, ioflag);
+ }
/*
* Maybe this should be above the vnode op call, but so long as