FAILED: patch "[PATCH] xprtrdma: prevent disconnect feedback during endpoint teardown" failed to apply to 5.10-stable tree
Subsystems (4)
Sasha Levin
maintainerThe patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x 0b5bb4e586f7b0a449f4d90a524f76a3be5db355
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From 0b5bb4e586f7b0a449f4d90a524f76a3be5db355 Mon Sep 17 00:00:00 2001
From: Tim Menninger <[email protected]>
Date: Thu, 24 Sep 2026 20:34:40 +0000
Subject: [PATCH] xprtrdma: prevent disconnect feedback during endpoint
teardown
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.
--- net/sunrpc/xprtrdma/verbs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
net/sunrpc/xprtrdma/verbs.c +6 -3
@@ -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) {
@@ -587,6 +587,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);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/2 xprtrdma: Remove the RPC/RDMA QP event handler
From: Chuck Lever <[email protected]>
[ Upstream commit e1648eb23d839bd4b9f2999296d5e81dcd93311f ]
Clean up: The handler only recorded a trace event. If indeed no action is needed by the RPC/RDMA consumer, then the event can be ignored.
Stable-dep-of: 0b5bb4e586f7 ("xprtrdma: prevent disconnect feedback during endpoint teardown")
--- include/trace/events/rpcrdma.h | 32 -------------------------------- net/sunrpc/xprtrdma/verbs.c | 18 ------------------ 2 files changed, 50 deletions(-)
include/trace/events/rpcrdma.h +0 -32
@@ -485,38 +485,6 @@ TRACE_EVENT(xprtrdma_op_set_cto, ) ); -TRACE_EVENT (xprtrdma_qp_event, -TP_PROTO ( - const struct rpcrdma_ep *ep, - const struct ib_event *event - ), - -TP_ARGS (ep, event), - -TP_STRUCT__entry ( - __field(unsigned long, event) - __string(name, event->device->name) - __array(unsigned char, srcaddr, sizeof(struct sockaddr_in6)) - __array(unsigned char, dstaddr, sizeof(struct sockaddr_in6)) - ), - -TP_fast_assign ( - const struct rdma_cm_id *id = ep->re_id; - - __entry->event = event->event; - __assign_str(name, event->device->name); - memcpy(__entry->srcaddr, &id->route.addr.src_addr, - sizeof(struct sockaddr_in6)); -memcpy (__entry->dstaddr, &id->route.addr.dst_addr, - sizeof(struct sockaddr_in6)); - ), - -TP_printk ("%pISpc -> %pISpc device=%s %s (%lu)" , - __entry->srcaddr, __entry->dstaddr,__get_str (name), -rdma_show_ib_event (__entry->event), __entry->event - ) -); -/** ** Call events **/
net/sunrpc/xprtrdma/verbs.c +0 -18
@@ -114,22 +114,6 @@ static void rpcrdma_xprt_drain(struct rpcrdma_xprt *r_xprt)rpcrdma_ep_put (ep); } -/** -* rpcrdma_qp_event_handler - Handle one QP event (error notification) -* @event: details of the event -* @context: ep that owns QP where event occurred -* -* Called from the RDMA provider (device driver) possibly in an interrupt -* context. The QP is always destroyed before the ID, so the ID will be -* reliably available when this handler is invoked. -*/ -static void rpcrdma_qp_event_handler (struct ib_event *event,void *context) -{ -struct rpcrdma_ep *ep = context; - -trace_xprtrdma_qp_event (ep, event); -} -/* 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).
@@ -428,8 +412,6 @@ static int rpcrdma_ep_create(struct rpcrdma_xprt *r_xprt) r_xprt->rx_buf.rb_max_requests =cpu_to_be32 (ep->re_max_requests); - ep->re_attr.event_handler = rpcrdma_qp_event_handler; - ep->re_attr.qp_context = ep; ep->re_attr.srq =NULL ; ep->re_attr.cap.max_inline_data =0 ; ep->re_attr.sq_sig_type =IB_SIGNAL_REQ_WR ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/2 xprtrdma: prevent disconnect feedback during endpoint teardown
From: Tim Menninger <[email protected]>
[ 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.
--- net/sunrpc/xprtrdma/verbs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
net/sunrpc/xprtrdma/verbs.c +6 -3
@@ -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. */ static void rpcrdma_force_disconnect (struct rpcrdma_ep *ep) {
@@ -576,6 +576,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);
Signature · 1 line
2.53.0