]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
NFS: Don't fsync twice for O_SYNC/IS_SYNC files
authorTrond Myklebust <trond.myklebust@primarydata.com>
Mon, 17 Aug 2015 21:55:18 +0000 (16:55 -0500)
committerTrond Myklebust <trond.myklebust@primarydata.com>
Mon, 17 Aug 2015 21:55:18 +0000 (16:55 -0500)
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>
fs/nfs/file.c

index 7538a85823846df69123902dc8be1800c807af1c..526a2681d9750380c5ef8e8cc26698e381ca6e6d 100644 (file)
@@ -645,12 +645,10 @@ static const struct vm_operations_struct nfs_file_vm_ops = {
        .page_mkwrite = nfs_vm_page_mkwrite,
 };
 
-static int nfs_need_sync_write(struct file *filp, struct inode *inode)
+static int nfs_need_check_write(struct file *filp, struct inode *inode)
 {
        struct nfs_open_context *ctx;
 
-       if (IS_SYNC(inode) || (filp->f_flags & O_DSYNC))
-               return 1;
        ctx = nfs_file_open_context(filp);
        if (test_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags) ||
            nfs_ctx_key_to_expire(ctx))
@@ -700,8 +698,8 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct iov_iter *from)
        if (result > 0)
                written = result;
 
-       /* Return error values for O_DSYNC and IS_SYNC() */
-       if (result >= 0 && nfs_need_sync_write(file, inode)) {
+       /* Return error values */
+       if (result >= 0 && nfs_need_check_write(file, inode)) {
                int err = vfs_fsync(file, 0);
                if (err < 0)
                        result = err;