xprtrdma: Retire the connection generation when a connect attempt fails
Subsystems (4)
PATCH 1/1 xprtrdma: Retire the connection generation when a connect attempt fails
When a connect attempt fails, xprt_rdma_connect_worker() wakes the tasks waiting on the transport with the connect error. For errors such as -ECONNREFUSED, call_connect_status() can then call xprt_conditional_disconnect() with the task's rq_connect_cookie, which was copied from xprt->connect_cookie when the task started waiting for the connection.
The failure path tears down the endpoint through rpcrdma_xprt_disconnect() without advancing connect_cookie, so that cookie still matches and the conditional disconnect requests an autoclose. If another task has already started the next connect attempt, that attempt holds XPRT_LOCKED and the close request sets XPRT_CLOSE_WAIT. When the attempt succeeds and releases the lock, the pending autoclose tears down the newly established connection.
This was observed on 7.4-rc3 after restarting the NFS service on a pNFS data server reached over RDMA. Connect attempts made while the server was not yet listening were rejected, and the first connections that then succeeded were closed within a millisecond of being established.
Advance connect_cookie after cleaning up a failed connect attempt and before waking its waiters, so that their conditional disconnects no longer match.
Also wake pending tasks before releasing the connect lock. Otherwise, a task can capture the updated cookie and join the pending queue for the next attempt before the previous attempt's error is delivered.
--- net/sunrpc/xprtrdma/transport.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/sunrpc/xprtrdma/transport.c +4 -2
@@ -239,10 +239,12 @@ xprt_rdma_connect_worker(struct work_struct *work) xprt->stat.connect_start;xprt_set_connected (xprt); rc = -EAGAIN ; - }else + }else {rpcrdma_xprt_disconnect (r_xprt); -xprt_unlock_connect (xprt, r_xprt); + xprt->connect_cookie++; + }xprt_wake_pending_tasks (xprt, rc); +xprt_unlock_connect (xprt, r_xprt);current_restore_flags (pflags,PF_MEMALLOC ); }
base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
Signature · 1 line
2.53.0