Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

SUNRPC: Handle NULL entries in svc_rqst_release_pages

svc_rqst_release_pages() releases response pages between rq_respages
and rq_next_page. It currently passes the entire range to
release_pages(), which does not expect NULL entries.

A subsequent patch preserves the rq_next_page pointer in
svc_rdma_save_io_pages() so that it accurately records how many
response pages were consumed. After that change, the range

[rq_respages, rq_next_page)

can contain NULL entries where pages have already been transferred
to a send context.

Iterate through the range entry by entry, skipping NULLs, to handle
this case correctly.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>

+13 -7
+13 -7
net/sunrpc/svc.c
··· 990 990 * svc_rqst_release_pages - Release Reply buffer pages 991 991 * @rqstp: RPC transaction context 992 992 * 993 - * Release response pages that might still be in flight after 994 - * svc_send, and any spliced filesystem-owned pages. 993 + * Release response pages in the range [rq_respages, rq_next_page). 994 + * NULL entries in this range are skipped, allowing transports to 995 + * transfer pages to a send context before this function runs. 995 996 */ 996 997 void svc_rqst_release_pages(struct svc_rqst *rqstp) 997 998 { 998 - int i, count = rqstp->rq_next_page - rqstp->rq_respages; 999 + struct page **pp; 999 1000 1000 - if (count) { 1001 - release_pages(rqstp->rq_respages, count); 1002 - for (i = 0; i < count; i++) 1003 - rqstp->rq_respages[i] = NULL; 1001 + for (pp = rqstp->rq_respages; pp < rqstp->rq_next_page; pp++) { 1002 + if (*pp) { 1003 + if (!folio_batch_add(&rqstp->rq_fbatch, 1004 + page_folio(*pp))) 1005 + __folio_batch_release(&rqstp->rq_fbatch); 1006 + *pp = NULL; 1007 + } 1004 1008 } 1009 + if (rqstp->rq_fbatch.nr) 1010 + __folio_batch_release(&rqstp->rq_fbatch); 1005 1011 } 1006 1012 1007 1013 /**