From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796386032; b=i8ZJ6IYOamUQ9GzCq14CEWy8xCfC+Nmx1dfKm8qgWdlBtUweDnebadTglZU9qzOGJFpw uC0JBRs4Lnm6dQG+fZa5comIC9w9LOROqyS962S+X4FHD0K4raETqwGkj+sGHgzbSGujz zcCSBLP18UfVi/zWnpSWK/yV+MLHMLGX5Ui1w5rc4EHEybGNyOcO4iDwVCJsWvKXusEwe JAAi6X6Dnhh8ffCusFAgt+Jy0ytr9UoR6k74cpkN80UW7ZBG2LfKy6/ukmtOgFKJAu70n EBCBFvTpssGNyvWFEmib2U3QksLBC/h6OQ9SWEHwjGfzETFWq93+DhKztjrSelxsDXA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386032; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=OM6co2CBBDmdhGM8XjX7qMd6UqkZ/QlHJKE+JkJvBpY=; b=Ph0IOXvXv6AMpiWvMQcU4lxpaqstoWp6+do3TVtu9ZxyUTEUiIzFypdHNemXACHqGDjH xy2XameJEVwdOnuyxL6o/qFHhBp9dcBHJ9Fjjzt2Ub4uPynKytYTpUR/NWiH7TeE1b5Q4 M/yduLIHxRhy8zAtD5qireApBqeb4Xvg3mMuyRgb+SZt0rU6JQY5U8ywvk3VsMiM/2UD7 kY559Y0/NheoGCYBYe4uOAFF1KHjjEoOknhexydAyJQszk+zzTdd/KzkxG+NEhdN7uo4g kOUvKPQgY8M0K8wQ/XqZwAalAHNIKb76k6hbAuRfTWkM1gA3TqYQHM0DYNuKcN2yWuw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=15L+4reD; arc=none smtp.remote-ip=100.103.45.18 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 344A1606A322; Fri, 4 Dec 2026 12:07:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=15L+4reD Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9FEEB1F000C2; Fri, 4 Dec 2026 12:07:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796386032; bh=OM6co2CBBDmdhGM8XjX7qMd6UqkZ/QlHJKE+JkJvBpY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=15L+4reDNKavzqJiV/jLW94ToqUi32fzMc4FqFuI+bisZicPgf8JDfHoajhGDdQfj ifYK9iHRf2P0cMocKT+6xp79YmE/DNQpEyX+QGNYVjQYhCRxJ9t1YYpmgz8gUVd2IP 8rVvrr0Axppu6i9a+V55dswoWhJsalTUfENJnGQo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Tim Menninger , Anna Schumaker , Sasha Levin Subject: [PATCH 6.6 0796/1167] pNFS: avoid repeatedly cancelling I/O for the same lseg Date: Fri, 4 Dec 2026 19:03:43 +0900 Message-ID: <20261204100722.858388393@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tim Menninger [ Upstream commit 9e28836b480c66cca4c3d391177f5b3a50927f7d ] Commit b739a5bd9d9f ("NFSv4/flexfiles: Cancel I/O if the layout is recalled or revoked") added I/O cancellation when a layout segment is invalidated while outstanding references remain. The invalid segment stays on the layout's segment list until those references drain. Subsequent scans can find it again and repeatedly invoke the layout driver's cancel_io() callback. For flexfiles, this cancels matching RPC tasks and disconnects data server RPC clients. During RPC/RDMA data server recovery, repeated cancellation can cause a reconnect loop that consumes essentially all client CPU and prevents forward progress. Record cancellation requests per mirror stripe in the flexfiles layout segment. Each stripe is cancelled at most once, regardless of how many times the invalid segment is encountered. A per-stripe bitmap rather than a single per-segment bit preserves the ability to cancel I/O to a different device after an earlier device-specific cancellation. Cancellation is best-effort. An RPC that has already passed the layout-validity check may not yet be visible to the cancellation scan. Such I/O retains its lseg reference and remains subject to the normal RPC completion and recovery paths. Suppress repeated cancellation and disconnect requests without changing the existing lseg lifetime and deferred layout-return accounting. This reproduced on 6.8.0, 7.0.0, and 7.4.0-rc1. It was tested on 7.4.0-rc1 with sustained pNFS/flexfiles I/O over RPC/RDMA while restarting the NFS service on a data server. Without it, repeated cancellation led to a reconnect loop and no workload recovery. With it, the client recovered after the data server returned. Fixes: b739a5bd9d9f ("NFSv4/flexfiles: Cancel I/O if the layout is recalled or revoked") Cc: stable@vger.kernel.org Signed-off-by: Tim Menninger Signed-off-by: Anna Schumaker [ sashal: Adapted to a tree without striping or device-specific cancel: the bitmap has one bit per mirror (sized by mirror_array_cnt, indexed by idx) instead of per mirror stripe. ] Signed-off-by: Sasha Levin --- fs/nfs/flexfilelayout/flexfilelayout.c | 11 +++++++++++ fs/nfs/flexfilelayout/flexfilelayout.h | 1 + 2 files changed, 12 insertions(+) diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c index c6bc831b95413..841b916f9515a 100644 --- a/fs/nfs/flexfilelayout/flexfilelayout.c +++ b/fs/nfs/flexfilelayout/flexfilelayout.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -267,6 +268,7 @@ static void _ff_layout_free_lseg(struct nfs4_ff_layout_segment *fls) { if (fls) { ff_layout_free_mirror_array(fls); + bitmap_free(fls->cancelled_stripes); kfree(fls); } } @@ -553,6 +555,12 @@ ff_layout_alloc_lseg(struct pnfs_layout_hdr *lh, fls->mirror_array[i]->report_interval = be32_to_cpup(p); out_sort_mirrors: + fls->cancelled_stripes = bitmap_zalloc(fls->mirror_array_cnt, + gfp_flags); + if (!fls->cancelled_stripes) { + rc = -ENOMEM; + goto out_err_free; + } ff_layout_sort_mirrors(fls); ret = &fls->generic_hdr; dprintk("<-- %s (success)\n", __func__); @@ -2201,6 +2209,9 @@ static void ff_layout_cancel_io(struct pnfs_layout_segment *lseg) for (idx = 0; idx < flseg->mirror_array_cnt; idx++) { mirror = flseg->mirror_array[idx]; + /* Do not cancel a stripe again while this lseg drains. */ + if (test_and_set_bit(idx, flseg->cancelled_stripes)) + continue; mirror_ds = mirror->mirror_ds; if (IS_ERR_OR_NULL(mirror_ds)) continue; diff --git a/fs/nfs/flexfilelayout/flexfilelayout.h b/fs/nfs/flexfilelayout/flexfilelayout.h index 1d4294c6a7ec4..4757aa633d1ea 100644 --- a/fs/nfs/flexfilelayout/flexfilelayout.h +++ b/fs/nfs/flexfilelayout/flexfilelayout.h @@ -99,6 +99,7 @@ struct nfs4_ff_layout_segment { u64 stripe_unit; u32 flags; u32 mirror_array_cnt; + unsigned long *cancelled_stripes; struct nfs4_ff_layout_mirror *mirror_array[]; }; -- 2.53.0