Skip to content

Commit 0a26d10

Browse files
chuckleverTrond Myklebust
authored andcommitted
xprtrdma: Move fr_cid to struct rpcrdma_mr
Clean up (for several purposes): - The MR's cid is initialized sooner so that tracepoints can show something reasonable even if the MR is never posted. - The MR's res.id doesn't change so the cid won't change either. Initializing the cid once is sufficient. - struct rpcrdma_frwr is going away soon. Signed-off-by: Chuck Lever <[email protected]> Signed-off-by: Trond Myklebust <[email protected]>
1 parent e1648eb commit 0a26d10

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

net/sunrpc/xprtrdma/frwr_ops.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@
4949
# define RPCDBG_FACILITY RPCDBG_TRANS
5050
#endif
5151

52+
static void frwr_cid_init(struct rpcrdma_ep *ep,
53+
struct rpcrdma_mr *mr)
54+
{
55+
struct rpc_rdma_cid *cid = &mr->mr_cid;
56+
57+
cid->ci_queue_id = ep->re_attr.send_cq->res.id;
58+
cid->ci_completion_id = mr->frwr.fr_mr->res.id;
59+
}
60+
5261
static void frwr_mr_unmap(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr *mr)
5362
{
5463
if (mr->mr_device) {
@@ -134,6 +143,7 @@ int frwr_mr_init(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr *mr)
134143
mr->mr_device = NULL;
135144
INIT_LIST_HEAD(&mr->mr_list);
136145
init_completion(&mr->frwr.fr_linv_done);
146+
frwr_cid_init(ep, mr);
137147

138148
sg_init_table(sg, depth);
139149
mr->mr_sg = sg;
@@ -358,22 +368,14 @@ static void frwr_wc_fastreg(struct ib_cq *cq, struct ib_wc *wc)
358368
struct ib_cqe *cqe = wc->wr_cqe;
359369
struct rpcrdma_frwr *frwr =
360370
container_of(cqe, struct rpcrdma_frwr, fr_cqe);
371+
struct rpcrdma_mr *mr = container_of(frwr, struct rpcrdma_mr, frwr);
361372

362373
/* WARNING: Only wr_cqe and status are reliable at this point */
363-
trace_xprtrdma_wc_fastreg(wc, &frwr->fr_cid);
374+
trace_xprtrdma_wc_fastreg(wc, &mr->mr_cid);
364375

365376
rpcrdma_flush_disconnect(cq->cq_context, wc);
366377
}
367378

368-
static void frwr_cid_init(struct rpcrdma_ep *ep,
369-
struct rpcrdma_frwr *frwr)
370-
{
371-
struct rpc_rdma_cid *cid = &frwr->fr_cid;
372-
373-
cid->ci_queue_id = ep->re_attr.send_cq->res.id;
374-
cid->ci_completion_id = frwr->fr_mr->res.id;
375-
}
376-
377379
/**
378380
* frwr_send - post Send WRs containing the RPC Call message
379381
* @r_xprt: controlling transport instance
@@ -404,7 +406,6 @@ int frwr_send(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req)
404406
frwr = &mr->frwr;
405407

406408
frwr->fr_cqe.done = frwr_wc_fastreg;
407-
frwr_cid_init(ep, frwr);
408409
frwr->fr_regwr.wr.next = post_wr;
409410
frwr->fr_regwr.wr.wr_cqe = &frwr->fr_cqe;
410411
frwr->fr_regwr.wr.num_sge = 0;
@@ -467,7 +468,7 @@ static void frwr_wc_localinv(struct ib_cq *cq, struct ib_wc *wc)
467468
struct rpcrdma_mr *mr = container_of(frwr, struct rpcrdma_mr, frwr);
468469

469470
/* WARNING: Only wr_cqe and status are reliable at this point */
470-
trace_xprtrdma_wc_li(wc, &frwr->fr_cid);
471+
trace_xprtrdma_wc_li(wc, &mr->mr_cid);
471472
frwr_mr_done(wc, mr);
472473

473474
rpcrdma_flush_disconnect(cq->cq_context, wc);
@@ -488,7 +489,7 @@ static void frwr_wc_localinv_wake(struct ib_cq *cq, struct ib_wc *wc)
488489
struct rpcrdma_mr *mr = container_of(frwr, struct rpcrdma_mr, frwr);
489490

490491
/* WARNING: Only wr_cqe and status are reliable at this point */
491-
trace_xprtrdma_wc_li_wake(wc, &frwr->fr_cid);
492+
trace_xprtrdma_wc_li_wake(wc, &mr->mr_cid);
492493
frwr_mr_done(wc, mr);
493494
complete(&frwr->fr_linv_done);
494495

@@ -529,7 +530,6 @@ void frwr_unmap_sync(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req)
529530

530531
frwr = &mr->frwr;
531532
frwr->fr_cqe.done = frwr_wc_localinv;
532-
frwr_cid_init(ep, frwr);
533533
last = &frwr->fr_invwr;
534534
last->next = NULL;
535535
last->wr_cqe = &frwr->fr_cqe;
@@ -585,7 +585,7 @@ static void frwr_wc_localinv_done(struct ib_cq *cq, struct ib_wc *wc)
585585
struct rpcrdma_rep *rep;
586586

587587
/* WARNING: Only wr_cqe and status are reliable at this point */
588-
trace_xprtrdma_wc_li_done(wc, &frwr->fr_cid);
588+
trace_xprtrdma_wc_li_done(wc, &mr->mr_cid);
589589

590590
/* Ensure that @rep is generated before the MR is released */
591591
rep = mr->mr_req->rl_reply;
@@ -631,7 +631,6 @@ void frwr_unmap_async(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req)
631631

632632
frwr = &mr->frwr;
633633
frwr->fr_cqe.done = frwr_wc_localinv;
634-
frwr_cid_init(ep, frwr);
635634
last = &frwr->fr_invwr;
636635
last->next = NULL;
637636
last->wr_cqe = &frwr->fr_cqe;

net/sunrpc/xprtrdma/xprt_rdma.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ struct rpcrdma_sendctx {
232232
struct rpcrdma_frwr {
233233
struct ib_mr *fr_mr;
234234
struct ib_cqe fr_cqe;
235-
struct rpc_rdma_cid fr_cid;
236235
struct completion fr_linv_done;
237236
union {
238237
struct ib_reg_wr fr_regwr;
@@ -254,6 +253,7 @@ struct rpcrdma_mr {
254253
u32 mr_length;
255254
u64 mr_offset;
256255
struct list_head mr_all;
256+
struct rpc_rdma_cid mr_cid;
257257
};
258258

259259
/*

0 commit comments

Comments
 (0)