Linux filesystem development
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev, David Howells <dhowells@redhat.com>,
	Paulo Alcantara <pc@manguebit.org>,
	netfs@lists.linux.dev, linux-fsdevel@vger.kernel.org,
	Christian Brauner <brauner@kernel.org>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.12 356/869] netfs: Fix missing locking around retry adding new subreqs
Date: Sat, 17 Oct 2026 17:53:17 +0200	[thread overview]
Message-ID: <20261017160046.234460515@linuxfoundation.org> (raw)
In-Reply-To: <20261017160036.979869304@linuxfoundation.org>

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: David Howells <dhowells@redhat.com>

[ Upstream commit cce18c263e9623872327ba3c956012f73c1179cc ]

Fix netfs_retry_read_subrequests() and netfs_retry_write_stream() to take
the appropriate lock when adding extra subrequests into
stream->subrequests.

Fixes: e2d46f2ec332 ("netfs: Change the read result collector to only use one work item")
Fixes: 288ace2f57c9 ("netfs: New writeback implementation")
Closes: https://sashiko.dev/#/patchset/20260425125426.3855807-1-dhowells%40redhat.com
Signed-off-by: David Howells <dhowells@redhat.com>
Link: https://patch.msgid.link/20260512123404.719402-3-dhowells@redhat.com
cc: Paulo Alcantara <pc@manguebit.org>
cc: netfs@lists.linux.dev
cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/netfs/write_collect.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/netfs/write_collect.c b/fs/netfs/write_collect.c
index c349867d74c34..ad2edf794f0ff 100644
--- a/fs/netfs/write_collect.c
+++ b/fs/netfs/write_collect.c
@@ -263,7 +263,9 @@ static void netfs_retry_write_stream(struct netfs_io_request *wreq,
 			list_for_each_entry_safe_from(subreq, tmp,
 						      &stream->subrequests, rreq_link) {
 				trace_netfs_sreq(subreq, netfs_sreq_trace_discard);
+				spin_lock_bh(&wreq->lock);
 				list_del(&subreq->rreq_link);
+				spin_unlock_bh(&wreq->lock);
 				netfs_put_subrequest(subreq, false, netfs_sreq_trace_put_done);
 				if (subreq == to)
 					break;
@@ -287,8 +289,10 @@ static void netfs_retry_write_stream(struct netfs_io_request *wreq,
 					     netfs_sreq_trace_new);
 			trace_netfs_sreq(subreq, netfs_sreq_trace_split);
 
+			spin_lock_bh(&wreq->lock);
 			list_add(&subreq->rreq_link, &to->rreq_link);
-			to = list_next_entry(to, rreq_link);
+			spin_unlock_bh(&wreq->lock);
+			to = subreq;
 			trace_netfs_sreq(subreq, netfs_sreq_trace_retry);
 
 			stream->sreq_max_len	= len;
-- 
2.53.0




  parent reply	other threads:[~2026-10-17 16:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20261017160036.979869304@linuxfoundation.org>
2026-10-17 15:53 ` [PATCH 6.12 355/869] netfs: Fix leak of request in netfs_write_begin() error handling Greg Kroah-Hartman
2026-10-17 15:53 ` Greg Kroah-Hartman [this message]
2026-10-17 15:53 ` [PATCH 6.12 365/869] netfs: Fix zeropoint update where i_size > remote_i_size Greg Kroah-Hartman
2026-10-17 15:54 ` [PATCH 6.12 436/869] netfs: Clean up some whitespace in trace header Greg Kroah-Hartman
2026-10-17 15:54 ` [PATCH 6.12 437/869] netfs: Use a folio_queue allocation and free functions Greg Kroah-Hartman
2026-10-17 15:54 ` [PATCH 6.12 438/869] netfs: Add a tracepoint to log the lifespan of folio_queue structs Greg Kroah-Hartman
2026-10-17 15:54 ` [PATCH 6.12 439/869] netfs: Abstract out a rolling folio buffer implementation Greg Kroah-Hartman
2026-10-17 15:54 ` [PATCH 6.12 440/869] netfs: Drop the was_async arg from netfs_read_subreq_terminated() Greg Kroah-Hartman
2026-10-17 15:54 ` [PATCH 6.12 441/869] netfs: Fix netfs_create_write_req() to handle async cache object creation Greg Kroah-Hartman
2026-10-17 15:55 ` [PATCH 6.12 497/869] netfs: Fix folio_queue ENOMEM in writeback by adding a mempool Greg Kroah-Hartman
2026-10-17 16:01 ` [PATCH 6.12 845/869] netfs: release readahead folios on iterator preparation failure Greg Kroah-Hartman
2026-10-17 16:01 ` [PATCH 6.12 846/869] netfs: Fix folio state after ENOMEM whilst under writeback iteration Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261017160046.234460515@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=brauner@kernel.org \
    --cc=dhowells@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=netfs@lists.linux.dev \
    --cc=patches@lists.linux.dev \
    --cc=pc@manguebit.org \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox