Skip to contentSkip to conversation

netfs: Fix barriering when walking subrequest list

PATCH Applied David Howells 3 participants 3 messages Jul 2 – Jul 3

Subsystems (2)
lore
Share & tools
lore

David Howells

author maintainer
#0 lore raw

PATCH 1/1 netfs: Fix barriering when walking subrequest list

Fix the barriering used when walking the subrequest list in retry as there's a possibility of seeing a subreq that's just been added by the application thread.

Fixes ee4cdf7ba857 ("netfs: Speed up buffered reading")
Fixes 288ace2f57c9 ("netfs: New writeback implementation")
cc Paulo Alcantara <[email protected]>
---
 fs/netfs/read_retry.c  |    7 ++++++-
 fs/netfs/write_retry.c |    7 ++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)
fs/netfs/read_retry.c +6 -1
index f59a70f3a086..2b42758e01ec 100644
@@ -98,7 +98,12 @@ static void netfs_retry_read_subrequests(struct netfs_io_request *rreq)
 			goto abandon;
 		}
 
-		list_for_each_continue(next, &stream->subrequests) {
+		for (;;) {
+			/* Read pointer to subreq before reading subreq state. */
+			next = smp_load_acquire(&next->next);
+			if (next == &stream->subrequests)
+				break;
+
 			subreq = list_entry(next, struct netfs_io_subrequest, rreq_link);
 			if (subreq->start + subreq->transferred != start + len ||
 			    test_bit(NETFS_SREQ_BOUNDARY, &subreq->flags) ||
fs/netfs/write_retry.c +6 -1
index 32735abfa03f..058bc7a166a5 100644
@@ -72,7 +72,12 @@ static void netfs_retry_write_stream(struct netfs_io_request *wreq,
 		    !test_bit(NETFS_SREQ_NEED_RETRY, &from->flags))
 			return;
 
-		list_for_each_continue(next, &stream->subrequests) {
+		for (;;) {
+			/* Read pointer to subreq before reading subreq state. */
+			next = smp_load_acquire(&next->next);
+			if (next == &stream->subrequests)
+				break;
+
 			subreq = list_entry(next, struct netfs_io_subrequest, rreq_link);
 			if (subreq->start + subreq->transferred != start + len ||
 			    test_bit(NETFS_SREQ_BOUNDARY, &subreq->flags) ||
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · David Howells

Fix the barriering used when walking the subrequest list in retry as there's a possibility of seeing a subreq that's just been added by the application thread.

Fixes ee4cdf7ba857 ("netfs: Speed up buffered reading")
Fixes 288ace2f57c9 ("netfs: New writeback implementation")
cc Paulo Alcantara <[email protected]>
Quoted 4 lines
---
 fs/netfs/read_retry.c  |    7 ++++++-
 fs/netfs/write_retry.c |    7 ++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)
maintainer Applied
#2 lore raw
In reply to David Howells
Quoted 1 line · David Howells

netfs: Fix barriering when walking subrequest list

Applied to the vfs.fixes branch of the vfs/vfs.git tree. Patches in the vfs.fixes branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.fixes

[1/1] netfs: Fix barriering when walking subrequest list

      https://git.kernel.org/vfs/vfs/c/5c6ce05e4065