Commit c487eb7d authored by Chuck Lever's avatar Chuck Lever Committed by Anna Schumaker

xprtrdma: Clean up disconnect

1. Ensure that only rpcrdma_cm_event_handler() modifies
   ep->re_connect_status to avoid racy changes to that field.

2. Ensure that xprt_force_disconnect() is invoked only once as a
   transport is closed or destroyed.
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
parent f423f755
...@@ -130,6 +130,16 @@ static void rpcrdma_qp_event_handler(struct ib_event *event, void *context) ...@@ -130,6 +130,16 @@ static void rpcrdma_qp_event_handler(struct ib_event *event, void *context)
trace_xprtrdma_qp_event(ep, event); 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).
*/
static void rpcrdma_force_disconnect(struct rpcrdma_ep *ep)
{
if (atomic_add_unless(&ep->re_force_disconnect, 1, 1))
xprt_force_disconnect(ep->re_xprt);
}
/** /**
* rpcrdma_flush_disconnect - Disconnect on flushed completion * rpcrdma_flush_disconnect - Disconnect on flushed completion
* @r_xprt: transport to disconnect * @r_xprt: transport to disconnect
...@@ -139,13 +149,8 @@ static void rpcrdma_qp_event_handler(struct ib_event *event, void *context) ...@@ -139,13 +149,8 @@ static void rpcrdma_qp_event_handler(struct ib_event *event, void *context)
*/ */
void rpcrdma_flush_disconnect(struct rpcrdma_xprt *r_xprt, struct ib_wc *wc) void rpcrdma_flush_disconnect(struct rpcrdma_xprt *r_xprt, struct ib_wc *wc)
{ {
struct rpc_xprt *xprt = &r_xprt->rx_xprt; if (wc->status != IB_WC_SUCCESS)
rpcrdma_force_disconnect(r_xprt->rx_ep);
if (wc->status != IB_WC_SUCCESS &&
r_xprt->rx_ep->re_connect_status == 1) {
r_xprt->rx_ep->re_connect_status = -ECONNABORTED;
xprt_force_disconnect(xprt);
}
} }
/** /**
...@@ -243,7 +248,6 @@ rpcrdma_cm_event_handler(struct rdma_cm_id *id, struct rdma_cm_event *event) ...@@ -243,7 +248,6 @@ rpcrdma_cm_event_handler(struct rdma_cm_id *id, struct rdma_cm_event *event)
{ {
struct sockaddr *sap = (struct sockaddr *)&id->route.addr.dst_addr; struct sockaddr *sap = (struct sockaddr *)&id->route.addr.dst_addr;
struct rpcrdma_ep *ep = id->context; struct rpcrdma_ep *ep = id->context;
struct rpc_xprt *xprt = ep->re_xprt;
might_sleep(); might_sleep();
...@@ -267,7 +271,6 @@ rpcrdma_cm_event_handler(struct rdma_cm_id *id, struct rdma_cm_event *event) ...@@ -267,7 +271,6 @@ rpcrdma_cm_event_handler(struct rdma_cm_id *id, struct rdma_cm_event *event)
/* fall through */ /* fall through */
case RDMA_CM_EVENT_ADDR_CHANGE: case RDMA_CM_EVENT_ADDR_CHANGE:
ep->re_connect_status = -ENODEV; ep->re_connect_status = -ENODEV;
xprt_force_disconnect(xprt);
goto disconnected; goto disconnected;
case RDMA_CM_EVENT_ESTABLISHED: case RDMA_CM_EVENT_ESTABLISHED:
rpcrdma_ep_get(ep); rpcrdma_ep_get(ep);
...@@ -292,7 +295,7 @@ rpcrdma_cm_event_handler(struct rdma_cm_id *id, struct rdma_cm_event *event) ...@@ -292,7 +295,7 @@ rpcrdma_cm_event_handler(struct rdma_cm_id *id, struct rdma_cm_event *event)
case RDMA_CM_EVENT_DISCONNECTED: case RDMA_CM_EVENT_DISCONNECTED:
ep->re_connect_status = -ECONNABORTED; ep->re_connect_status = -ECONNABORTED;
disconnected: disconnected:
xprt_force_disconnect(xprt); rpcrdma_force_disconnect(ep);
return rpcrdma_ep_put(ep); return rpcrdma_ep_put(ep);
default: default:
break; break;
......
...@@ -82,6 +82,7 @@ struct rpcrdma_ep { ...@@ -82,6 +82,7 @@ struct rpcrdma_ep {
unsigned int re_max_inline_recv; unsigned int re_max_inline_recv;
int re_async_rc; int re_async_rc;
int re_connect_status; int re_connect_status;
atomic_t re_force_disconnect;
struct ib_qp_init_attr re_attr; struct ib_qp_init_attr re_attr;
wait_queue_head_t re_connect_wait; wait_queue_head_t re_connect_wait;
struct rpc_xprt *re_xprt; struct rpc_xprt *re_xprt;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment