netfs.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Christian Brauner <christian@brauner.io>,
	Steve French <smfrench@gmail.com>,
	Matthew Wilcox <willy@infradead.org>
Cc: David Howells <dhowells@redhat.com>,
	Jeff Layton <jlayton@kernel.org>,
	Gao Xiang <hsiangkao@linux.alibaba.com>,
	Dominique Martinet <asmadeus@codewreck.org>,
	Marc Dionne <marc.dionne@auristor.com>,
	Paulo Alcantara <pc@manguebit.com>,
	Shyam Prasad N <sprasad@microsoft.com>,
	Tom Talpey <tom@talpey.com>,
	Eric Van Hensbergen <ericvh@kernel.org>,
	Ilya Dryomov <idryomov@gmail.com>,
	netfs@lists.linux.dev, linux-afs@lists.infradead.org,
	linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org,
	ceph-devel@vger.kernel.org, v9fs@lists.linux.dev,
	linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org,
	linux-mm@kvack.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH v3 26/33] afs: Fix cleanup of immediately failed async calls
Date: Wed,  6 Nov 2024 12:35:50 +0000	[thread overview]
Message-ID: <20241106123559.724888-27-dhowells@redhat.com> (raw)
In-Reply-To: <20241106123559.724888-1-dhowells@redhat.com>

If we manage to begin an async call, but fail to transmit any data on it
due to a signal, we then abort it which causes a race between the
notification of call completion from rxrpc and our attempt to cancel the
notification.  The notification will be necessary, however, for async
FetchData to terminate the netfs subrequest.

However, since we get a notification from rxrpc upon completion of a call
(aborted or otherwise), we can just leave it to that.

This leads to calls not getting cleaned up, but appearing in
/proc/net/rxrpc/calls as being aborted with code 6.

Fix this by making the "error_do_abort:" case of afs_make_call() abort the
call and then abandon it to the notification handler.

Fixes: 34fa47612bfe ("afs: Fix race in async call refcounting")
Reported-by: Marc Dionne <marc.dionne@auristor.com>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: linux-afs@lists.infradead.org
---
 fs/afs/internal.h          |  9 +++++++++
 fs/afs/rxrpc.c             | 12 +++++++++---
 include/trace/events/afs.h |  2 ++
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index 36125fce0590..238fc8cbfe25 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -1335,6 +1335,15 @@ extern void afs_send_simple_reply(struct afs_call *, const void *, size_t);
 extern int afs_extract_data(struct afs_call *, bool);
 extern int afs_protocol_error(struct afs_call *, enum afs_eproto_cause);
 
+static inline void afs_see_call(struct afs_call *call, enum afs_call_trace why)
+{
+	int r = refcount_read(&call->ref);
+
+	trace_afs_call(call->debug_id, why, r,
+		       atomic_read(&call->net->nr_outstanding_calls),
+		       __builtin_return_address(0));
+}
+
 static inline void afs_make_op_call(struct afs_operation *op, struct afs_call *call,
 				    gfp_t gfp)
 {
diff --git a/fs/afs/rxrpc.c b/fs/afs/rxrpc.c
index 9f2a3bb56ec6..a122c6366ce1 100644
--- a/fs/afs/rxrpc.c
+++ b/fs/afs/rxrpc.c
@@ -430,11 +430,16 @@ void afs_make_call(struct afs_call *call, gfp_t gfp)
 	return;
 
 error_do_abort:
-	if (ret != -ECONNABORTED) {
+	if (ret != -ECONNABORTED)
 		rxrpc_kernel_abort_call(call->net->socket, rxcall,
 					RX_USER_ABORT, ret,
 					afs_abort_send_data_error);
-	} else {
+	if (call->async) {
+		afs_see_call(call, afs_call_trace_async_abort);
+		return;
+	}
+
+	if (ret == -ECONNABORTED) {
 		len = 0;
 		iov_iter_kvec(&msg.msg_iter, ITER_DEST, NULL, 0, 0);
 		rxrpc_kernel_recv_data(call->net->socket, rxcall,
@@ -445,6 +450,8 @@ void afs_make_call(struct afs_call *call, gfp_t gfp)
 	call->error = ret;
 	trace_afs_call_done(call);
 error_kill_call:
+	if (call->async)
+		afs_see_call(call, afs_call_trace_async_kill);
 	if (call->type->done)
 		call->type->done(call);
 
@@ -602,7 +609,6 @@ static void afs_deliver_to_call(struct afs_call *call)
 	abort_code = 0;
 call_complete:
 	afs_set_call_complete(call, ret, remote_abort);
-	state = AFS_CALL_COMPLETE;
 	goto done;
 }
 
diff --git a/include/trace/events/afs.h b/include/trace/events/afs.h
index 49a749672e38..cdb5f2af7799 100644
--- a/include/trace/events/afs.h
+++ b/include/trace/events/afs.h
@@ -118,6 +118,8 @@ enum yfs_cm_operation {
  */
 #define afs_call_traces \
 	EM(afs_call_trace_alloc,		"ALLOC") \
+	EM(afs_call_trace_async_abort,		"ASYAB") \
+	EM(afs_call_trace_async_kill,		"ASYKL") \
 	EM(afs_call_trace_free,			"FREE ") \
 	EM(afs_call_trace_get,			"GET  ") \
 	EM(afs_call_trace_put,			"PUT  ") \


  parent reply	other threads:[~2024-11-06 12:39 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-06 12:35 [PATCH v3 00/33] netfs: Read performance improvements and "single-blob" support David Howells
2024-11-06 12:35 ` [PATCH v3 01/33] kheaders: Ignore silly-rename files David Howells
2024-11-06 12:35 ` [PATCH v3 02/33] netfs: Remove call to folio_index() David Howells
2024-11-06 12:35 ` [PATCH v3 03/33] netfs: Fix a few minor bugs in netfs_page_mkwrite() David Howells
2024-11-06 12:35 ` [PATCH v3 04/33] netfs: Remove unnecessary references to pages David Howells
2024-11-06 12:35 ` [PATCH v3 05/33] netfs: Use a folio_queue allocation and free functions David Howells
2024-11-06 12:35 ` [PATCH v3 06/33] netfs: Add a tracepoint to log the lifespan of folio_queue structs David Howells
2024-11-06 12:35 ` [PATCH v3 07/33] netfs: Abstract out a rolling folio buffer implementation David Howells
2024-11-06 12:35 ` [PATCH v3 08/33] netfs: Make netfs_advance_write() return size_t David Howells
2024-11-06 12:35 ` [PATCH v3 09/33] netfs: Split retry code out of fs/netfs/write_collect.c David Howells
2024-11-06 12:35 ` [PATCH v3 10/33] netfs: Drop the error arg from netfs_read_subreq_terminated() David Howells
2024-11-06 12:35 ` [PATCH v3 11/33] netfs: Drop the was_async " David Howells
2024-11-06 12:35 ` [PATCH v3 12/33] netfs: Don't use bh spinlock David Howells
2024-11-06 12:35 ` [PATCH v3 13/33] afs: Don't use mutex for I/O operation lock David Howells
2024-11-06 12:35 ` [PATCH v3 14/33] afs: Fix EEXIST error returned from afs_rmdir() to be ENOTEMPTY David Howells
2024-11-06 12:35 ` [PATCH v3 15/33] afs: Fix directory format encoding struct David Howells
2024-11-06 12:35 ` [PATCH v3 16/33] netfs: Remove some extraneous directory invalidations David Howells
2024-11-06 12:35 ` [PATCH v3 17/33] cachefiles: Add some subrequest tracepoints David Howells
2024-11-06 12:35 ` [PATCH v3 18/33] cachefiles: Add auxiliary data trace David Howells
2024-11-06 12:35 ` [PATCH v3 19/33] afs: Add more tracepoints to do with tracking validity David Howells
2024-11-06 12:35 ` [PATCH v3 20/33] netfs: Add functions to build/clean a buffer in a folio_queue David Howells
2024-11-06 12:35 ` [PATCH v3 21/33] netfs: Add support for caching single monolithic objects such as AFS dirs David Howells
2024-11-06 12:35 ` [PATCH v3 22/33] afs: Make afs_init_request() get a key if not given a file David Howells
2024-11-06 12:35 ` [PATCH v3 23/33] afs: Use netfslib for directories David Howells
2024-11-06 12:35 ` [PATCH v3 24/33] afs: Use netfslib for symlinks, allowing them to be cached David Howells
2024-11-06 12:35 ` [PATCH v3 25/33] afs: Eliminate afs_read David Howells
2024-11-06 12:35 ` David Howells [this message]
2024-11-06 12:35 ` [PATCH v3 27/33] afs: Make {Y,}FS.FetchData an asynchronous operation David Howells
2024-11-06 12:35 ` [PATCH v3 28/33] netfs: Change the read result collector to only use one work item David Howells
2024-11-06 12:35 ` [PATCH v3 29/33] afs: Make afs_mkdir() locally initialise a new directory's content David Howells
2024-11-06 12:35 ` [PATCH v3 30/33] afs: Use the contained hashtable to search a directory David Howells
2024-11-06 12:35 ` [PATCH v3 31/33] afs: Locally initialise the contents of a new symlink on creation David Howells
2024-11-06 12:35 ` [PATCH v3 32/33] afs: Add a tracepoint for afs_read_receive() David Howells
2024-11-06 12:35 ` [PATCH v3 33/33] netfs: Report on NULL folioq in netfs_writeback_unlock_folios() David Howells
2024-11-08 17:03 ` [PATCH v3 28/33] netfs: Change the read result collector to only use one work item David Howells
2024-11-08 17:23 ` [PATCH v3 23/33] afs: Use netfslib for directories David Howells

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=20241106123559.724888-27-dhowells@redhat.com \
    --to=dhowells@redhat.com \
    --cc=asmadeus@codewreck.org \
    --cc=ceph-devel@vger.kernel.org \
    --cc=christian@brauner.io \
    --cc=ericvh@kernel.org \
    --cc=hsiangkao@linux.alibaba.com \
    --cc=idryomov@gmail.com \
    --cc=jlayton@kernel.org \
    --cc=linux-afs@lists.infradead.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=marc.dionne@auristor.com \
    --cc=netdev@vger.kernel.org \
    --cc=netfs@lists.linux.dev \
    --cc=pc@manguebit.com \
    --cc=smfrench@gmail.com \
    --cc=sprasad@microsoft.com \
    --cc=tom@talpey.com \
    --cc=v9fs@lists.linux.dev \
    --cc=willy@infradead.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;
as well as URLs for NNTP newsgroup(s).