SUNRPC: Use __alloc_bulk_pages() in svc_init_buffer()

Clean up: Use the bulk page allocator when filling a server thread's
buffer page array.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
This commit is contained in:
Chuck Lever 2023-05-15 09:47:36 -04:00
parent 5f7fc5d69f
commit 88e4d41a26
1 changed files with 7 additions and 16 deletions

View File

@ -597,34 +597,25 @@ svc_destroy(struct kref *ref)
} }
EXPORT_SYMBOL_GPL(svc_destroy); EXPORT_SYMBOL_GPL(svc_destroy);
/* static bool
* Allocate an RPC server's buffer space.
* We allocate pages and place them in rq_pages.
*/
static int
svc_init_buffer(struct svc_rqst *rqstp, unsigned int size, int node) svc_init_buffer(struct svc_rqst *rqstp, unsigned int size, int node)
{ {
unsigned int pages, arghi; unsigned long pages, ret;
/* bc_xprt uses fore channel allocated buffers */ /* bc_xprt uses fore channel allocated buffers */
if (svc_is_backchannel(rqstp)) if (svc_is_backchannel(rqstp))
return 1; return true;
pages = size / PAGE_SIZE + 1; /* extra page as we hold both request and reply. pages = size / PAGE_SIZE + 1; /* extra page as we hold both request and reply.
* We assume one is at most one page * We assume one is at most one page
*/ */
arghi = 0;
WARN_ON_ONCE(pages > RPCSVC_MAXPAGES); WARN_ON_ONCE(pages > RPCSVC_MAXPAGES);
if (pages > RPCSVC_MAXPAGES) if (pages > RPCSVC_MAXPAGES)
pages = RPCSVC_MAXPAGES; pages = RPCSVC_MAXPAGES;
while (pages) {
struct page *p = alloc_pages_node(node, GFP_KERNEL, 0); ret = alloc_pages_bulk_array_node(GFP_KERNEL, node, pages,
if (!p) rqstp->rq_pages);
break; return ret == pages;
rqstp->rq_pages[arghi++] = p;
pages--;
}
return pages == 0;
} }
/* /*