aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortarangg@amazon.com <tarangg@amazon.com>2017-09-07 09:29:23 -0400
committerTrond Myklebust <trond.myklebust@primarydata.com>2017-09-07 11:07:13 -0400
commite973b1a5999e57da677ab50da5f5479fdc0f0c31 (patch)
treee6c6e1e64fd7149e6ba99f45ca01ee0e80e4847c
parent58a69893a9bf6833a79dae801da78e1d4f46f0a2 (diff)
NFS: Sync the correct byte range during synchronous writes
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> Cc: stable@vger.kernel.org # v4.8+ Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
-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 1d71472d239d..a385d1c3f146 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -631,11 +631,11 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct iov_iter *from)
631 if (result <= 0) 631 if (result <= 0)
632 goto out; 632 goto out;
633 633
634 result = generic_write_sync(iocb, result);
635 if (result < 0)
636 goto out;
637 written = result; 634 written = result;
638 iocb->ki_pos += written; 635 iocb->ki_pos += written;
636 result = generic_write_sync(iocb, written);
637 if (result < 0)
638 goto out;
639 639
640 /* Return error values */ 640 /* Return error values */
641 if (nfs_need_check_write(file, inode)) { 641 if (nfs_need_check_write(file, inode)) {