From patchwork Wed Nov 6 12:35:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13864794 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 B76B1D44D58 for ; Wed, 6 Nov 2024 12:39:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4C1988D000A; Wed, 6 Nov 2024 07:39:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 42C958D0001; Wed, 6 Nov 2024 07:39:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 226C58D000A; Wed, 6 Nov 2024 07:39:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id EA9298D0001 for ; Wed, 6 Nov 2024 07:39:32 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id B306A1A014E for ; Wed, 6 Nov 2024 12:39:32 +0000 (UTC) X-FDA: 82755625848.28.A43C85C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf12.hostedemail.com (Postfix) with ESMTP id 5376E4001D for ; Wed, 6 Nov 2024 12:39:15 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Wy8L8Mvw; spf=pass (imf12.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1730896721; 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=aHqPw2c8a9FuvJhVx4WkNMPnZ8jptON+Bkzvr9JNRgc=; b=ZwgSEu+EUclIcyAyP79AUwLZv4IJepy3X2aoVZtMCnrU/KbSflNeRKm7NJC19S+fEeywdM RelB+QbVERrw33WHJrVXew97GUCWbvlw9FU24v45ZzzZzVTv99r/A0BbYjf+IEoDMgOhsc tqKld1TlWSNH/Ihl/hotJ9rx6kkJ1LA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730896721; a=rsa-sha256; cv=none; b=3u/1S6XXSIKDpJbtF1AYvIKsa7/w4E+h3JiFDDyeCgW9DMZfnwm18v+nScVfzfyAWriQXa 153G5m2Wc7Tgm1xARuMUi6Y3uaLZ3U2OUTHsieDaRS/CWhG5THD9Q9APKdpxCwGUoJyuDv cPWFDq/hl0BAog+PTFUqstCVtvB44W8= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Wy8L8Mvw; spf=pass (imf12.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1730896770; 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=aHqPw2c8a9FuvJhVx4WkNMPnZ8jptON+Bkzvr9JNRgc=; b=Wy8L8Mvw6qWvDUZ1FLX5jnRUVG7+Y3hLmsTwiZC9CKr8AGR6gYsWY4kdxTxDDItUhYGiNk 24JnUWb+WkAT8Nx5k93k2clsk+jM1uOktyDwD7gkA1qiTC3JtShnECIAUDW+C4vuP4aQ7V F/Oo/fbsUs05ZeQwcqON3/VFv0QLat0= Received: from mx-prod-mc-02.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-530-MRnpyDNFNNywM1SBYv0ajg-1; Wed, 06 Nov 2024 07:39:27 -0500 X-MC-Unique: MRnpyDNFNNywM1SBYv0ajg-1 X-Mimecast-MFC-AGG-ID: MRnpyDNFNNywM1SBYv0ajg Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4A6A01955EAA; Wed, 6 Nov 2024 12:39:24 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.231]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C312619541A5; Wed, 6 Nov 2024 12:39:18 +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 v3 26/33] afs: Fix cleanup of immediately failed async calls Date: Wed, 6 Nov 2024 12:35:50 +0000 Message-ID: <20241106123559.724888-27-dhowells@redhat.com> In-Reply-To: <20241106123559.724888-1-dhowells@redhat.com> References: <20241106123559.724888-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Stat-Signature: 7zbz6e35uuxgn4ja68w5gh6egbd5axbo X-Rspam-User: X-Rspamd-Queue-Id: 5376E4001D X-Rspamd-Server: rspam02 X-HE-Tag: 1730896755-782091 X-HE-Meta: U2FsdGVkX18soqHwkhojbf0anJoiAjYPJI9F2sVTwvutL3yfhkvLZqnNhcCJN1EADlpBA06G2elxDrvbbPCQfp/Pu7x+yIEkIZ1c23ifE6/gcVNP6dTji6cQqXGG6jIRzkl7O+xkK5aGIPKDyAQmG2oYJzBbBmg3kDN5g48NDuj71nn9xK0+/vVS8qj8fEBbHCOFO+2JkQ7DmWlIsTEgVsJEqLvmMExFK3oEMWd9n/RF7/kWq1gED7eD97YIDyFPY704wiQaj1D4l75uO1VSSDrrhin7u5MRWdb59ZO6djjTY1X/p0tT3K0DFPKNiVLOcMPJVjTSoBfRQWC9CTOUz7g1vs5P6d5seytBM5hens0stZnUxx7XEMVt4eaArevaCluWpUrVV/9bH7e9Iqg2zFsTWoQMCjIft1XcAiTofH3g/RpW+AlnRPFj7mi52kNV/CZMxM31kfqMYb3UU6CO23fmv5MCWAoYrIfTc0vWDA9/zPNgliRlR7m2ahF1/SOwjlFVfABPflnqNqlYNbbeAmiSQ+JN/dEiyOkcPn3NgsiX5UW4hWQ/KoiajlX/kP6maCeUIsE924CXOUHbfSoyqcZMGxqPbC3mbFtFO3TGqkVqQ1afhFukw2fl7VQd/c7xcNnHURKaFt71NcS+/LebtpC1KB2GIFVCc8ExhNS1g+p0/z1H+ySx/X2a75YtsWQ5cgYDfA+q2z8eNrBSq7ZrfXpGtnJreFzb13iQ1+dwATJrlcF+NSASYY1go6D5wgF3lGUMY9XEUdcs+/9C80ooSeazmFSHtBcPk0uPMkxEh8wxj2NFQIRzIojbXxx8jmsURQWEaMPDE5HpmrAkLt11jyGcSPFEFLTyOPmyMDzJIeHhMApuFfMOYTKfOdH0RXSssOHFKS8Lda8/xTVmy2ZEumgsYQW79JvB7eUQkFyxxq+/ssPBTY4ke8DU4v+AJrLetre9QUwPkapZJMNX5jl I8/9hwWc O1Cr/Zj4vWBjm+4jJRhE0zSdxbzPmeIHjaTZUMGuvMTmKnFVmv3lIRQQkXHIk9v5xqey1VKN+0pTfqzMufA0x7U/4AcpzkaEGmmzKm9H1LmWLGBUhuWhcQDfMx4WOPDS5uIA4sZdlHC2NtxOlGJ6eKH7P+uGfm219jYc2Dg2wjq8RBOS3h8QAHlhHya+rF93/Equz9CssiwXLjRij+iiY71lfjIogYSQbLrpZFnwGQnQwjwvRj1m11/dZ2BX5t58P0/JI/KlIGc9L8Vo+9qgIR/j+ymvtLMKaU8bYPoz4016b4y1ZFzl6wOgwKd/bKhwJJGLRW84R7DhDD5TOEpMIp8+odhvb4+eCL3PetNVyOrHA7o5vBsrKJhodUPCvRMM9KDLvp9wX1E71A5mdqPZaJMFBgBLSeSE/SYQvPHKjSsx9RKdeHECD99KiyaQY3TX1bImW 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 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 ") \