Article View: linux.kernel.netdev
Article #11483Re: [PATCH v2 1/2] SUNRPC: add request-scoped disconnects when cancelling tasks
From: Trond Myklebust
Date: Thu, 05 Nov 2026 03:14
Date: Thu, 05 Nov 2026 03:14
90 lines
11171 bytes
11171 bytes
On Thu, 2026-11-05 at 02:02 +0000, tmenninger@purestorage.com wrote:
> From: Tim Menninger <tmenninger@everpuredata.com>
>
> rpc_cancel_tasks() allows callers to cancel a selected set of RPC
> tasks,
> but callers that also need to tear down the connection currently have
> to
> disconnect at the rpc_clnt level.
>
> That is broader than necessary for clients with multiple transports.
> A
> cancelled request is associated with a specific rpc_xprt and records
> the
> connection generation on which it was transmitted in
> rq_connect_cookie.
>
> Add rpc_cancel_tasks_and_disconnect() to cancel matching tasks and
> mark
> matching requests that remain on the transport transmit or receive
> queues
> for conditional transport disconnect when the request is released.
>
> Store the disconnect indication in struct rpc_rqst rather than struct
> rpc_task. An RPC task can release one request and later acquire
> another,
> so task-scoped state could otherwise be consumed by a successor
> request
> and disconnect the wrong transport generation.
>
> After cancelling matching tasks, walk the client's transports and
> mark
> matching requests belonging to that client that remain on the
> transmit
> or receive queues. An rpc_xprt may be shared by multiple rpc_clnt
> instances, so requests belonging to other clients are left untouched.
>
> When a marked request is released, use xprt_conditional_disconnect()
> with
> its saved rq_connect_cookie. This disconnects the transport only if
> it is
> still using the same connection generation on which the request was
> sent,
> and leaves a replacement connection untouched.
>
> Requests that were never transmitted do not require a disconnect.
>
I'm all for optimising where it makes sense, however this is adding
another spinlock protected section in xprt_release() for something that
is clearly a rare corner case.
So how about something like the following change instead?
8<---------------------------------------------------------------
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
index 7fe8b91fa47c..42b0b04de659 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.c
+++ b/fs/nfs/flexfilelayout/flexfilelayout.c
@@ -2459,6 +2459,12 @@ static bool ff_layout_match_io(const struct rpc_task *task, const void *data)
return false;
}
+static bool ff_layout_match_untransmitted_io(const struct rpc_task *task,
+ const void *data)
+{
+ return !RPC_WAS_SENT(task) && ff_layout_match_io(task, data);
+}
+
static void ff_layout_cancel_io(struct pnfs_layout_segment *lseg)
{
struct nfs4_ff_layout_segment *flseg = FF_LAYOUT_LSEG(lseg);
@@ -2484,6 +2490,9 @@ static void ff_layout_cancel_io(struct pnfs_layout_segment *lseg)
clnt = ds_clp->cl_rpcclient;
if (!clnt)
continue;
+ rpc_cancel_tasks(clnt, -ECANCELED,
+ ff_layout_match_untransmitted_io,
+ lseg);
if (!rpc_cancel_tasks(clnt, -ECANCELED,
ff_layout_match_io, lseg))
continue;
--
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trondmy@kernel.org, trond.myklebust@hammerspace.com
Technical Details
Message-ID:
<681354cdb85b67410793908d9aa4ee37a06408d2.camel@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-357042-linux-kernel-netdev=dewy.ruReferences:
<20261105020249.2607367-1-tmenninger@purestorage.com> <20261105020249.2607367-2-tmenninger@purestorage.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-357042-linux-kernel-netdev=dewy.ru From: trondmy@kernel.org (Trond Myklebust) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH v2 1/2] SUNRPC: add request-scoped disconnects when cancelling tasks Date: Wed, 04 Nov 2026 22:14:47 -0500 Organization: Usenet Network Message-ID: <681354cdb85b67410793908d9aa4ee37a06408d2.camel@kernel.org> References: <20261105020249.2607367-1-tmenninger@purestorage.com> <20261105020249.2607367-2-tmenninger@purestorage.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: usenet.network; logging-data="3555132"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:25hObN9JBvDWotyPtv3QXqtwRfE= sha256:6quf52u6i0FEG6ESpJ0rTsh8XPm6qo0pP6V0w6wSfw4= sha1:FnggTdcHVyGs+gRVA2lrPbpuP2E= sha256:dP1odyMomgvixD6dfTp4v6/KsUpXx+TQKr2H/N6nSOU= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 59B44112E87; Thu, 5 Nov 2026 06:53:52 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nMZ1BFfHX4cS; Thu, 5 Nov 2026 06:53:49 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-357042-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id E5B30112E6C; Thu, 5 Nov 2026 06:53:38 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 19B8BC6D42; Thu, 5 Nov 2026 03:14:59 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1793848491; b=zJ8o6sy1eyZs44sQ7YXLABQo1cOtVg3uEfiGwDZNgrV7GMZsDfDqAa34huTFpK1Vy7T0 83WNZEhw4ccMkdIBl9ZfzO3WH08zrh2kbEkqwIZODUiHhUdUPFBjN3Ob2QStRyCyNz4tt ko1kN97PZYu8a6OhiB4fDy5/Mu+Fg6NAK7ZaiafsZsEim87meQq5k7deM4T4wh9XJ75tS 9eZW4wma01erAWwxGlLp17t+OkXiy9hKbY2SxC/jDxgB2FolTbeX4V0fYL+K50ngJttbj l2mI0Wa9VqCVqkLPZm4dl9xXBKNUkCSNKmE5AQ+b/Fg8nzc+6GomrET29nw7Kxs78tw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793848491; h=X-Original-To:Received:Received:DKIM-Signature:Message-ID:Subject: From:To:Cc:Date:In-Reply-To:References:Content-Type: Content-Transfer-Encoding:User-Agent:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version; bh=e+ufwWTqe/yOyThkZLCwuXirSaPEZ6SPf/o4r9Bdnd0=; b=Wgx6kUwoBSOI09sHlTpIAmYkK9yKWTVCVtBq2jOVVYUopxbSXNOPMmNZGtBeDdmNTD6e SiNLiUi5K2c3fFYgVOOUdgumitOZOTtAFdMjgSX76bp1draORUtTOs4GB5LOnXrFtFPCt 8tiT2KzRpUfZMNEz4WBkGNz5iV/fifJ3IqzsfDV2euLPPc6E8GXBcH0f/3W/Eg6S/hm1N 419Ahs6E6a2F1crWGq/fJMVtUZ3pSG7d8ZGjaX34on13uAatl22KuXKFjX3wtuG4a9VGD b0B1LXgO2bLnbILyQSLAPuxrGeB+iR3Wd7nkbc9yHTsbWAyGuTbqZ6sgyanh/Plh0oA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=M7InAYm7; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 07757606D807; Thu, 5 Nov 2026 03:14:51 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=M7InAYm7 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793848490; b=SArVxdUlmlpGUb0BqO5KTCLkC4x1xslWcfbQfGJACl65pi/ydpjPSZerS8Bq6WFaQfHL bSD3SJE/LQcCLUXl3gCwTdYEqNdxEAMoj/Gpx9H9V6uDQ8Bt1hjmxArsnz+IbIOxFOLy2 ul77skfpxwZrU5FiEIp18nUjo4/+AwYOx9Si7mdcSOzAFKhBorchPnYWZTG6612wg+VnV OlN+6KPKyK5Kd5TsOE3DpFR21qWsG5Fb93InsndSFL+ytM/ZLmDd39WBe0WyI8YF3K92b 9Rgs7gxZxK9orzqajHm5a0XO7XzjaRdbEDG2OCxneKHSkwJ6XUktmwcAUyI52WOW2dw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793848490; h=Received:DKIM-Signature:Message-ID:Subject:From:To:Cc:Date: In-Reply-To:References:Content-Type:Content-Transfer-Encoding: User-Agent:MIME-Version; bh=e+ufwWTqe/yOyThkZLCwuXirSaPEZ6SPf/o4r9Bdnd0=; b=0yljwcw6gMd/EytNlhWC3RtXVQtrc3YHT5xcyqLTI86vupghqFrP86K7XTTIofOyLKsP I9ika3uCOxvamZwU//t68nryc4XOoHzyPJTzv4+vbOoFEMUcIMRuW4bmAMejtrN+lwWKT lQmdp/gzXt8trmjVFp9O5Aih6zYd1w0Zua7t5eoDYfLohp1YXtxgLrdevpfbeM9gHKEaK Uh+ONHeaXbtJA7CvbzpdfQ4e46+Qa5mzHYdAGM1Wud7KSLbeRkmE3HckjlYVsT8WXTxYV 7I89+DP0gxth7R55gM6Rj3grwCD0W58LJ+1rR72YCcy5BUV4dC36jwnlCunvPZ5+CjQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=M7InAYm7; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD149606A332; Thu, 5 Nov 2026 03:14:49 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A7391F00919; Thu, 5 Nov 2026 03:14:48 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793848489; bh=e+ufwWTqe/yOyThkZLCwuXirSaPEZ6SPf/o4r9Bdnd0=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=M7InAYm77dKIVcWYkI0QwI4a5poNlKZD2yypYJkz0tsN5gwC5SnYQgy/LJqVD8aIN GLSCxtg85siA7dVYl/qNRIGtD33W7voYPdNSEOvBFNT4LCIwWjLYDiL5p9nOodqvkA 2/2ci4WaYUb/yOdSDQI3wvp2EWHuHtD/UtAr8KMzx18dzp/GxLZcoHexHDpW4ODP0G uqUQNpXvLLLE/1/tylT2hmErAqzHSuu7PQ0dTaRwcvixj2tVSPIPl9p5I40qZPurzt V6TDYJKDTpi55vIxqkcIjB6MGWztQfryfjy8VD/v1fHAqaUYXMv11kOTTzLuQH8DBU u4+aZ5cFclBtw== X-Cc: cel@kernel.org, ebadger@everpuredata.com, jcurley@everpuredata.com, jlayton@kernel.org, linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, netdev@vger.kernel.org, slingappa@everpuredata.com, Tim Menninger <tmenninger@everpuredata.com> X-In-Reply-To: <20261105020249.2607367-2-tmenninger@purestorage.com> X-User-Agent: Evolution 3.62.1 (3.62.1-1.fc45) X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list