From patchwork Mon Dec 16 20:41:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13910506 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 273DEE77183 for ; Mon, 16 Dec 2024 20:44:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ACFC96B00CC; Mon, 16 Dec 2024 15:44:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A4D676B00E1; Mon, 16 Dec 2024 15:44:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8A0EF6B00E2; Mon, 16 Dec 2024 15:44:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 5D9596B00CC for ; Mon, 16 Dec 2024 15:44:40 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 11113ACB50 for ; Mon, 16 Dec 2024 20:44:40 +0000 (UTC) X-FDA: 82901999754.30.FB6EFE0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf13.hostedemail.com (Postfix) with ESMTP id 5A0452000B for ; Mon, 16 Dec 2024 20:44:09 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MlB52lKA; spf=pass (imf13.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=1734381858; 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=7Rzt3CvBzQOmJqie1D3ccu3exasudbT/5eWilriju0oc2qMOkw0CoNacWIVqEgyW5deNBe eA8d3ygQ06lu7e+RMAHjCtR+RozRske16s/3X9VLrsNIokf6oLBhaV3oBC2P85fEpkkCRW RakEXvM3hCEeWLnRci2bVng33dJlMGM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734381858; a=rsa-sha256; cv=none; b=KsJ5dimP5ykE4CtwVVDc2bVGjyb0oSr0A5M8Dklv+YaL5CaDVoxngzjTiM/GjxeandGSAr U0PCjqEu6AN51BSqd+kVzLTq6dmYaqeRTnY/KW13vfb2RncmCU/fCTUTN9/HVOMfpSSYvu zv7YJkdFBq2U+H4zwwffM1pdF1lSaiI= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MlB52lKA; spf=pass (imf13.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=1734381877; 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=MlB52lKAZLBBpvlnMOkJQhGDxcLf0BBHXy9eQpIksF0OX/nOOfy9/cx4G0UxarWrcGpBL4 iICumD0SLVNEbIvkSFkDb9wu8iJLSeTX4FSH7uwSCdOhi2isC3CN1iOxBcLCBR/MzAMZmg G3ewwvzTMFy1wCTOysX/LEec7Oi6ImM= Received: from mx-prod-mc-03.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-655-CmBsNdYvNwikLl9PUzf_eA-1; Mon, 16 Dec 2024 15:44:34 -0500 X-MC-Unique: CmBsNdYvNwikLl9PUzf_eA-1 X-Mimecast-MFC-AGG-ID: CmBsNdYvNwikLl9PUzf_eA Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AA3D6195604F; Mon, 16 Dec 2024 20:44:31 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.48]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2010319560AD; Mon, 16 Dec 2024 20:44:25 +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 v5 24/32] afs: Fix cleanup of immediately failed async calls Date: Mon, 16 Dec 2024 20:41:14 +0000 Message-ID: <20241216204124.3752367-25-dhowells@redhat.com> In-Reply-To: <20241216204124.3752367-1-dhowells@redhat.com> References: <20241216204124.3752367-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 5A0452000B X-Stat-Signature: wps8by4py93jq6k8ssxp8amkwgcuzpqi X-Rspam-User: X-HE-Tag: 1734381849-314522 X-HE-Meta: U2FsdGVkX18eaWazdAXJ0g/McyCavSCdW682zajfzrn5SAdJTAYZpmEAAGnCY50btrT4NBJxxjKnN9pA3jeFcm6QDWIGB19uMH1QNpmtLSHUA6hwFVb6vdM+xHQiRBhPwlllZ3gPxK5HLEnEzuiQJqvrMhMFbQmIMKOpaCW0gOxsr2SRpmH+GErt7w3uDPW+uYwMKQecGWkQcal185+YOAUDbDae0BBt4hBrL33JegicTn77wbrhXMHKOvx/Evn12k26fvn5Lmjjjpt6qYOuKhtlQ1cSJ7fUKyiHkJgjkTMu7jNu/Cj/LYsBqBPL8gDjqaWtavH6uHbu2MqzTbilNuNUnal4fnREOnwuLmydN483MEYorS1f8XvF1CXTjm+E7gB7uwYy108bu1d191q0LzL5sRbk4DPJfFxRx1CWxBA/gXCbgXCwrxZ8eC4v/au5c3GmXc2L8YSiXSTYDCv+1Esn9BsrUvaS37Wgvne0qOnoSnktPCJz2jJI0JIOtYZJMGm+zSRY8+RYUVklfepcsodltQhj+Rb9n8mMoyHDLXNSBwqV8RODyzURL1L+J+J+ZeNE8VumwKy35IEG6H1Qhi/F+wkBE2NqCrPMLAskXLi9HP0Ull/erArQ91wI3yaJ4abuH590zeYjgQ/qzFr2JrqQgZAwNmpYRaJRhtsEI28IZGTsNGGBMCm8GFKG0WZXLGyUROCegBN0cDay5KvB0ZYe+3YuH/8hxFXah2D1Nw0JEwaQ3CeSP8JYg1mDnbRPA48w8f7LPAe8owzc9KXsMlX8n3CvgX41SDeJiqeVBUAgrWxfKZ3FY5oMBMZbST/cexUPeDGKWaxV35AuKTf7mjOKhytdi8wNyTulvlvzyN6K26+TUsNjQxPV+Mh7KgiYDPkIKnYDbcD6JE0I5rHIVhwhHtAr0mZEi+oLLP0EIr1/kMtA5RrZpuAhdcAtalsawfyWwe/vENMZHjymtTX cL4l6Swr GQt/MOIYGifY4ZitMKkxUxU+ceqVRCqU+XGHgnp/yHj6pj/YHnmJ665bebH0ebrPcmukJMHoh07lPYURu9UpWpb4POmHxQ0O6QfzIM9fTiOTvNsS1XNCJQrmw6HywrVAcMzb+7pM3evqzAFLosgrSg/7ZJ17wjfESEbva83MnmTWeOeNFORBuUES1WNALimlT3MT8obfd+vTOjktbyF4TtHtjWzXgOvV+T0tf4eaXop6s3cRR9LL2iqtcCiWeelzwjcpUedxAB0TCn+0eHiUEcJB39e8+Hdd13nX8V1UST9966pID+Kk4GGPpTfPnvDQWFa3ZSiWTKQYicDJxkiT+N/2/1Ro7wt3XzkCyUKcr2UmAlhExEHGahPwsgzYABhAvR3FuqFm/lhIKmHK79Ie+FWEF7mwWmuHRkospgp1IMVMmApGG2QPOPoBj1mpCeEoR0aFm 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 ") \