@@ -78,6 +78,7 @@ static void rpcrdma_mrs_create(struct rpcrdma_xprt *r_xprt);
7878static void rpcrdma_mrs_destroy (struct rpcrdma_buffer * buf );
7979static int rpcrdma_create_rep (struct rpcrdma_xprt * r_xprt , bool temp );
8080static void rpcrdma_dma_unmap_regbuf (struct rpcrdma_regbuf * rb );
81+ static void rpcrdma_post_recvs (struct rpcrdma_xprt * r_xprt , bool temp );
8182
8283struct workqueue_struct * rpcrdma_receive_wq __read_mostly ;
8384
@@ -189,11 +190,13 @@ rpcrdma_wc_receive(struct ib_cq *cq, struct ib_wc *wc)
189190 struct ib_cqe * cqe = wc -> wr_cqe ;
190191 struct rpcrdma_rep * rep = container_of (cqe , struct rpcrdma_rep ,
191192 rr_cqe );
193+ struct rpcrdma_xprt * r_xprt = rep -> rr_rxprt ;
192194
193- /* WARNING: Only wr_id and status are reliable at this point */
195+ /* WARNING: Only wr_cqe and status are reliable at this point */
194196 trace_xprtrdma_wc_receive (wc );
197+ -- r_xprt -> rx_ep .rep_receive_count ;
195198 if (wc -> status != IB_WC_SUCCESS )
196- goto out_fail ;
199+ goto out_flushed ;
197200
198201 /* status == SUCCESS means all fields in wc are trustworthy */
199202 rpcrdma_set_xdrlen (& rep -> rr_hdrbuf , wc -> byte_len );
@@ -204,17 +207,16 @@ rpcrdma_wc_receive(struct ib_cq *cq, struct ib_wc *wc)
204207 rdmab_addr (rep -> rr_rdmabuf ),
205208 wc -> byte_len , DMA_FROM_DEVICE );
206209
207- out_schedule :
210+ rpcrdma_post_recvs ( r_xprt , false);
208211 rpcrdma_reply_handler (rep );
209212 return ;
210213
211- out_fail :
214+ out_flushed :
212215 if (wc -> status != IB_WC_WR_FLUSH_ERR )
213216 pr_err ("rpcrdma: Recv: %s (%u/0x%x)\n" ,
214217 ib_wc_status_msg (wc -> status ),
215218 wc -> status , wc -> vendor_err );
216- rpcrdma_set_xdrlen (& rep -> rr_hdrbuf , 0 );
217- goto out_schedule ;
219+ rpcrdma_recv_buffer_put (rep );
218220}
219221
220222static void
@@ -581,6 +583,7 @@ rpcrdma_ep_create(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia,
581583 init_waitqueue_head (& ep -> rep_connect_wait );
582584 INIT_DELAYED_WORK (& ep -> rep_disconnect_worker ,
583585 rpcrdma_disconnect_worker );
586+ ep -> rep_receive_count = 0 ;
584587
585588 sendcq = ib_alloc_cq (ia -> ri_device , NULL ,
586589 ep -> rep_attr .cap .max_send_wr + 1 ,
@@ -1174,7 +1177,6 @@ rpcrdma_buffer_create(struct rpcrdma_xprt *r_xprt)
11741177 }
11751178
11761179 buf -> rb_credits = 1 ;
1177- buf -> rb_posted_receives = 0 ;
11781180 INIT_LIST_HEAD (& buf -> rb_recv_bufs );
11791181
11801182 rc = rpcrdma_sendctxs_create (r_xprt );
@@ -1511,25 +1513,20 @@ rpcrdma_ep_post(struct rpcrdma_ia *ia,
15111513 return 0 ;
15121514}
15131515
1514- /**
1515- * rpcrdma_post_recvs - Maybe post some Receive buffers
1516- * @r_xprt: controlling transport
1517- * @temp: when true, allocate temp rpcrdma_rep objects
1518- *
1519- */
1520- void
1516+ static void
15211517rpcrdma_post_recvs (struct rpcrdma_xprt * r_xprt , bool temp )
15221518{
15231519 struct rpcrdma_buffer * buf = & r_xprt -> rx_buf ;
1520+ struct rpcrdma_ep * ep = & r_xprt -> rx_ep ;
15241521 struct ib_recv_wr * wr , * bad_wr ;
15251522 int needed , count , rc ;
15261523
15271524 rc = 0 ;
15281525 count = 0 ;
15291526 needed = buf -> rb_credits + (buf -> rb_bc_srv_max_requests << 1 );
1530- if (buf -> rb_posted_receives > needed )
1527+ if (ep -> rep_receive_count > needed )
15311528 goto out ;
1532- needed -= buf -> rb_posted_receives ;
1529+ needed -= ep -> rep_receive_count ;
15331530
15341531 count = 0 ;
15351532 wr = NULL ;
@@ -1577,7 +1574,7 @@ rpcrdma_post_recvs(struct rpcrdma_xprt *r_xprt, bool temp)
15771574 -- count ;
15781575 }
15791576 }
1580- buf -> rb_posted_receives += count ;
1577+ ep -> rep_receive_count += count ;
15811578out :
15821579 trace_xprtrdma_post_recvs (r_xprt , count , rc );
15831580}
0 commit comments