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=1795045448; b=QymWq/atBfNSmbAZSz8biQhSMQCZHnoPQAIDx/FITkx/SyV1tUeM1ThmK2aD5ynvMIG9 Kd0lKjnIhLxpWD8RaLwd7ZN6Z061lkwzWfxgeTPNxAxdAD3rhTtFHyEXw/ZI7WOQOn0lc pV/Pxb1uQ0QCbxDGAkaO4B6Sh7XFkWAtt8LcpL3W4iTjOmZEH29KK6yWFhu6FxD47YT5y h69AoYDmNNkm5QZp2FB0ZATp1IOSq9cij3nHNsGkiZqafwUEEyygkNd/qDX8AIzNAcsp5 hzqwueh+DCtdxAHetH+0iBkY7dF3C9Kbv1UsRrxiRF8k6Qx19/9AAvOZJqxjfI+XcFg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795045448; 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=SvHF2w4SM3rX7CRgomfnbxunt+I0QbE44mdt9ZcjDqM=; b=ADqcIexgHYLO9QAsq+gejZaETF/2JLWdVYdyLNWr1BMSP1eAjOHLPPK7rRMD8xpqq1/3 vv78bSgxfbqeMHqkvxhQ3SKcdzkESBO7yaLGLTVHfZ/GayjpbcSU7+fTd9WSSoAaJwnLG nbbqobK3RfntfB1Z1DHZWizxj7oVWf0q9d4AmS6+c0QOTgfVd44Au5clZwF4oyIprZqII RI5t8f0sdFBr/JfDXiQo3Dhgq6DPmA7s5ugaPRef2ZfiMd14qXBpIIPjOqLMpVAD00VdT /rZIwrnRz+horuh5hLBEuBYdVxOyjGxPSm1hqnUC4OLQ5xpUWBVNR8ov5pSF9ytEGFw== 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=L3u8UJCw; 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 8C2D7606A31C; Wed, 18 Nov 2026 23:44:08 +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=L3u8UJCw Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB2861F000C4; Wed, 18 Nov 2026 23:44:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795045448; bh=SvHF2w4SM3rX7CRgomfnbxunt+I0QbE44mdt9ZcjDqM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=L3u8UJCwvj6YdgJ8Xk5R4m4pgDAi0+ZL+xxcbu1xn241ZWg4nwnqM0GBavFN/ULkM gt8NdzVb5dqaulFXZ9U44h3EqwaZ4ag60EK7OXSulJqcljXvo5P6ZhV0jicpidyDT0 uftsD4mDFNxBGW8D1EuB/OBg0TUIEHqO4lS0AUZQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Tim Menninger , Chuck Lever , Anna Schumaker , Sasha Levin Subject: [PATCH 6.1 0926/2857] xprtrdma: prevent disconnect feedback during endpoint teardown Date: Wed, 18 Nov 2026 15:32:40 +0100 Message-ID: <20261118150234.930348085@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150201.293410965@linuxfoundation.org> References: <20261118150201.293410965@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.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tim Menninger [ Upstream commit 0b5bb4e586f7b0a449f4d90a524f76a3be5db355 ] xprt_autoclose() clears XPRT_CLOSE_WAIT before invoking the transport's ->close() operation. For RPC/RDMA, ->close() calls rpcrdma_xprt_disconnect(), which disconnects the RDMA CM endpoint and drains its QP. Since commit 31e62d25b5b8 ("xprtrdma: Simplify RPC wake-ups on connect"), RDMA_CM_EVENT_DISCONNECTED requests a SUNRPC transport disconnect. Today that path, along with failed completion handling, reaches xprt_force_disconnect() through rpcrdma_force_disconnect(). Commit c487eb7d8e41 ("xprtrdma: Clean up disconnect") later added re_force_disconnect to ensure that multiple failure indications request only one SUNRPC disconnect. However, the gate remains open when SUNRPC itself begins endpoint teardown. If re_force_disconnect is still clear, either a CM disconnect event or a completion error can set XPRT_CLOSE_WAIT again while the current close is in progress. When the transport send lock is subsequently released, xprt_clear_locked() observes XPRT_CLOSE_WAIT and queues another autoclose. Requesting a disconnect this way is necessary when a connection is lost unexpectedly, but not when the event was generated by rpcrdma_xprt_disconnect() itself. In that case SUNRPC is already committed to closing the transport. Mark re_force_disconnect before initiating local endpoint teardown so that CM events and completion errors caused by that teardown cannot request another close. An unexpected error that wins the race before local endpoint teardown begins can still request a disconnect normally. Use a fully ordered exchange so that the gate is globally closed before rdma_disconnect() can transition the QP to error and generate the callbacks that the gate suppresses. In 30-second traces of a sustained recovery loop, without this change there were 7,693 xprt_force_disconnect() calls, 6,267 SUNRPC autocloses, and 172,892 receive-side IB_WC_WR_FLUSH_ERR completions. With this change, the same tracepoints recorded 3,512 xprt_force_disconnect() calls, 3,212 autocloses, and 131,287 receive-side flush completions. Thus QP teardown continues to produce flushed completions, but closing the disconnect gate before teardown substantially reduces their feedback into the SUNRPC close path. Fixes: 31e62d25b5b8 ("xprtrdma: Simplify RPC wake-ups on connect") Cc: stable@vger.kernel.org Signed-off-by: Tim Menninger Reviewed-by: Chuck Lever Signed-off-by: Anna Schumaker Signed-off-by: Sasha Levin --- net/sunrpc/xprtrdma/verbs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c index 34a3c08a82fba..6a1ed28ba3d77 100644 --- a/net/sunrpc/xprtrdma/verbs.c +++ b/net/sunrpc/xprtrdma/verbs.c @@ -114,9 +114,9 @@ static void rpcrdma_xprt_drain(struct rpcrdma_xprt *r_xprt) rpcrdma_ep_put(ep); } -/* Ensure xprt_force_disconnect() is invoked exactly once when a - * connection is closed or lost. (The important thing is it needs - * to be invoked "at least" once). +/* Ensure xprt_force_disconnect() is invoked at most once for an + * unexpected endpoint failure. Local endpoint teardown closes this + * gate before it can generate CM events and flushed completions. */ void rpcrdma_force_disconnect(struct rpcrdma_ep *ep) { @@ -574,6 +574,9 @@ void rpcrdma_xprt_disconnect(struct rpcrdma_xprt *r_xprt) if (!ep) return; + /* Prevent teardown-generated events from requesting another close. */ + atomic_xchg(&ep->re_force_disconnect, 1); + id = ep->re_id; rc = rdma_disconnect(id); trace_xprtrdma_disconnect(r_xprt, rc); -- 2.53.0