SUNRPC: Relocate svc_free_res_pages()
authorChuck Lever <chuck.lever@oracle.com>
Sat, 15 Apr 2023 00:17:56 +0000 (20:17 -0400)
committerChuck Lever <chuck.lever@oracle.com>
Wed, 26 Apr 2023 13:05:01 +0000 (09:05 -0400)
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>
include/linux/sunrpc/svc.h
net/sunrpc/svc.c
net/sunrpc/svc_xprt.c

index 2d31121fc2e6bb46eb343321321f1161fdf443b7..762d7231e574b737d34682aa3257ad4692519164 100644 (file)
@@ -309,17 +309,6 @@ static inline struct sockaddr *svc_daddr(const struct svc_rqst *rqst)
        return (struct sockaddr *) &rqst->rq_daddr;
 }
 
-static inline void svc_free_res_pages(struct svc_rqst *rqstp)
-{
-       while (rqstp->rq_next_page != rqstp->rq_respages) {
-               struct page **pp = --rqstp->rq_next_page;
-               if (*pp) {
-                       put_page(*pp);
-                       *pp = NULL;
-               }
-       }
-}
-
 struct svc_deferred_req {
        u32                     prot;   /* protocol (UDP or TCP) */
        struct svc_xprt         *xprt;
@@ -424,6 +413,7 @@ struct svc_rqst *svc_rqst_alloc(struct svc_serv *serv,
                                        struct svc_pool *pool, int node);
 bool              svc_rqst_replace_page(struct svc_rqst *rqstp,
                                         struct page *page);
+void              svc_rqst_release_pages(struct svc_rqst *rqstp);
 void              svc_rqst_free(struct svc_rqst *);
 void              svc_exit_thread(struct svc_rqst *);
 struct svc_serv *  svc_create_pooled(struct svc_program *, unsigned int,
index 0aa8892fad6368e34754726e0eb11771a21812a0..0fc70cc405b2e55393ad899785560458b3570f75 100644 (file)
@@ -869,6 +869,25 @@ bool svc_rqst_replace_page(struct svc_rqst *rqstp, struct page *page)
 }
 EXPORT_SYMBOL_GPL(svc_rqst_replace_page);
 
+/**
+ * svc_rqst_release_pages - Release Reply buffer pages
+ * @rqstp: RPC transaction context
+ *
+ * Release response pages that might still be in flight after
+ * svc_send, and any spliced filesystem-owned pages.
+ */
+void svc_rqst_release_pages(struct svc_rqst *rqstp)
+{
+       while (rqstp->rq_next_page != rqstp->rq_respages) {
+               struct page **pp = --rqstp->rq_next_page;
+
+               if (*pp) {
+                       put_page(*pp);
+                       *pp = NULL;
+               }
+       }
+}
+
 /*
  * Called from a server thread as it's exiting. Caller must hold the "service
  * mutex" for the service.
index 36c79b71832376963ef9b5137eceb1f9fc6c615c..533e08c4f3192c1a9cc96f46427ddb4f52efc80f 100644 (file)
@@ -542,7 +542,7 @@ static void svc_xprt_release(struct svc_rqst *rqstp)
        rqstp->rq_deferred = NULL;
 
        pagevec_release(&rqstp->rq_pvec);
-       svc_free_res_pages(rqstp);
+       svc_rqst_release_pages(rqstp);
        rqstp->rq_res.page_len = 0;
        rqstp->rq_res.page_base = 0;