From mboxrd@z Thu Jan 1 00:00:00 1970 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 5F9BCD74958 for ; Thu, 31 Oct 2024 12:58:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E66466B008C; Thu, 31 Oct 2024 08:58:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DEF306B0092; Thu, 31 Oct 2024 08:58:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C69B86B0093; Thu, 31 Oct 2024 08:58:49 -0400 (EDT) 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 A19676B008C for ; Thu, 31 Oct 2024 08:58:49 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 1D4C0A14D8 for ; Thu, 31 Oct 2024 12:58:49 +0000 (UTC) X-FDA: 82733900634.03.98B01A5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf04.hostedemail.com (Postfix) with ESMTP id E3AC840011 for ; Thu, 31 Oct 2024 12:58:12 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=R03KAIA7; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf04.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730379446; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Tw7g6uU6ZxI1gC/pUKtFC6nfgE91Ln7aDN8ewiylNhk=; b=s0vgqqPFZta2OhOUoBZJNm0iBMqP/tg9uoqENKUDse8sn/GFh/IEGV1Wt8kJCHcikE7vH0 keis2hpReGtQ6ti0HpfqkyRe86k4Bwz4VpyU2KUjyYXCHazcY52CPKg8lr7Hx9DZWsfJvC /tJeOZe9rQGF2RxMr5bLODAev6kD7xE= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=R03KAIA7; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf04.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730379446; a=rsa-sha256; cv=none; b=j1D89UBqNgkBKyopmEUn90LSI2/BnpYieh7mHmKX1kpa66zbwC++9Kq9RbQrmyXfZr5YJr 2JqhZZmJfX+tD/lDKDQ112wkoW9ySsP1twxPxUwD4JDAsJyy4RoU0kxSobqCxKK0oze2lL bb+I5wcAC8EGgAZ6zg3do2qTbs97bU8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730379526; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Tw7g6uU6ZxI1gC/pUKtFC6nfgE91Ln7aDN8ewiylNhk=; b=R03KAIA7nlAsBEVsaF+/w3KU4DYNmkaih95mq/KUokw8OjnWwGWmsfV/dbkYHY1nWzVGjw 6A+msBqwOnrCjX3xPSywmPrfRIjalEzbhT0/9ES/C6FIxJWVyf/SUOoNlNe8FVmekZTcv7 AiCvB/XcaY70GFxRItuMNlAZJSWcTwY= Received: from mx-prod-mc-01.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-99-Mc0dZgGdMRKw16nHTE7gOw-1; Thu, 31 Oct 2024 08:58:41 -0400 X-MC-Unique: Mc0dZgGdMRKw16nHTE7gOw-1 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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 91A071956058; Thu, 31 Oct 2024 12:58:38 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.231]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 40C4E1956054; Thu, 31 Oct 2024 12:58:34 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <20241025204008.4076565-26-dhowells@redhat.com> References: <20241025204008.4076565-26-dhowells@redhat.com> <20241025204008.4076565-1-dhowells@redhat.com> To: Marc Dionne Cc: dhowells@redhat.com, Christian Brauner , Jeff Layton , 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: Re: [PATCH v2 25/31] afs: Make {Y,}FS.FetchData an asynchronous operation MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <43387.1730379513.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Thu, 31 Oct 2024 12:58:33 +0000 Message-ID: <43388.1730379513@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: E3AC840011 X-Stat-Signature: ao5i3a6spsn1ynt6dwo9oa85irju7bfe X-HE-Tag: 1730379492-370516 X-HE-Meta: U2FsdGVkX190srmz5lJeTTRF8Ui/5u5sGOH74zinNxjdtVt9QTXfi+CIGVsXCGWZQKwdmXgdJ20uvlR7g/D08XEcNbXql38gWPVhz9kfup3wqf8XnlukFOaGgVYlIM2L7X8lcCEzI3EPYrbGIXwXLcHpBYPd7EWIHAZtNF+ZWLJpy3zuspfvCpaQ9+DoNScPTYPWw1hpf4CdJrhDgbO0kaiwP80T47akN+wgmGNnUVMA3UGGt7ZXJWhwS+up5Mjm0Mx5McZqTB0awd//vpylVSaQ+aCGXs2oZZeuf/R0OTG9FBLLOBsk2bIT3VNXvCeFM9HJVUHYaHaefHjy/UCnweok9e6QJBSo+UL9jO5qdAudXWckajWVMqO5qNd2kz/9PLvAYuv9ykWuSr4rwgw0bTRZc03dkPcs9s/lGkZvmhR9T5eAqYh/1fByowY9goxrZkTFRGdgKfXywUSRWVZRGiJuUekLlwQxnRY0lIFrZNGMTaLSkjxRgkLf75D+7S6zDurpnfWzXIsP99T+EplH4V6m3udOJdnOO6XHRyYHSewvW/QRYofXzgw5wxlAvGGdE0Hbu6ooMh1Yet67htPkzcD3L9Klybol/Pt9Hngm8D2zJIf84HnHZt1aRUzXHjWBEOQ2+Qb8sTfphLM8vt2o4uqaxKCcT6ElZtWIRGHECPt8Y3WlJUzy8SrPKjkEwULerh2y9uOOoXOsxzoeZd5QdLDAvwIgBAgp1rTf+l3XEEFdlC+o+iE6zdjzhyc8GXYIsr0DXkMftK3a935SPk24bWuS/8HcwcAlJNE1TIFYXxl+TzFkwf36GgC6rHtpGGgY+pLsjzPuHmwk/94B+40UScMs4H25bIizyYhNTpYQD6jO+K4oyJm8N21Q5+Ut/GRvsKKUSKeyt4FCuFjUC+CkvBPfzyt6rw61ak9P0G3wmhm4C6BPM9lTRWzgal0KKAhsJMJ2QIJqPifoXekBdNy 35+nXz6T nYY+m0TMrGLvsGwLiC8zLuefe9NftxLVQkFJBKTnMj9TCaJEPQ2n8qcx3cAB1gHW/iBWBJWh5XS6K3eZyrPDHKsL9a3KZrs5eagvG3mER28rnmLCAmaXCoJKdXb1B1aQtiTWLndUh5tu3Y3jFEt6R+KUDD2nyBeoRG0wzsm0oHXmqZ7sj37nK8v1boKQNRVP+Yd/3pf+xCqdYN8g9lg8lDWNxRmgCtrTBRVDyqHvC5DOzeJWhVX5lxBI6PoDiTbFAVZnteZchpwv9BdyEBsEg0F6z/ZRbkDE0xUhPstHyZtx/wZiKKMnVasRbQnZp7P5JfOHF4OkAhztcV540w9g2V15sJJi4orAWHW6d80Q5kYX/pwgW5ztU/kzTF3owNEW0BpCYkiGkXilS0g3ZGW8J6G47lckePTUVoRWY2HJtkA5TaCaItGYmOLMUFWqZjcbHCoIv 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: I think this may need an additional bit (see attached). David --- afs: Fix hang due to FetchData RPC op being cancelled by signal If a signal comes in just as an RPC operation is being queued to get a channel for transmission, afs_make_call() will submit an immediate abort and cancel the asynchronous work. This is a problem for asynchronous FetchData as the file-read routines don't get notified and don't therefore get to inform netfslib, leaving netfslib hanging. Fix this by: (1) Split the ->done() call op to have an ->immediate_cancel() op also that is called by afs_make_call() instead of ->done(). It is undesirable from async FetchData's point of view to implement ->done() as this is also called from the received data processing loop, which is triggered by the async notification from AF_RXRPC. (2) Make the various async Probe RPCs use their ->immediate_cancel() go t= o the same handler as their ->done() call. (3) Don't provide the Lock RPCs, InlineBulkStatus RPC and YFS.RemoveFile2 RPC with ->immediate_cancel() as their ->done() calls are only interested in looking at the response from the server. (4) Implement this for FetchData RPCs, making it schedule the async handler and wait for it so that it doesn't get cancelled. Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- fs/afs/file.c | 8 ++++++++ fs/afs/fsclient.c | 3 +++ fs/afs/internal.h | 17 +++++++++++++++++ fs/afs/rxrpc.c | 17 ++--------------- fs/afs/vlclient.c | 1 + fs/afs/yfsclient.c | 1 + 6 files changed, 32 insertions(+), 15 deletions(-) diff --git a/fs/afs/file.c b/fs/afs/file.c index dbc108c6cae5..a2880fd3c460 100644 --- a/fs/afs/file.c +++ b/fs/afs/file.c @@ -314,6 +314,14 @@ void afs_fetch_data_async_rx(struct work_struct *work= ) afs_put_call(call); } = +void afs_fetch_data_immediate_cancel(struct afs_call *call) +{ + afs_get_call(call, afs_call_trace_wake); + if (!queue_work(afs_async_calls, &call->async_work)) + afs_deferred_put_call(call); + flush_work(&call->async_work); +} + /* * Fetch file data from the volume. */ diff --git a/fs/afs/fsclient.c b/fs/afs/fsclient.c index 6380cdcfd4fc..1d9ecd5418d8 100644 --- a/fs/afs/fsclient.c +++ b/fs/afs/fsclient.c @@ -410,6 +410,7 @@ static const struct afs_call_type afs_RXFSFetchData =3D= { .op =3D afs_FS_FetchData, .async_rx =3D afs_fetch_data_async_rx, .deliver =3D afs_deliver_fs_fetch_data, + .immediate_cancel =3D afs_fetch_data_immediate_cancel, .destructor =3D afs_flat_call_destructor, }; = @@ -418,6 +419,7 @@ static const struct afs_call_type afs_RXFSFetchData64 = =3D { .op =3D afs_FS_FetchData64, .async_rx =3D afs_fetch_data_async_rx, .deliver =3D afs_deliver_fs_fetch_data, + .immediate_cancel =3D afs_fetch_data_immediate_cancel, .destructor =3D afs_flat_call_destructor, }; = @@ -1734,6 +1736,7 @@ static const struct afs_call_type afs_RXFSGetCapabil= ities =3D { .op =3D afs_FS_GetCapabilities, .deliver =3D afs_deliver_fs_get_capabilities, .done =3D afs_fileserver_probe_result, + .immediate_cancel =3D afs_fileserver_probe_result, .destructor =3D afs_fs_get_capabilities_destructor, }; = diff --git a/fs/afs/internal.h b/fs/afs/internal.h index b11b2dfb8380..2077f6c923e0 100644 --- a/fs/afs/internal.h +++ b/fs/afs/internal.h @@ -210,6 +210,9 @@ struct afs_call_type { = /* Call done function (gets called immediately on success or failure) */ void (*done)(struct afs_call *call); + + /* Handle a call being immediately cancelled. */ + void (*immediate_cancel)(struct afs_call *call); }; = /* @@ -1127,6 +1130,7 @@ extern void afs_put_wb_key(struct afs_wb_key *); extern int afs_open(struct inode *, struct file *); extern int afs_release(struct inode *, struct file *); void afs_fetch_data_async_rx(struct work_struct *work); +void afs_fetch_data_immediate_cancel(struct afs_call *call); = /* * flock.c @@ -1362,6 +1366,19 @@ 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 struct afs_call *afs_get_call(struct afs_call *call, + enum afs_call_trace why) +{ + int r; + + __refcount_inc(&call->ref, &r); + + trace_afs_call(call->debug_id, why, r + 1, + atomic_read(&call->net->nr_outstanding_calls), + __builtin_return_address(0)); + return call; +} + 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 94fff4e214b0..066e5d70dabe 100644 --- a/fs/afs/rxrpc.c +++ b/fs/afs/rxrpc.c @@ -236,19 +236,6 @@ void afs_deferred_put_call(struct afs_call *call) schedule_work(&call->free_work); } = -static struct afs_call *afs_get_call(struct afs_call *call, - enum afs_call_trace why) -{ - int r; - - __refcount_inc(&call->ref, &r); - - trace_afs_call(call->debug_id, why, r + 1, - atomic_read(&call->net->nr_outstanding_calls), - __builtin_return_address(0)); - return call; -} - /* * Queue the call for actual work. */ @@ -444,8 +431,8 @@ void afs_make_call(struct afs_call *call, gfp_t gfp) call->error =3D ret; trace_afs_call_done(call); error_kill_call: - if (call->type->done) - call->type->done(call); + if (call->type->immediate_cancel) + call->type->immediate_cancel(call); = /* We need to dispose of the extra ref we grabbed for an async call. * The call, however, might be queued on afs_async_calls and we need to diff --git a/fs/afs/vlclient.c b/fs/afs/vlclient.c index cac75f89b64a..adc617a82a86 100644 --- a/fs/afs/vlclient.c +++ b/fs/afs/vlclient.c @@ -370,6 +370,7 @@ static const struct afs_call_type afs_RXVLGetCapabilit= ies =3D { .name =3D "VL.GetCapabilities", .op =3D afs_VL_GetCapabilities, .deliver =3D afs_deliver_vl_get_capabilities, + .immediate_cancel =3D afs_vlserver_probe_result, .done =3D afs_vlserver_probe_result, .destructor =3D afs_destroy_vl_get_capabilities, }; diff --git a/fs/afs/yfsclient.c b/fs/afs/yfsclient.c index 4e7d93ee5a08..f57c089f26ee 100644 --- a/fs/afs/yfsclient.c +++ b/fs/afs/yfsclient.c @@ -458,6 +458,7 @@ static const struct afs_call_type yfs_RXYFSFetchData64= =3D { .op =3D yfs_FS_FetchData64, .async_rx =3D afs_fetch_data_async_rx, .deliver =3D yfs_deliver_fs_fetch_data64, + .immediate_cancel =3D afs_fetch_data_immediate_cancel, .destructor =3D afs_flat_call_destructor, }; =