Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
* [PATCH v3 0/3] rpcrdma: Fix device removal races and endpoint cleanup
@ 2026-11-24  2:18 Li Xiasong
  2026-11-24  2:13 ` sashiko-bot
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Li Xiasong @ 2026-11-24  2:18 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. The critical
section runs in a NOIO allocation scope so reclaim cannot wait for RPC I/O
on a transport whose reconnect needs the same mutex.

Patch 2 serializes removal callbacks with unregister. Short removal
callbacks run under the device mutex, so an owner cannot be unregistered
and freed while its callback is running. Callbacks that must release a
reference do so outside the mutex through an independently owned release
callback, keeping a final transport put from waiting on a connect worker
that needs the mutex.

Patch 3 records device removal in the endpoint connection status and wakes
a waiting connect worker. Atomic state transitions give -ENODEV precedence
and force an established connection to disconnect without a late
ESTABLISHED event masking the error. 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.
Device removal during setup is translated to -ENOTCONN so pending RPCs
retry.

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 v2:
- Run the registration critical section under memalloc_noio_save()/
  memalloc_noio_restore() so the module-wide mutex is never held across
  reclaim that may wait for RPC I/O.
- Drop the rn_get/rn_put callbacks and rpcrdma_notification_ref. Removal
  callbacks now run under the device mutex (they are short and do not
  sleep), so a pinned owner is unnecessary. Transport references are moved
  back into verbs.c and svc_rdma_transport.c and released outside the
  mutex via a new rpcrdma_notification_release output parameter.
- Make rpcrdma_ep_disconnect() use a try_cmpxchg loop so a connection that
  is already established transitions to the error state and is forced to
  disconnect, instead of leaving re_connect_status at 1.
- Have RDMA_CM_EVENT_ESTABLISHED return early when the status is already
  non-zero, avoiding a forced disconnect on an unpinned transport.
- Translate the -ENODEV connection status to -ENOTCONN so pending RPCs
  retry on a hard mount when the device disappears during setup.
- Link to v2: https://lore.kernel.org/all/20261103032758.1302493-1-lixiasong1@huawei.com/

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

 include/linux/sunrpc/rdma_rn.h           |  27 ++++-
 net/sunrpc/xprtrdma/ib_client.c          |  86 +++++++++++---
 net/sunrpc/xprtrdma/svc_rdma_transport.c |  24 +++-
 net/sunrpc/xprtrdma/transport.c          |   2 +-
 net/sunrpc/xprtrdma/verbs.c              | 138 +++++++++++++++--------
 5 files changed, 208 insertions(+), 69 deletions(-)

-- 
2.34.1


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

end of thread, other threads:[~2026-11-24  2:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24  2:18 [PATCH v3 0/3] rpcrdma: Fix device removal races and endpoint cleanup Li Xiasong
2026-11-24  2:13 ` sashiko-bot
2026-11-24  2:18 ` [PATCH v3 1/3] rpcrdma: Serialize notification registration with device removal Li Xiasong
2026-11-24  2:18 ` [PATCH v3 2/3] rpcrdma: Serialize removal callbacks with unregister Li Xiasong
2026-11-24  2:18 ` [PATCH v3 3/3] xprtrdma: Wake connect worker on device removal Li Xiasong

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