Skip to content

Commit f298e37

Browse files
dhowellsbrauner
authored andcommitted
netfs: Fix collection of results during pause when collection offloaded
A netfs read request can run in one of two modes: for synchronous reads writes, the app thread does the collection of results and for asynchronous reads, this is offloaded to a worker thread. This is controlled by the NETFS_RREQ_OFFLOAD_COLLECTION flag. Now, if a subrequest incurs an error, the NETFS_RREQ_PAUSE flag is set to stop the issuing loop temporarily from issuing more subrequests until a retry is successful or the request is abandoned. When the issuing loop sees NETFS_RREQ_PAUSE, it jumps to netfs_wait_for_pause() which will wait for the PAUSE flag to be cleared - and whilst it is waiting, it will call out to the collector as more results acrue... But this is the wrong thing to do if OFFLOAD_COLLECTION is set as we can then end up with both the app thread and the work item collecting results simultaneously. This manifests itself occasionally when running the generic/323 xfstest against multichannel cifs as an oops that's a bit random but frequently involving io_submit() (the test does lots of simultaneous async DIO reads). Fix this by only doing the collection in netfs_wait_for_pause() if the NETFS_RREQ_OFFLOAD_COLLECTION is not set. Fixes: e2d46f2 ("netfs: Change the read result collector to only use one work item") Reported-by: Steve French <stfrench@microsoft.com> Signed-off-by: David Howells <dhowells@redhat.com> Link: https://lore.kernel.org/r/20250314164201.1993231-2-dhowells@redhat.com Acked-by: "Paulo Alcantara (Red Hat)" <pc@manguebit.com> cc: Paulo Alcantara <pc@manguebit.com> cc: Jeff Layton <jlayton@kernel.org> cc: linux-cifs@vger.kernel.org cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent d9ecc77 commit f298e37

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

fs/netfs/read_collect.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -682,14 +682,16 @@ void netfs_wait_for_pause(struct netfs_io_request *rreq)
682682
trace_netfs_rreq(rreq, netfs_rreq_trace_wait_queue);
683683
prepare_to_wait(&rreq->waitq, &myself, TASK_UNINTERRUPTIBLE);
684684

685-
subreq = list_first_entry_or_null(&stream->subrequests,
686-
struct netfs_io_subrequest, rreq_link);
687-
if (subreq &&
688-
(!test_bit(NETFS_SREQ_IN_PROGRESS, &subreq->flags) ||
689-
test_bit(NETFS_SREQ_MADE_PROGRESS, &subreq->flags))) {
690-
__set_current_state(TASK_RUNNING);
691-
netfs_read_collection(rreq);
692-
continue;
685+
if (!test_bit(NETFS_RREQ_OFFLOAD_COLLECTION, &rreq->flags)) {
686+
subreq = list_first_entry_or_null(&stream->subrequests,
687+
struct netfs_io_subrequest, rreq_link);
688+
if (subreq &&
689+
(!test_bit(NETFS_SREQ_IN_PROGRESS, &subreq->flags) ||
690+
test_bit(NETFS_SREQ_MADE_PROGRESS, &subreq->flags))) {
691+
__set_current_state(TASK_RUNNING);
692+
netfs_read_collection(rreq);
693+
continue;
694+
}
693695
}
694696

695697
if (!test_bit(NETFS_RREQ_IN_PROGRESS, &rreq->flags) ||

0 commit comments

Comments
 (0)