Skip to content

Commit

Permalink
NFSv4: Cap the transport reconnection timer at 1/2 lease period
Browse files Browse the repository at this point in the history
We don't want to miss a lease period renewal due to the TCP connection
failing to reconnect in a timely fashion. To ensure this doesn't happen,
cap the reconnection timer so that we retry the connection attempt
at least every 1/2 lease period.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
  • Loading branch information
trondmypd committed Aug 5, 2016
1 parent fb10fb6 commit 8d48032
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fs/nfs/nfs4renewd.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ void nfs4_set_lease_period(struct nfs_client *clp,
clp->cl_lease_time = lease;
clp->cl_last_renewal = lastrenewed;
spin_unlock(&clp->cl_lock);

/* Cap maximum reconnect timeout at 1/2 lease period */
rpc_cap_max_reconnect_timeout(clp->cl_rpcclient, lease >> 1);
}

/*
Expand Down
2 changes: 2 additions & 0 deletions include/linux/sunrpc/clnt.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ int rpc_clnt_add_xprt(struct rpc_clnt *, struct xprt_create *,
struct rpc_xprt *,
void *),
void *data);
void rpc_cap_max_reconnect_timeout(struct rpc_clnt *clnt,
unsigned long timeo);

const char *rpc_proc_name(const struct rpc_task *task);
#endif /* __KERNEL__ */
Expand Down
21 changes: 21 additions & 0 deletions net/sunrpc/clnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2676,6 +2676,27 @@ int rpc_clnt_add_xprt(struct rpc_clnt *clnt,
}
EXPORT_SYMBOL_GPL(rpc_clnt_add_xprt);

static int
rpc_xprt_cap_max_reconnect_timeout(struct rpc_clnt *clnt,
struct rpc_xprt *xprt,
void *data)
{
unsigned long timeout = *((unsigned long *)data);

if (timeout < xprt->max_reconnect_timeout)
xprt->max_reconnect_timeout = timeout;
return 0;
}

void
rpc_cap_max_reconnect_timeout(struct rpc_clnt *clnt, unsigned long timeo)
{
rpc_clnt_iterate_for_each_xprt(clnt,
rpc_xprt_cap_max_reconnect_timeout,
&timeo);
}
EXPORT_SYMBOL_GPL(rpc_cap_max_reconnect_timeout);

#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
static void rpc_show_header(void)
{
Expand Down

0 comments on commit 8d48032

Please sign in to comment.