Skip to content

Commit a944209

Browse files
committed
SUNRPC: Revert 5799006 ("svcrdma: Remove unused sc_pages field")
Pre-requisite for releasing pages in the send completion handler. Reverted by hand: patch -R would not apply cleanly. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent 6be7afc commit a944209

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

include/linux/sunrpc/svc_rdma.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,9 @@ struct svc_rdma_send_ctxt {
158158
struct xdr_buf sc_hdrbuf;
159159
struct xdr_stream sc_stream;
160160
void *sc_xprt_buf;
161+
int sc_page_count;
161162
int sc_cur_sge_no;
162-
163+
struct page *sc_pages[RPCSVC_MAXPAGES];
163164
struct ib_sge sc_sges[];
164165
};
165166

net/sunrpc/xprtrdma/svc_rdma_sendto.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ struct svc_rdma_send_ctxt *svc_rdma_send_ctxt_get(struct svcxprt_rdma *rdma)
213213

214214
ctxt->sc_send_wr.num_sge = 0;
215215
ctxt->sc_cur_sge_no = 0;
216+
ctxt->sc_page_count = 0;
216217
return ctxt;
217218

218219
out_empty:
@@ -227,13 +228,18 @@ struct svc_rdma_send_ctxt *svc_rdma_send_ctxt_get(struct svcxprt_rdma *rdma)
227228
* svc_rdma_send_ctxt_put - Return send_ctxt to free list
228229
* @rdma: controlling svcxprt_rdma
229230
* @ctxt: object to return to the free list
231+
*
232+
* Pages left in sc_pages are DMA unmapped and released.
230233
*/
231234
void svc_rdma_send_ctxt_put(struct svcxprt_rdma *rdma,
232235
struct svc_rdma_send_ctxt *ctxt)
233236
{
234237
struct ib_device *device = rdma->sc_cm_id->device;
235238
unsigned int i;
236239

240+
for (i = 0; i < ctxt->sc_page_count; ++i)
241+
put_page(ctxt->sc_pages[i]);
242+
237243
/* The first SGE contains the transport header, which
238244
* remains mapped until @ctxt is destroyed.
239245
*/
@@ -798,6 +804,25 @@ int svc_rdma_map_reply_msg(struct svcxprt_rdma *rdma,
798804
svc_rdma_xb_dma_map, &args);
799805
}
800806

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+
801826
/* Prepare the portion of the RPC Reply that will be transmitted
802827
* via RDMA Send. The RPC-over-RDMA transport header is prepared
803828
* in sc_sges[0], and the RPC xdr_buf is prepared in following sges.

0 commit comments

Comments
 (0)