linux/include/linux/sunrpc
Chuck Lever e5248a7426 svcrdma: wake sq waiters when the transport closes
Threads parked in svc_rdma_sq_wait() on sc_sq_ticket_wait or
sc_send_wait can hang indefinitely in TASK_UNINTERRUPTIBLE state
across transport teardown, pinning svc_xprt references and
blocking svc_rdma_free().

The close path sets XPT_CLOSE before invoking xpo_detach and both
wait_event predicates include an XPT_CLOSE term, but the
predicates are re-evaluated only on wakeup. sc_sq_ticket_wait has
no completion-driven wake path; it is advanced solely by the
chained ticket handoff inside svc_rdma_sq_wait() itself. Without
an explicit wake at close, parked threads never observe
XPT_CLOSE, hold their svc_xprt_get reference forever, and
svc_rdma_free() blocks on xpt_ref dropping to zero.

Two close entry points reach this transport. Local teardown runs
svc_rdma_detach() from svc_handle_xprt() -> svc_delete_xprt() ->
xpo_detach() on a worker thread. A remote disconnect arrives at
svc_rdma_cma_handler(), which calls svc_xprt_deferred_close():
that sets XPT_CLOSE and enqueues the transport but does not
access either RDMA waitqueue, so a worker already parked in
svc_rdma_sq_wait() never re-evaluates its predicate. With every
worker parked on this transport, no thread is available to run
the local teardown either, and the wake site there is
unreachable.

Introduce svc_rdma_xprt_deferred_close(), a thin svcrdma wrapper
that calls svc_xprt_deferred_close() and then wakes both
sc_sq_ticket_wait and sc_send_wait. Convert the svcrdma producers
that called svc_xprt_deferred_close() directly:
svc_rdma_cma_handler(), qp_event_handler(),
svc_rdma_post_send_err(), svc_rdma_wc_send(), the sendto drop
path, the rw completion error paths, and the recvfrom flush and
read-list error paths.

Wake both waitqueues from svc_rdma_detach() as well. The
synchronous svc_xprt_close() path (backchannel ENOTCONN, device
removal via svc_rdma_xprt_done) reaches detach without flowing
through svc_xprt_deferred_close() and therefore does not invoke
the new helper.

Fixes: ccc89b9d1e ("svcrdma: Add fair queuing for Send Queue access")
Cc: stable@vger.kernel.org
Assisted-by: kres (claude-opus-4-7)
Signed-off-by: Chris Mason <clm@meta.com>
[ cel: add svc_rdma_xprt_deferred_close() to complete the fix ]
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2026-06-09 16:32:59 -04:00
..
xdrgen Documentation: Add the RPC language description of NLM version 3 2026-06-09 16:32:59 -04:00
addr.h
auth_gss.h
auth.h
bc_xprt.h SUNRPC: new helper function for stopping backchannel server 2025-11-23 15:30:12 -05:00
cache.h sunrpc: add a generic netlink family for cache upcalls 2026-06-01 11:08:18 -04:00
clnt.h
debug.h sunrpc: Fix compilation error (make W=1) when dprintk() is no-op 2026-03-29 21:25:09 -04:00
gss_api.h
gss_err.h
gss_krb5.h SUNRPC: Remove dead rpcsec_gss_krb5 definitions 2026-06-09 16:32:59 -04:00
metrics.h
msg_prot.h
rdma_rn.h
rpc_pipe_fs.h
rpc_rdma_cid.h
rpc_rdma.h
sched.h sunrpc: Fix compilation error (make W=1) when dprintk() is no-op 2026-03-29 21:25:09 -04:00
stats.h
svc_rdma_pcl.h
svc_rdma.h svcrdma: wake sq waiters when the transport closes 2026-06-09 16:32:59 -04:00
svc_xprt.h SUNRPC: Move the svc_rpcb_cleanup() call sites 2025-09-23 13:28:19 -04:00
svc.h NFSD 7.1 Release Notes 2026-04-20 10:44:02 -07:00
svcauth_gss.h
svcauth.h
svcsock.h sunrpc: allow svc_recv() to return -ETIMEDOUT and -EBUSY 2026-01-28 10:15:42 -05:00
timer.h
types.h
xdr.h SUNRPC: Return an error from xdr_buf_to_bvec() on overflow 2026-06-09 16:32:59 -04:00
xprt.h xprtrdma: Close lost-wakeup race in xprt_rdma_alloc_slot 2026-04-13 11:56:20 -07:00
xprtmultipath.h
xprtrdma.h
xprtsock.h