Unverified Commit 0e764b9d authored by David Howells's avatar David Howells Committed by Christian Brauner
Browse files

netfs: Fix the handling of stream->front by removing it



The netfs_io_stream::front member is meant to point to the subrequest
currently being collected on a stream, but it isn't actually used this way
by direct write (which mostly ignores it).  However, there's a tracepoint
which looks at it.  Further, stream->front is actually redundant with
stream->subrequests.next.

Fix the potential problem in the direct code by just removing the member
and using stream->subrequests.next instead, thereby also simplifying the
code.

Fixes: a0b4c7a4 ("netfs: Fix unbuffered/DIO writes to dispatch subrequests in strict sequence")
Reported-by: default avatarPaulo Alcantara <pc@manguebit.org>
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Link: https://patch.msgid.link/4158599.1774426817@warthog.procyon.org.uk


Reviewed-by: default avatarPaulo Alcantara (Red Hat) <pc@manguebit.org>
cc: netfs@lists.linux.dev
cc: linux-fsdevel@vger.kernel.org
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent f621324d
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -171,9 +171,8 @@ static void netfs_queue_read(struct netfs_io_request *rreq,
	spin_lock(&rreq->lock);
	list_add_tail(&subreq->rreq_link, &stream->subrequests);
	if (list_is_first(&subreq->rreq_link, &stream->subrequests)) {
		stream->front = subreq;
		if (!stream->active) {
			stream->collected_to = stream->front->start;
			stream->collected_to = subreq->start;
			/* Store list pointers before active flag */
			smp_store_release(&stream->active, true);
		}
+1 −2
Original line number Diff line number Diff line
@@ -71,9 +71,8 @@ static int netfs_dispatch_unbuffered_reads(struct netfs_io_request *rreq)
		spin_lock(&rreq->lock);
		list_add_tail(&subreq->rreq_link, &stream->subrequests);
		if (list_is_first(&subreq->rreq_link, &stream->subrequests)) {
			stream->front = subreq;
			if (!stream->active) {
				stream->collected_to = stream->front->start;
				stream->collected_to = subreq->start;
				/* Store list pointers before active flag */
				smp_store_release(&stream->active, true);
			}
+0 −1
Original line number Diff line number Diff line
@@ -111,7 +111,6 @@ static int netfs_unbuffered_write(struct netfs_io_request *wreq)
			netfs_prepare_write(wreq, stream, wreq->start + wreq->transferred);
			subreq = stream->construct;
			stream->construct = NULL;
			stream->front = NULL;
		}

		/* Check if (re-)preparation failed. */
+2 −2
Original line number Diff line number Diff line
@@ -205,7 +205,8 @@ static void netfs_collect_read_results(struct netfs_io_request *rreq)
	 * in progress.  The issuer thread may be adding stuff to the tail
	 * whilst we're doing this.
	 */
	front = READ_ONCE(stream->front);
	front = list_first_entry_or_null(&stream->subrequests,
					 struct netfs_io_subrequest, rreq_link);
	while (front) {
		size_t transferred;

@@ -301,7 +302,6 @@ static void netfs_collect_read_results(struct netfs_io_request *rreq)
		list_del_init(&front->rreq_link);
		front = list_first_entry_or_null(&stream->subrequests,
						 struct netfs_io_subrequest, rreq_link);
		stream->front = front;
		spin_unlock(&rreq->lock);
		netfs_put_subrequest(remove,
				     notes & ABANDON_SREQ ?
+0 −1
Original line number Diff line number Diff line
@@ -107,7 +107,6 @@ static int netfs_single_dispatch_read(struct netfs_io_request *rreq)
	spin_lock(&rreq->lock);
	list_add_tail(&subreq->rreq_link, &stream->subrequests);
	trace_netfs_sreq(subreq, netfs_sreq_trace_added);
	stream->front = subreq;
	/* Store list pointers before active flag */
	smp_store_release(&stream->active, true);
	spin_unlock(&rreq->lock);
Loading