summaryrefslogtreecommitdiff
path: root/fs/nfs
diff options
context:
space:
mode:
authortarangg@amazon.com <tarangg@amazon.com>2017-09-07 09:29:23 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-09-13 14:13:37 -0700
commit3885bc68ae143c9d69eec76066049bf33a89a9d6 (patch)
tree3ead65fcacf6696832926383d3b4ec72fe1eda91 /fs/nfs
parenta70912a6bfff1289a2461e6b99a97f462fd14756 (diff)
NFS: Sync the correct byte range during synchronous writes
commit e973b1a5999e57da677ab50da5f5479fdc0f0c31 upstream. Since commit 18290650b1c8 ("NFS: Move buffered I/O locking into nfs_file_write()") nfs_file_write() has not flushed the correct byte range during synchronous writes. generic_write_sync() expects that iocb->ki_pos points to the right edge of the range rather than the left edge. To replicate the problem, open a file with O_DSYNC, have the client write at increasing offsets, and then print the successful offsets. Block port 2049 partway through that sequence, and observe that the client application indicates successful writes in advance of what the server received. Fixes: 18290650b1c8 ("NFS: Move buffered I/O locking into nfs_file_write()") Signed-off-by: Jacob Strauss <jsstraus@amazon.com> Signed-off-by: Tarang Gupta <tarangg@amazon.com> Tested-by: Tarang Gupta <tarangg@amazon.com> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/file.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 84c1cb9237d0..1eec947c562d 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -636,11 +636,11 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct iov_iter *from)
if (result <= 0)
goto out;
- result = generic_write_sync(iocb, result);
- if (result < 0)
- goto out;
written = result;
iocb->ki_pos += written;
+ result = generic_write_sync(iocb, written);
+ if (result < 0)
+ goto out;
/* Return error values */
if (nfs_need_check_write(file, inode)) {