From patchwork Fri Nov 8 17:32:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13868584 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC560D64072 for ; Fri, 8 Nov 2024 17:36:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5B37B900002; Fri, 8 Nov 2024 12:36:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5112B8D0001; Fri, 8 Nov 2024 12:36:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 36645900002; Fri, 8 Nov 2024 12:36:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 128BB8D0001 for ; Fri, 8 Nov 2024 12:36:01 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id CB65D80EC6 for ; Fri, 8 Nov 2024 17:36:00 +0000 (UTC) X-FDA: 82763629242.19.D53AEA7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 8C64840025 for ; Fri, 8 Nov 2024 17:35:30 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=J++NsyyU; spf=pass (imf17.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731087273; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=OrdAljyu/86B7Uupqp5aIMyvZ1Oua6M6rtiSOl8cYT8=; b=mvEmwM0bNSuKJq1epXonA/edEP7m5A7K2yWrnA3Mex+HznH9o0l51VQAgOStAJbDqvfeA4 /1ICzSk1AibwP2VGG3pm1Y3PY+yL4B9R+ZWmY2ozddO0nHtmTe3QVgNNvdneStdRVPv0I3 +3LBXdIUb/mpEO/7JJqhfb4wbE0Olq4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731087273; a=rsa-sha256; cv=none; b=SHutIOk2lzJljhhm0m7bzDrIOHaQffzx2ggsTFBFgojOqpl7T+Zq0cY5V89ihpX4vuKfuc aS23TTWWqAiK9m3nmK5k7NIS7ClxVOUCtllE0/Y4LgI8bmG2+bxxEsMD7813KVjIcHtvuK ngLZIRwa6tVECnIZVOwRaEVDDVPjkUY= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=J++NsyyU; spf=pass (imf17.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731087358; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OrdAljyu/86B7Uupqp5aIMyvZ1Oua6M6rtiSOl8cYT8=; b=J++NsyyUQtUC5BeW/9kLW/p7KF2RklaI+qyjrWxc9/O5+Z3lPk8AIZEoJ1zlCqlmAPY9EJ 4JSGnBIV8dDVdXQ2HV267fOJoys7bTQM3oImIc4FkKc63JemnsRjbB/TR+8V6GrpN2EE7k E280ZIFlpNwA/kGVwFdfab9tuXOzPE4= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-529-EfyNqsjiPTm6U8UvLq2wbA-1; Fri, 08 Nov 2024 12:35:57 -0500 X-MC-Unique: EfyNqsjiPTm6U8UvLq2wbA-1 X-Mimecast-MFC-AGG-ID: EfyNqsjiPTm6U8UvLq2wbA Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 59E7019560A1; Fri, 8 Nov 2024 17:35:54 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.231]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DD9153003B71; Fri, 8 Nov 2024 17:35:48 +0000 (UTC) From: David Howells To: Christian Brauner , Steve French , Matthew Wilcox Cc: David Howells , Jeff Layton , Gao Xiang , Dominique Martinet , Marc Dionne , Paulo Alcantara , Shyam Prasad N , Tom Talpey , Eric Van Hensbergen , Ilya Dryomov , 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 v4 26/33] afs: Fix cleanup of immediately failed async calls Date: Fri, 8 Nov 2024 17:32:27 +0000 Message-ID: <20241108173236.1382366-27-dhowells@redhat.com> In-Reply-To: <20241108173236.1382366-1-dhowells@redhat.com> References: <20241108173236.1382366-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Rspamd-Server: rspam10 X-Stat-Signature: cet69k5jgroabnpbg6amh44dsdq7rmwg X-Rspamd-Queue-Id: 8C64840025 X-Rspam-User: X-HE-Tag: 1731087330-222398 X-HE-Meta: U2FsdGVkX19Sc8hEj8SoGCJ2oOAzeFH/nLLjfIy9k3RYPXsr0YyqXNN442x3A0tGnGZHgDONj5a9bGfrnBvB1a9KNlcedG/Z74X9TmqOIGt8eO3PRRj/cZfhIYa7oAPdRjcNfdX8teVSzFE6ZhtR6L3FLSAsCRkkA+REALLaOhv12HNkOyduZVtCSbjHCrkrvKDoq1hP4ZTtrozADVEwLWC8RwnjRg4vkuPw2+DliMqxExAQWyDZJEUN9ej4pZbdh8zYCwAWpghD3TzaQdSyIk+9RAu61Ve0ekharSzMSj6MmAYd+IBINbN34iK3C8omQxJd6U5t7xkdMRPt8NwpcV1U8zmH0uSUqidHzDYiupf/cneq898azl3bAsVGC2rzLL20FUiuHjmQS2iq7AJ6JGfogvI3Bc42yrGp1E8Esz0wEfmf3NPyWmgU8zLV91vPgisQr5H2yT6TncHBGbqOYJeM5NityMq9i5cvuUYmACbZn9L7GqK6uzFuyjM17Az6RxwF/sQ1EE33aqEH7Gle59w92zymX38HVx/SMpwNq8voQy2P1SAI2fHczNAAKhRvgV0m5SpD2GuO+FAnRI5F1EOANaVtNX3sq5xfRVLE4HlHSyc40w43D8O2njGYM5tYLw+536Ij/TcPkwBeqt1dHDkH43tvbvxhUjFBtTh4XG7f7TRH+EdMCAXALkTdA+WbRy0cnd7zBevHfso66JigEuGiwEv3zofhKWv1Lvp1qRgqbFP7jh1ZfCfHMjP2yM2BKW2gvjhOugOkyCVA1/zjipa3yRM451gah1IcXyycIvEbHE9ymuaeFOFwhws/Z9oQu23y72aUBJOY7HKKsuGZknvEJkNsQZAn+K4JbHMXEBHyK7lSlTyVJJ3ivH77N9KyXEUvniBJLUMZniQ1dBY/4BQb9F6mJuHsXkNIN4071VtbUvqhNbUoB0ZwoI3En2+IfWrqwbBhAOYy/fP1qDg 2IIqgGOd mOSBs+wuthyy6J/VGoQU+J8HHMNneMk0gRfVHnCUMB93adaMZzZSFk36lPOOnYWe8YPAvupzBYo14xVU3kDyemBSVGptcl9ScTU2W1aimgEcD7PHBJTUTWSYh1+BwnriliyZpi6SuoZZNtqF2OkmU+7ddgjp2if69WZtRE4tgNscK2lIIcDIxCTCSJiu39LU16DlZNtAz0lT0KVzIkjtpj4c3aZyGSFdS1yp4FXqijhYQPI8ZutWXNOxDTm+n5IG/LsiIEDfZ6aTpqDoeHZqnqoniACgxTm+XZbu5MOUDjiqu81dPe/xp8r6FWJNpX9B5Uq2+v87HzRSDL0U2DL4biUZ4TwB+rr+at0zhbRyqJgiqhf5kHnwfMM5vRwltwKq7ZeXU2dhU8MfY9Wr65C6FvZzgFjbCFYcbw4nbZsYDiK1YrDv6tKYoR3MF8RBzBA+GjtXI X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 Signed-off-by: David Howells 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 39d2e29ed0e0..96fc466efd10 100644 --- a/fs/afs/internal.h +++ b/fs/afs/internal.h @@ -1336,6 +1336,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 ") \