NFSv4.1: Use the nfs_client's rpc timeouts for backchannel
authorBenjamin Coddington <bcodding@redhat.com>
Thu, 4 Jan 2024 14:58:46 +0000 (09:58 -0500)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Thu, 4 Jan 2024 22:01:01 +0000 (17:01 -0500)
For backchannel requests that lookup the appropriate nfs_client, use the
state-management rpc_clnt's rpc_timeout parameters for the backchannel's
response.  When the nfs_client cannot be found, fall back to using the
xprt's default timeout parameters.

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
Tested-by: Chuck Lever <chuck.lever@oracle.com>
Tested-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
fs/nfs/callback_xdr.c
include/linux/sunrpc/bc_xprt.h
include/linux/sunrpc/sched.h
include/linux/sunrpc/svc.h
include/linux/sunrpc/xprt.h
net/sunrpc/clnt.c
net/sunrpc/svc.c
net/sunrpc/xprt.c

index 321af81c456e2a6e68462bc683f2973d58dc4687..9369488f2ed453068b19bd505801c1debb811af1 100644 (file)
@@ -967,6 +967,11 @@ static __be32 nfs4_callback_compound(struct svc_rqst *rqstp)
                nops--;
        }
 
+       if (svc_is_backchannel(rqstp) && cps.clp) {
+               rqstp->bc_to_initval = cps.clp->cl_rpcclient->cl_timeout->to_initval;
+               rqstp->bc_to_retries = cps.clp->cl_rpcclient->cl_timeout->to_retries;
+       }
+
        *hdr_res.status = status;
        *hdr_res.nops = htonl(nops);
        nfs4_cb_free_slot(&cps);
index db30a159f9d5f5bc9620c2831e42adacb2798997..f22bf915dcf6e6e52740251ee292d0b2a147b794 100644 (file)
@@ -20,7 +20,8 @@
 #ifdef CONFIG_SUNRPC_BACKCHANNEL
 struct rpc_rqst *xprt_lookup_bc_request(struct rpc_xprt *xprt, __be32 xid);
 void xprt_complete_bc_request(struct rpc_rqst *req, uint32_t copied);
-void xprt_init_bc_request(struct rpc_rqst *req, struct rpc_task *task);
+void xprt_init_bc_request(struct rpc_rqst *req, struct rpc_task *task,
+               const struct rpc_timeout *to);
 void xprt_free_bc_request(struct rpc_rqst *req);
 int xprt_setup_backchannel(struct rpc_xprt *, unsigned int min_reqs);
 void xprt_destroy_backchannel(struct rpc_xprt *, unsigned int max_reqs);
index 8ada7dc802d3050790cc4ed3e2c38dbf3bc8efe3..2d61987b354564d4b227e2f4f5ad676ca014814a 100644 (file)
@@ -37,6 +37,17 @@ struct rpc_wait {
        struct list_head        timer_list;     /* Timer list */
 };
 
+/*
+ * This describes a timeout strategy
+ */
+struct rpc_timeout {
+       unsigned long           to_initval,             /* initial timeout */
+                               to_maxval,              /* max timeout */
+                               to_increment;           /* if !exponential */
+       unsigned int            to_retries;             /* max # of retries */
+       unsigned char           to_exponential;
+};
+
 /*
  * This is the RPC task struct
  */
@@ -205,7 +216,8 @@ struct rpc_wait_queue {
  */
 struct rpc_task *rpc_new_task(const struct rpc_task_setup *);
 struct rpc_task *rpc_run_task(const struct rpc_task_setup *);
-struct rpc_task *rpc_run_bc_task(struct rpc_rqst *req);
+struct rpc_task *rpc_run_bc_task(struct rpc_rqst *req,
+               struct rpc_timeout *timeout);
 void           rpc_put_task(struct rpc_task *);
 void           rpc_put_task_async(struct rpc_task *);
 bool           rpc_task_set_rpc_status(struct rpc_task *task, int rpc_status);
index b10f987509cc8007c508e93def6fdcd8b3a4ab72..3331a1c2b47e649a1a0e95fd377aba92abce24c5 100644 (file)
@@ -250,6 +250,8 @@ struct svc_rqst {
        struct net              *rq_bc_net;     /* pointer to backchannel's
                                                 * net namespace
                                                 */
+       unsigned long   bc_to_initval;
+       unsigned int    bc_to_retries;
        void **                 rq_lease_breaker; /* The v4 client breaking a lease */
        unsigned int            rq_status_counter; /* RPC processing counter */
 };
index f85d3a0daca26f045be8a628f7e08dc08af380f5..464f6a9492ab7e2e3b8e0e5f5edc0d4f456c6636 100644 (file)
 #define RPC_MAXCWND(xprt)      ((xprt)->max_reqs << RPC_CWNDSHIFT)
 #define RPCXPRT_CONGESTED(xprt) ((xprt)->cong >= (xprt)->cwnd)
 
-/*
- * This describes a timeout strategy
- */
-struct rpc_timeout {
-       unsigned long           to_initval,             /* initial timeout */
-                               to_maxval,              /* max timeout */
-                               to_increment;           /* if !exponential */
-       unsigned int            to_retries;             /* max # of retries */
-       unsigned char           to_exponential;
-};
-
 enum rpc_display_format_t {
        RPC_DISPLAY_ADDR = 0,
        RPC_DISPLAY_PORT,
index 0b2c4b5484f58a9bb5fafce70f58bd1e2b260110..19437b15ffc7bf0acd0a60a0a441556fd34f6004 100644 (file)
@@ -1311,8 +1311,10 @@ static void call_bc_encode(struct rpc_task *task);
  * rpc_run_bc_task - Allocate a new RPC task for backchannel use, then run
  * rpc_execute against it
  * @req: RPC request
+ * @timeout: timeout values to use for this task
  */
-struct rpc_task *rpc_run_bc_task(struct rpc_rqst *req)
+struct rpc_task *rpc_run_bc_task(struct rpc_rqst *req,
+               struct rpc_timeout *timeout)
 {
        struct rpc_task *task;
        struct rpc_task_setup task_setup_data = {
@@ -1331,7 +1333,7 @@ struct rpc_task *rpc_run_bc_task(struct rpc_rqst *req)
                return task;
        }
 
-       xprt_init_bc_request(req, task);
+       xprt_init_bc_request(req, task, timeout);
 
        task->tk_action = call_bc_encode;
        atomic_inc(&task->tk_count);
index 3f2ea7a0496fdc520a498fe9dd3af0eafcc75c98..3f714d33624be31d3408ec52e1bc1ea860d50ef1 100644 (file)
@@ -1557,6 +1557,7 @@ void svc_process_bc(struct rpc_rqst *req, struct svc_rqst *rqstp)
 {
        struct rpc_task *task;
        int proc_error;
+       struct rpc_timeout timeout;
 
        /* Build the svc_rqst used by the common processing routine */
        rqstp->rq_xid = req->rq_xid;
@@ -1602,8 +1603,16 @@ void svc_process_bc(struct rpc_rqst *req, struct svc_rqst *rqstp)
                return;
        }
        /* Finally, send the reply synchronously */
+       if (rqstp->bc_to_initval > 0) {
+               timeout.to_initval = rqstp->bc_to_initval;
+               timeout.to_retries = rqstp->bc_to_initval;
+       } else {
+               timeout.to_initval = req->rq_xprt->timeout->to_initval;
+               timeout.to_initval = req->rq_xprt->timeout->to_retries;
+       }
        memcpy(&req->rq_snd_buf, &rqstp->rq_res, sizeof(req->rq_snd_buf));
-       task = rpc_run_bc_task(req);
+       task = rpc_run_bc_task(req, &timeout);
+
        if (IS_ERR(task))
                return;
 
index 6cc9ffac962d2039a3fe2426ecf44f0475ec414d..af13fdfa6672146daf1b572aa29a8d4bd3731b1d 100644 (file)
@@ -1986,7 +1986,8 @@ void xprt_release(struct rpc_task *task)
 
 #ifdef CONFIG_SUNRPC_BACKCHANNEL
 void
-xprt_init_bc_request(struct rpc_rqst *req, struct rpc_task *task)
+xprt_init_bc_request(struct rpc_rqst *req, struct rpc_task *task,
+               const struct rpc_timeout *to)
 {
        struct xdr_buf *xbufp = &req->rq_snd_buf;
 
@@ -1999,8 +2000,13 @@ xprt_init_bc_request(struct rpc_rqst *req, struct rpc_task *task)
         */
        xbufp->len = xbufp->head[0].iov_len + xbufp->page_len +
                xbufp->tail[0].iov_len;
-
-       xprt_init_majortimeo(task, req, req->rq_xprt->timeout);
+       /*
+        * Backchannel Replies are sent with !RPC_TASK_SOFT and
+        * RPC_TASK_NO_RETRANS_TIMEOUT. The major timeout setting
+        * affects only how long each Reply waits to be sent when
+        * a transport connection cannot be established.
+        */
+       xprt_init_majortimeo(task, req, to);
 }
 #endif