Skip to contentSkip to conversation

Patch "cifs: Fix setting of zero_point after DIO write" has been added to the 6.10-stable tree

PATCH [email protected] 1 participant 1 message Jul 23, 2024

Subsystems (2)
lore
Share & tools
lore

[email protected]

author Applied
#0 lore raw

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

cifs: Fix setting of zero_point after DIO write

to the 6.10-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:
cifs-fix-setting-of-zero_point-after-dio-write.patch
and it can be found in the queue-6.10 subdirectory.

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

From 61ea6b3a3104fcd66364282391dd2152bc4c129a Mon Sep 17 00:00:00 2001
From: David Howells <[email protected]>
Date: Fri, 19 Jul 2024 14:07:07 +0100
Subject: cifs: Fix setting of zero_point after DIO write

From: David Howells <[email protected]>

commit 61ea6b3a3104fcd66364282391dd2152bc4c129a upstream.

At the moment, at the end of a DIO write, cifs calls netfs_resize_file() to adjust the size of the file if it needs it. This will reduce the zero_point (the point above which we assume a read will just return zeros) if it's more than the new i_size, but won't increase it.

With DIO writes, however, we definitely want to increase it as we have clobbered the local pagecache and then written some data that's not available locally.

Fix cifs to make the zero_point above the end of a DIO or unbuffered write.

This fixes corruption seen occasionally with the generic/708 xfs-test. In that case, the read-back of some of the written data is being short-circuited and replaced with zeroes.

---
 fs/smb/client/file.c |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
fs/smb/client/file.c +9 -4
@@ -2364,13 +2364,18 @@ void cifs_write_subrequest_terminated(st
 				      bool was_async)
 {
 	struct netfs_io_request *wreq = wdata->rreq;
-	loff_t new_server_eof;
+	struct netfs_inode *ictx = netfs_inode(wreq->inode);
+	loff_t wrend;
 
 	if (result > 0) {
-		new_server_eof = wdata->subreq.start + wdata->subreq.transferred + result;
+		wrend = wdata->subreq.start + wdata->subreq.transferred + result;
 
-		if (new_server_eof > netfs_inode(wreq->inode)->remote_i_size)
-			netfs_resize_file(netfs_inode(wreq->inode), new_server_eof, true);
+		if (wrend > ictx->zero_point &&
+		    (wdata->rreq->origin == NETFS_UNBUFFERED_WRITE ||
+		     wdata->rreq->origin == NETFS_DIO_WRITE))
+			ictx->zero_point = wrend;
+		if (wrend > ictx->remote_i_size)
+			netfs_resize_file(ictx, wrend, true);
 	}
 
 	netfs_write_subrequest_terminated(&wdata->subreq, result, was_async);

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

queue-6.10/cifs-fix-server-re-repick-on-subrequest-retry.patch queue-6.10/cifs-fix-setting-of-zero_point-after-dio-write.patch queue-6.10/cifs-fix-missing-error-code-set.patch queue-6.10/cifs-fix-missing-fscache-invalidation.patch