Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
* [PATCH v2 0/3] rpcrdma: Fix device removal races and endpoint cleanup
@ 2026-11-03  3:27 Li Xiasong
  2026-11-03  3:27 ` [PATCH v2 1/3] rpcrdma: Serialize notification registration with device removal Li Xiasong
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Li Xiasong @ 2026-11-03  3:27 UTC (permalink / raw)
  To: Chuck Lever, Jeff Layton, NeilBrown, Olga Kornievskaia, Dai Ngo,
	Tom Talpey, Trond Myklebust, Anna Schumaker
  Cc: linux-nfs, linux-rdma, stable, yuehaibing, zhangchangzhong,
	weiyongjun1

This series fixes races and endpoint cleanup issues in the RPC-over-RDMA
device removal paths.

Notification registration is not serialized with device removal. Removal
can free the per-device private data while registration is still using it,
or finish walking the notification array before a new registration is
published. In addition, the notification walk does not hold references to
the objects containing the notifications, allowing concurrent unregister
and teardown to free an object before its removal callback is invoked.

On the client side, the device removal callback only forces a transport
disconnect. A connect worker waiting for re_connect_status to change can
remain asleep, preventing endpoint cleanup. Removal that races with
connection establishment can also be overwritten by a late ESTABLISHED
event, and releasing the endpoint from a removal callback or address
change can free its CM ID context before CMA has stopped dispatching
events to it.

Patch 1 serializes notification registration with the transition to device
removal and protects access to the per-device private data.

Patch 2 uses the same mutex to serialize notification reference acquisition
with unregister, and holds references across each removal callback. Each
notification records the references it acquires, so a partially completed
acquisition can be unwound without touching a freed owner or blocking on
XPRT_LOCKED under the device mutex. The client endpoint pin also takes a
reference on the RPC transport. Callbacks and reference release run outside
the mutex to allow teardown to unregister notifications.

Patch 3 records device removal in the endpoint connection status and wakes
a waiting connect worker. Atomic state transitions ensure the first path to
leave the established state forces a disconnect exactly once. It drops the
connection-management callback get/put pairs and destroys the CM ID in the
endpoint destructor, before freeing its context, so that active and future
callbacks are fenced. It also handles connection establishment racing with
removal.

The patches are ordered by dependency: patch 2 uses the serialization
introduced by patch 1, and patch 3 relies on the callback lifetime
protection added by patch 2.

Changes since v1:
- Pin the client RPC transport alongside the endpoint owner, and track
  acquired references separately so a partial acquisition can be unwound
  without accessing a freed owner or waiting for XPRT_LOCKED under the
  device mutex.
- Add kernel-doc for the new get/put callbacks and Context: sections to
  the notification registration interfaces.
- Rework client endpoint lifetime: remove the connection-management
  callback get/put pairs and destroy the CM ID in the endpoint destructor
  before freeing its context, closing the use-after-free window on
  teardown.
- Give UNREACHABLE and REJECTED the same atomic status handling as
  ADDR_CHANGE so a transition on an established connection forces a
  disconnect exactly once.
- Link to v1: https://lore.kernel.org/all/20261023125033.528835-1-lixiasong1@huawei.com/

Li Xiasong (3):
  rpcrdma: Serialize notification registration with device removal
  rpcrdma: Pin notifications during removal callbacks
  xprtrdma: Wake connect worker on device removal

 include/linux/sunrpc/rdma_rn.h           |  29 +++++-
 net/sunrpc/xprtrdma/ib_client.c          |  84 +++++++++++++++--
 net/sunrpc/xprtrdma/svc_rdma_transport.c |  21 ++++-
 net/sunrpc/xprtrdma/verbs.c              | 114 ++++++++++++++++-------
 4 files changed, 203 insertions(+), 45 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-11-03 22:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-03  3:27 [PATCH v2 0/3] rpcrdma: Fix device removal races and endpoint cleanup Li Xiasong
2026-11-03  3:27 ` [PATCH v2 1/3] rpcrdma: Serialize notification registration with device removal Li Xiasong
2026-11-03  3:16   ` sashiko-bot
2026-11-03 22:06   ` Chuck Lever
2026-11-03  3:27 ` [PATCH v2 2/3] rpcrdma: Pin notifications during removal callbacks Li Xiasong
2026-11-03  3:21   ` sashiko-bot
2026-11-03 22:06   ` Chuck Lever
2026-11-03  3:27 ` [PATCH v2 3/3] xprtrdma: Wake connect worker on device removal Li Xiasong
2026-11-03  3:30   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox