Skip to content

Commit 57331a5

Browse files
bcodding-rhamschuma-ntap
authored andcommitted
NFSv4.1: Use the nfs_client's rpc timeouts for backchannel
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>
1 parent e6f533b commit 57331a5

File tree

8 files changed

+45
-19
lines changed

8 files changed

+45
-19
lines changed

fs/nfs/callback_xdr.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,11 @@ static __be32 nfs4_callback_compound(struct svc_rqst *rqstp)
967967
nops--;
968968
}
969969

970+
if (svc_is_backchannel(rqstp) && cps.clp) {
971+
rqstp->bc_to_initval = cps.clp->cl_rpcclient->cl_timeout->to_initval;
972+
rqstp->bc_to_retries = cps.clp->cl_rpcclient->cl_timeout->to_retries;
973+
}
974+
970975
*hdr_res.status = status;
971976
*hdr_res.nops = htonl(nops);
972977
nfs4_cb_free_slot(&cps);

include/linux/sunrpc/bc_xprt.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
#ifdef CONFIG_SUNRPC_BACKCHANNEL
2121
struct rpc_rqst *xprt_lookup_bc_request(struct rpc_xprt *xprt, __be32 xid);
2222
void xprt_complete_bc_request(struct rpc_rqst *req, uint32_t copied);
23-
void xprt_init_bc_request(struct rpc_rqst *req, struct rpc_task *task);
23+
void xprt_init_bc_request(struct rpc_rqst *req, struct rpc_task *task,
24+
const struct rpc_timeout *to);
2425
void xprt_free_bc_request(struct rpc_rqst *req);
2526
int xprt_setup_backchannel(struct rpc_xprt *, unsigned int min_reqs);
2627
void xprt_destroy_backchannel(struct rpc_xprt *, unsigned int max_reqs);

include/linux/sunrpc/sched.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ struct rpc_wait {
3737
struct list_head timer_list; /* Timer list */
3838
};
3939

40+
/*
41+
* This describes a timeout strategy
42+
*/
43+
struct rpc_timeout {
44+
unsigned long to_initval, /* initial timeout */
45+
to_maxval, /* max timeout */
46+
to_increment; /* if !exponential */
47+
unsigned int to_retries; /* max # of retries */
48+
unsigned char to_exponential;
49+
};
50+
4051
/*
4152
* This is the RPC task struct
4253
*/
@@ -205,7 +216,8 @@ struct rpc_wait_queue {
205216
*/
206217
struct rpc_task *rpc_new_task(const struct rpc_task_setup *);
207218
struct rpc_task *rpc_run_task(const struct rpc_task_setup *);
208-
struct rpc_task *rpc_run_bc_task(struct rpc_rqst *req);
219+
struct rpc_task *rpc_run_bc_task(struct rpc_rqst *req,
220+
struct rpc_timeout *timeout);
209221
void rpc_put_task(struct rpc_task *);
210222
void rpc_put_task_async(struct rpc_task *);
211223
bool rpc_task_set_rpc_status(struct rpc_task *task, int rpc_status);

include/linux/sunrpc/svc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ struct svc_rqst {
250250
struct net *rq_bc_net; /* pointer to backchannel's
251251
* net namespace
252252
*/
253+
unsigned long bc_to_initval;
254+
unsigned int bc_to_retries;
253255
void ** rq_lease_breaker; /* The v4 client breaking a lease */
254256
unsigned int rq_status_counter; /* RPC processing counter */
255257
};

include/linux/sunrpc/xprt.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,6 @@
3030
#define RPC_MAXCWND(xprt) ((xprt)->max_reqs << RPC_CWNDSHIFT)
3131
#define RPCXPRT_CONGESTED(xprt) ((xprt)->cong >= (xprt)->cwnd)
3232

33-
/*
34-
* This describes a timeout strategy
35-
*/
36-
struct rpc_timeout {
37-
unsigned long to_initval, /* initial timeout */
38-
to_maxval, /* max timeout */
39-
to_increment; /* if !exponential */
40-
unsigned int to_retries; /* max # of retries */
41-
unsigned char to_exponential;
42-
};
43-
4433
enum rpc_display_format_t {
4534
RPC_DISPLAY_ADDR = 0,
4635
RPC_DISPLAY_PORT,

net/sunrpc/clnt.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,8 +1311,10 @@ static void call_bc_encode(struct rpc_task *task);
13111311
* rpc_run_bc_task - Allocate a new RPC task for backchannel use, then run
13121312
* rpc_execute against it
13131313
* @req: RPC request
1314+
* @timeout: timeout values to use for this task
13141315
*/
1315-
struct rpc_task *rpc_run_bc_task(struct rpc_rqst *req)
1316+
struct rpc_task *rpc_run_bc_task(struct rpc_rqst *req,
1317+
struct rpc_timeout *timeout)
13161318
{
13171319
struct rpc_task *task;
13181320
struct rpc_task_setup task_setup_data = {
@@ -1331,7 +1333,7 @@ struct rpc_task *rpc_run_bc_task(struct rpc_rqst *req)
13311333
return task;
13321334
}
13331335

1334-
xprt_init_bc_request(req, task);
1336+
xprt_init_bc_request(req, task, timeout);
13351337

13361338
task->tk_action = call_bc_encode;
13371339
atomic_inc(&task->tk_count);

net/sunrpc/svc.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1557,6 +1557,7 @@ void svc_process_bc(struct rpc_rqst *req, struct svc_rqst *rqstp)
15571557
{
15581558
struct rpc_task *task;
15591559
int proc_error;
1560+
struct rpc_timeout timeout;
15601561

15611562
/* Build the svc_rqst used by the common processing routine */
15621563
rqstp->rq_xid = req->rq_xid;
@@ -1602,8 +1603,16 @@ void svc_process_bc(struct rpc_rqst *req, struct svc_rqst *rqstp)
16021603
return;
16031604
}
16041605
/* Finally, send the reply synchronously */
1606+
if (rqstp->bc_to_initval > 0) {
1607+
timeout.to_initval = rqstp->bc_to_initval;
1608+
timeout.to_retries = rqstp->bc_to_initval;
1609+
} else {
1610+
timeout.to_initval = req->rq_xprt->timeout->to_initval;
1611+
timeout.to_initval = req->rq_xprt->timeout->to_retries;
1612+
}
16051613
memcpy(&req->rq_snd_buf, &rqstp->rq_res, sizeof(req->rq_snd_buf));
1606-
task = rpc_run_bc_task(req);
1614+
task = rpc_run_bc_task(req, &timeout);
1615+
16071616
if (IS_ERR(task))
16081617
return;
16091618

net/sunrpc/xprt.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,7 +1986,8 @@ void xprt_release(struct rpc_task *task)
19861986

19871987
#ifdef CONFIG_SUNRPC_BACKCHANNEL
19881988
void
1989-
xprt_init_bc_request(struct rpc_rqst *req, struct rpc_task *task)
1989+
xprt_init_bc_request(struct rpc_rqst *req, struct rpc_task *task,
1990+
const struct rpc_timeout *to)
19901991
{
19911992
struct xdr_buf *xbufp = &req->rq_snd_buf;
19921993

@@ -1999,8 +2000,13 @@ xprt_init_bc_request(struct rpc_rqst *req, struct rpc_task *task)
19992000
*/
20002001
xbufp->len = xbufp->head[0].iov_len + xbufp->page_len +
20012002
xbufp->tail[0].iov_len;
2002-
2003-
xprt_init_majortimeo(task, req, req->rq_xprt->timeout);
2003+
/*
2004+
* Backchannel Replies are sent with !RPC_TASK_SOFT and
2005+
* RPC_TASK_NO_RETRANS_TIMEOUT. The major timeout setting
2006+
* affects only how long each Reply waits to be sent when
2007+
* a transport connection cannot be established.
2008+
*/
2009+
xprt_init_majortimeo(task, req, to);
20042010
}
20052011
#endif
20062012

0 commit comments

Comments
 (0)