Skip to content

Commit b20cb39

Browse files
committed
SUNRPC: Relocate svc_free_res_pages()
Clean-up: There doesn't seem to be a reason why this function is stuck in a header. One thing it prevents is the convenient addition of tracing. Moving it to a source file also makes the rq_respages clean-up logic easier to find. Reviewed-by: Calum Mackay <calum.mackay@oracle.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 92e4a67 commit b20cb39

3 files changed

Lines changed: 21 additions & 12 deletions

File tree

include/linux/sunrpc/svc.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -309,17 +309,6 @@ static inline struct sockaddr *svc_daddr(const struct svc_rqst *rqst)
309309
return (struct sockaddr *) &rqst->rq_daddr;
310310
}
311311

312-
static inline void svc_free_res_pages(struct svc_rqst *rqstp)
313-
{
314-
while (rqstp->rq_next_page != rqstp->rq_respages) {
315-
struct page **pp = --rqstp->rq_next_page;
316-
if (*pp) {
317-
put_page(*pp);
318-
*pp = NULL;
319-
}
320-
}
321-
}
322-
323312
struct svc_deferred_req {
324313
u32 prot; /* protocol (UDP or TCP) */
325314
struct svc_xprt *xprt;
@@ -424,6 +413,7 @@ struct svc_rqst *svc_rqst_alloc(struct svc_serv *serv,
424413
struct svc_pool *pool, int node);
425414
bool svc_rqst_replace_page(struct svc_rqst *rqstp,
426415
struct page *page);
416+
void svc_rqst_release_pages(struct svc_rqst *rqstp);
427417
void svc_rqst_free(struct svc_rqst *);
428418
void svc_exit_thread(struct svc_rqst *);
429419
struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int,

net/sunrpc/svc.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,25 @@ bool svc_rqst_replace_page(struct svc_rqst *rqstp, struct page *page)
869869
}
870870
EXPORT_SYMBOL_GPL(svc_rqst_replace_page);
871871

872+
/**
873+
* svc_rqst_release_pages - Release Reply buffer pages
874+
* @rqstp: RPC transaction context
875+
*
876+
* Release response pages that might still be in flight after
877+
* svc_send, and any spliced filesystem-owned pages.
878+
*/
879+
void svc_rqst_release_pages(struct svc_rqst *rqstp)
880+
{
881+
while (rqstp->rq_next_page != rqstp->rq_respages) {
882+
struct page **pp = --rqstp->rq_next_page;
883+
884+
if (*pp) {
885+
put_page(*pp);
886+
*pp = NULL;
887+
}
888+
}
889+
}
890+
872891
/*
873892
* Called from a server thread as it's exiting. Caller must hold the "service
874893
* mutex" for the service.

net/sunrpc/svc_xprt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ static void svc_xprt_release(struct svc_rqst *rqstp)
542542
rqstp->rq_deferred = NULL;
543543

544544
pagevec_release(&rqstp->rq_pvec);
545-
svc_free_res_pages(rqstp);
545+
svc_rqst_release_pages(rqstp);
546546
rqstp->rq_res.page_len = 0;
547547
rqstp->rq_res.page_base = 0;
548548

0 commit comments

Comments
 (0)