Skip to contentSkip to conversation

Patch "NFS: Sync the correct byte range during synchronous writes" has been added to the 4.12-stable tree

PATCH [email protected] 1 participant 1 message Sep 12, 2017

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

NFS: Sync the correct byte range during synchronous writes

to the 4.12-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
nfs-sync-the-correct-byte-range-during-synchronous-writes.patch
and it can be found in the queue-4.12 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From e973b1a5999e57da677ab50da5f5479fdc0f0c31 Mon Sep 17 00:00:00 2001

From: "[email protected]" <[email protected]>
Date: Thu, 7 Sep 2017 09:29:23 -0400
Subject: NFS: Sync the correct byte range during synchronous writes

From: [email protected] <[email protected]>

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()")
---
 fs/nfs/file.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
fs/nfs/file.c +3 -3
@@ -629,11 +629,11 @@ ssize_t nfs_file_write(struct kiocb *ioc
 	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)) {

Patches currently in stable-queue which might be from [email protected] are

queue-4.12/nfs-sync-the-correct-byte-range-during-synchronous-writes.patch