Skip to content

Commit fc709d8

Browse files
committed
svcrdma: Fix retry loop in svc_rdma_send()
Don't call ib_post_send() at all if the transport is already shutting down. Signed-off-by: Chuck Lever <[email protected]>
1 parent 773f6c5 commit fc709d8

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

net/sunrpc/xprtrdma/svc_rdma_sendto.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,9 @@ static void svc_rdma_wc_send(struct ib_cq *cq, struct ib_wc *wc)
320320
* that these values remain available after the ib_post_send() call.
321321
* In some error flow cases, svc_rdma_wc_send() releases @ctxt.
322322
*
323-
* Returns zero if the Send WR was posted successfully. Otherwise, a
324-
* negative errno is returned.
323+
* Return values:
324+
* %0: @ctxt's WR chain was posted successfully
325+
* %-ENOTCONN: The connection was lost
325326
*/
326327
int svc_rdma_send(struct svcxprt_rdma *rdma, struct svc_rdma_send_ctxt *ctxt)
327328
{
@@ -338,30 +339,35 @@ int svc_rdma_send(struct svcxprt_rdma *rdma, struct svc_rdma_send_ctxt *ctxt)
338339
DMA_TO_DEVICE);
339340

340341
/* If the SQ is full, wait until an SQ entry is available */
341-
while (1) {
342+
while (!test_bit(XPT_CLOSE, &rdma->sc_xprt.xpt_flags)) {
342343
if ((atomic_dec_return(&rdma->sc_sq_avail) < 0)) {
343344
svc_rdma_wake_send_waiters(rdma, 1);
345+
346+
/* When the transport is torn down, assume
347+
* ib_drain_sq() will trigger enough Send
348+
* completions to wake us. The XPT_CLOSE test
349+
* above should then cause the while loop to
350+
* exit.
351+
*/
344352
percpu_counter_inc(&svcrdma_stat_sq_starve);
345353
trace_svcrdma_sq_full(rdma, &cid);
346354
wait_event(rdma->sc_send_wait,
347355
atomic_read(&rdma->sc_sq_avail) > 0);
348-
if (test_bit(XPT_CLOSE, &rdma->sc_xprt.xpt_flags))
349-
return -ENOTCONN;
350356
trace_svcrdma_sq_retry(rdma, &cid);
351357
continue;
352358
}
353359

354360
trace_svcrdma_post_send(ctxt);
355361
ret = ib_post_send(rdma->sc_qp, wr, NULL);
356-
if (ret)
362+
if (ret) {
363+
trace_svcrdma_sq_post_err(rdma, &cid, ret);
364+
svc_xprt_deferred_close(&rdma->sc_xprt);
365+
svc_rdma_wake_send_waiters(rdma, 1);
357366
break;
367+
}
358368
return 0;
359369
}
360-
361-
trace_svcrdma_sq_post_err(rdma, &cid, ret);
362-
svc_xprt_deferred_close(&rdma->sc_xprt);
363-
svc_rdma_wake_send_waiters(rdma, 1);
364-
return ret;
370+
return -ENOTCONN;
365371
}
366372

367373
/**

0 commit comments

Comments
 (0)