netfs: Fix ref leak on inserted extra subreq in write retry
authorDavid Howells <dhowells@redhat.com>
Tue, 1 Jul 2025 16:38:40 +0000 (17:38 +0100)
committerChristian Brauner <brauner@kernel.org>
Tue, 1 Jul 2025 20:37:13 +0000 (22:37 +0200)
The write-retry algorithm will insert extra subrequests into the list if it
can't get sufficient capacity to split the range that needs to be retried
into the sequence of subrequests it currently has (for instance, if the
cifs credit pool has fewer credits available than it did when the range was
originally divided).

However, the allocator furnishes each new subreq with 2 refs and then
another is added for resubmission, causing one to be leaked.

Fix this by replacing the ref-getting line with a neutral trace line.

Fixes: 288ace2f57c9 ("netfs: New writeback implementation")
Signed-off-by: David Howells <dhowells@redhat.com>
Link: https://lore.kernel.org/20250701163852.2171681-6-dhowells@redhat.com
Tested-by: Steve French <sfrench@samba.org>
Reviewed-by: Paulo Alcantara <pc@manguebit.org>
cc: netfs@lists.linux.dev
cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/netfs/write_retry.c

index 9d1d8a8bab726149d150c4588a106f15106384ea..7158657061e98153dcf6faf6bd609c49a9ce0fba 100644 (file)
@@ -153,7 +153,7 @@ static void netfs_retry_write_stream(struct netfs_io_request *wreq,
                        trace_netfs_sreq_ref(wreq->debug_id, subreq->debug_index,
                                             refcount_read(&subreq->ref),
                                             netfs_sreq_trace_new);
-                       netfs_get_subrequest(subreq, netfs_sreq_trace_get_resubmit);
+                       trace_netfs_sreq(subreq, netfs_sreq_trace_split);
 
                        list_add(&subreq->rreq_link, &to->rreq_link);
                        to = list_next_entry(to, rreq_link);