@@ -213,6 +213,7 @@ struct svc_rdma_send_ctxt *svc_rdma_send_ctxt_get(struct svcxprt_rdma *rdma)
213
213
214
214
ctxt -> sc_send_wr .num_sge = 0 ;
215
215
ctxt -> sc_cur_sge_no = 0 ;
216
+ ctxt -> sc_page_count = 0 ;
216
217
return ctxt ;
217
218
218
219
out_empty :
@@ -227,13 +228,18 @@ struct svc_rdma_send_ctxt *svc_rdma_send_ctxt_get(struct svcxprt_rdma *rdma)
227
228
* svc_rdma_send_ctxt_put - Return send_ctxt to free list
228
229
* @rdma: controlling svcxprt_rdma
229
230
* @ctxt: object to return to the free list
231
+ *
232
+ * Pages left in sc_pages are DMA unmapped and released.
230
233
*/
231
234
void svc_rdma_send_ctxt_put (struct svcxprt_rdma * rdma ,
232
235
struct svc_rdma_send_ctxt * ctxt )
233
236
{
234
237
struct ib_device * device = rdma -> sc_cm_id -> device ;
235
238
unsigned int i ;
236
239
240
+ for (i = 0 ; i < ctxt -> sc_page_count ; ++ i )
241
+ put_page (ctxt -> sc_pages [i ]);
242
+
237
243
/* The first SGE contains the transport header, which
238
244
* remains mapped until @ctxt is destroyed.
239
245
*/
@@ -798,6 +804,25 @@ int svc_rdma_map_reply_msg(struct svcxprt_rdma *rdma,
798
804
svc_rdma_xb_dma_map , & args );
799
805
}
800
806
807
+ /* The svc_rqst and all resources it owns are released as soon as
808
+ * svc_rdma_sendto returns. Transfer pages under I/O to the ctxt
809
+ * so they are released by the Send completion handler.
810
+ */
811
+ static inline void svc_rdma_save_io_pages (struct svc_rqst * rqstp ,
812
+ struct svc_rdma_send_ctxt * ctxt )
813
+ {
814
+ int i , pages = rqstp -> rq_next_page - rqstp -> rq_respages ;
815
+
816
+ ctxt -> sc_page_count += pages ;
817
+ for (i = 0 ; i < pages ; i ++ ) {
818
+ ctxt -> sc_pages [i ] = rqstp -> rq_respages [i ];
819
+ rqstp -> rq_respages [i ] = NULL ;
820
+ }
821
+
822
+ /* Prevent svc_xprt_release from releasing pages in rq_pages */
823
+ rqstp -> rq_next_page = rqstp -> rq_respages ;
824
+ }
825
+
801
826
/* Prepare the portion of the RPC Reply that will be transmitted
802
827
* via RDMA Send. The RPC-over-RDMA transport header is prepared
803
828
* in sc_sges[0], and the RPC xdr_buf is prepared in following sges.
0 commit comments