Skip to content

Commit cb586de

Browse files
chuckleveramschuma-ntap
authored andcommitted
xprtrdma: Make sendctx queue lifetime the same as connection lifetime
The size of the sendctx queue depends on the value stored in ia->ri_max_send_sges. This value is determined by querying the underlying device. Eventually, rpcrdma_ia_open() and rpcrdma_ep_create() will be called in the connect worker rather than at transport set-up time. The underlying device will not have been chosen device set-up time. The sendctx queue will thus have to be created after the underlying device has been chosen via address and route resolution; in other words, in the connect worker. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
1 parent 2e87036 commit cb586de

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

include/trace/events/rpcrdma.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,7 @@ TRACE_EVENT(xprtrdma_post_send,
729729

730730
TP_STRUCT__entry(
731731
__field(const void *, req)
732+
__field(const void *, sc)
732733
__field(unsigned int, task_id)
733734
__field(unsigned int, client_id)
734735
__field(int, num_sge)
@@ -743,14 +744,15 @@ TRACE_EVENT(xprtrdma_post_send,
743744
__entry->client_id = rqst->rq_task->tk_client ?
744745
rqst->rq_task->tk_client->cl_clid : -1;
745746
__entry->req = req;
747+
__entry->sc = req->rl_sendctx;
746748
__entry->num_sge = req->rl_wr.num_sge;
747749
__entry->signaled = req->rl_wr.send_flags & IB_SEND_SIGNALED;
748750
__entry->status = status;
749751
),
750752

751-
TP_printk("task:%u@%u req=%p (%d SGE%s) %sstatus=%d",
753+
TP_printk("task:%u@%u req=%p sc=%p (%d SGE%s) %sstatus=%d",
752754
__entry->task_id, __entry->client_id,
753-
__entry->req, __entry->num_sge,
755+
__entry->req, __entry->sc, __entry->num_sge,
754756
(__entry->num_sge == 1 ? "" : "s"),
755757
(__entry->signaled ? "signaled " : ""),
756758
__entry->status
@@ -849,20 +851,22 @@ TRACE_EVENT(xprtrdma_wc_send,
849851

850852
TP_STRUCT__entry(
851853
__field(const void *, req)
854+
__field(const void *, sc)
852855
__field(unsigned int, unmap_count)
853856
__field(unsigned int, status)
854857
__field(unsigned int, vendor_err)
855858
),
856859

857860
TP_fast_assign(
858861
__entry->req = sc->sc_req;
862+
__entry->sc = sc;
859863
__entry->unmap_count = sc->sc_unmap_count;
860864
__entry->status = wc->status;
861865
__entry->vendor_err = __entry->status ? wc->vendor_err : 0;
862866
),
863867

864-
TP_printk("req=%p, unmapped %u pages: %s (%u/0x%x)",
865-
__entry->req, __entry->unmap_count,
868+
TP_printk("req=%p sc=%p unmapped=%u: %s (%u/0x%x)",
869+
__entry->req, __entry->sc, __entry->unmap_count,
866870
rdma_show_wc_status(__entry->status),
867871
__entry->status, __entry->vendor_err
868872
)

net/sunrpc/xprtrdma/verbs.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@
7474
/*
7575
* internal functions
7676
*/
77+
static int rpcrdma_sendctxs_create(struct rpcrdma_xprt *r_xprt);
78+
static void rpcrdma_sendctxs_destroy(struct rpcrdma_xprt *r_xprt);
7779
static void rpcrdma_sendctx_put_locked(struct rpcrdma_xprt *r_xprt,
7880
struct rpcrdma_sendctx *sc);
7981
static void rpcrdma_reqs_reset(struct rpcrdma_xprt *r_xprt);
@@ -428,6 +430,7 @@ rpcrdma_ia_remove(struct rpcrdma_ia *ia)
428430
rpcrdma_regbuf_dma_unmap(req->rl_recvbuf);
429431
}
430432
rpcrdma_mrs_destroy(r_xprt);
433+
rpcrdma_sendctxs_destroy(r_xprt);
431434
ib_dealloc_pd(ia->ri_pd);
432435
ia->ri_pd = NULL;
433436

@@ -705,6 +708,10 @@ rpcrdma_ep_connect(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia)
705708
rpcrdma_reset_cwnd(r_xprt);
706709
rpcrdma_post_recvs(r_xprt, true);
707710

711+
rc = rpcrdma_sendctxs_create(r_xprt);
712+
if (rc)
713+
goto out;
714+
708715
rc = rdma_connect(ia->ri_id, &ep->rep_remote_cma);
709716
if (rc)
710717
goto out;
@@ -757,6 +764,7 @@ rpcrdma_ep_disconnect(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia)
757764
rpcrdma_xprt_drain(r_xprt);
758765
rpcrdma_reqs_reset(r_xprt);
759766
rpcrdma_mrs_destroy(r_xprt);
767+
rpcrdma_sendctxs_destroy(r_xprt);
760768
}
761769

762770
/* Fixed-size circular FIFO queue. This implementation is wait-free and
@@ -776,13 +784,17 @@ rpcrdma_ep_disconnect(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia)
776784
* queue activity, and rpcrdma_xprt_drain has flushed all remaining
777785
* Send requests.
778786
*/
779-
static void rpcrdma_sendctxs_destroy(struct rpcrdma_buffer *buf)
787+
static void rpcrdma_sendctxs_destroy(struct rpcrdma_xprt *r_xprt)
780788
{
789+
struct rpcrdma_buffer *buf = &r_xprt->rx_buf;
781790
unsigned long i;
782791

792+
if (!buf->rb_sc_ctxs)
793+
return;
783794
for (i = 0; i <= buf->rb_sc_last; i++)
784795
kfree(buf->rb_sc_ctxs[i]);
785796
kfree(buf->rb_sc_ctxs);
797+
buf->rb_sc_ctxs = NULL;
786798
}
787799

788800
static struct rpcrdma_sendctx *rpcrdma_sendctx_create(struct rpcrdma_ep *ep)
@@ -810,7 +822,6 @@ static int rpcrdma_sendctxs_create(struct rpcrdma_xprt *r_xprt)
810822
* Sends are posted.
811823
*/
812824
i = buf->rb_max_requests + RPCRDMA_MAX_BC_REQUESTS;
813-
dprintk("RPC: %s: allocating %lu send_ctxs\n", __func__, i);
814825
buf->rb_sc_ctxs = kcalloc(i, sizeof(sc), GFP_KERNEL);
815826
if (!buf->rb_sc_ctxs)
816827
return -ENOMEM;
@@ -824,6 +835,8 @@ static int rpcrdma_sendctxs_create(struct rpcrdma_xprt *r_xprt)
824835
buf->rb_sc_ctxs[i] = sc;
825836
}
826837

838+
buf->rb_sc_head = 0;
839+
buf->rb_sc_tail = 0;
827840
return 0;
828841
}
829842

@@ -1166,10 +1179,6 @@ int rpcrdma_buffer_create(struct rpcrdma_xprt *r_xprt)
11661179

11671180
init_llist_head(&buf->rb_free_reps);
11681181

1169-
rc = rpcrdma_sendctxs_create(r_xprt);
1170-
if (rc)
1171-
goto out;
1172-
11731182
return 0;
11741183
out:
11751184
rpcrdma_buffer_destroy(buf);
@@ -1245,7 +1254,6 @@ static void rpcrdma_mrs_destroy(struct rpcrdma_xprt *r_xprt)
12451254
void
12461255
rpcrdma_buffer_destroy(struct rpcrdma_buffer *buf)
12471256
{
1248-
rpcrdma_sendctxs_destroy(buf);
12491257
rpcrdma_reps_destroy(buf);
12501258

12511259
while (!list_empty(&buf->rb_send_bufs)) {

0 commit comments

Comments
 (0)