summaryrefslogtreecommitdiffstats
path: root/fs/nfs/file.c
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@primarydata.com>2015-08-17 17:55:18 -0400
committerTrond Myklebust <trond.myklebust@primarydata.com>2015-08-17 17:55:18 -0400
commit7e94d6c4ab69562423fdc18801050a84462c2787 (patch)
treec76fe5e25b9630866731414279b920e2763ca184 /fs/nfs/file.c
parent9fba8e30f704d49627ab8a4a57213862206b3e5f (diff)
NFS: Don't fsync twice for O_SYNC/IS_SYNC files
generic_file_write_iter() will already do an fsync on our behalf if the file descriptor is O_SYNC or the file is marked as IS_SYNC. Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'fs/nfs/file.c')
-rw-r--r--fs/nfs/file.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 7538a8582384..526a2681d975 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -645,12 +645,10 @@ static const struct vm_operations_struct nfs_file_vm_ops = {
645 .page_mkwrite = nfs_vm_page_mkwrite, 645 .page_mkwrite = nfs_vm_page_mkwrite,
646}; 646};
647 647
648static int nfs_need_sync_write(struct file *filp, struct inode *inode) 648static int nfs_need_check_write(struct file *filp, struct inode *inode)
649{ 649{
650 struct nfs_open_context *ctx; 650 struct nfs_open_context *ctx;
651 651
652 if (IS_SYNC(inode) || (filp->f_flags & O_DSYNC))
653 return 1;
654 ctx = nfs_file_open_context(filp); 652 ctx = nfs_file_open_context(filp);
655 if (test_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags) || 653 if (test_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags) ||
656 nfs_ctx_key_to_expire(ctx)) 654 nfs_ctx_key_to_expire(ctx))
@@ -700,8 +698,8 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct iov_iter *from)
700 if (result > 0) 698 if (result > 0)
701 written = result; 699 written = result;
702 700
703 /* Return error values for O_DSYNC and IS_SYNC() */ 701 /* Return error values */
704 if (result >= 0 && nfs_need_sync_write(file, inode)) { 702 if (result >= 0 && nfs_need_check_write(file, inode)) {
705 int err = vfs_fsync(file, 0); 703 int err = vfs_fsync(file, 0);
706 if (err < 0) 704 if (err < 0)
707 result = err; 705 result = err;