aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/xprtsock.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2013-09-24 11:25:22 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2013-10-01 18:22:10 -0400
commit7f260e8575bf53b93b77978c1e39f8e67612759c (patch)
tree7f1ddee8da8fb7b4a7c771c1e1b1c31fe223ae8a /net/sunrpc/xprtsock.c
parenta6f951ddbdfb7bd87d31a44f61abe202ed6ce57f (diff)
SUNRPC: Enable the keepalive option for TCP sockets
For NFSv4 we want to avoid retransmitting RPC calls unless the TCP connection breaks. However we still want to detect TCP connection breakage as soon as possible. Do this by setting the keepalive option with the idle timeout and count set to the 'timeo' and 'retrans' mount options. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc/xprtsock.c')
-rw-r--r--net/sunrpc/xprtsock.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index ee03d35677d9..208a7634b916 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -2112,6 +2112,19 @@ static int xs_tcp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)
2112 2112
2113 if (!transport->inet) { 2113 if (!transport->inet) {
2114 struct sock *sk = sock->sk; 2114 struct sock *sk = sock->sk;
2115 unsigned int keepidle = xprt->timeout->to_initval / HZ;
2116 unsigned int keepcnt = xprt->timeout->to_retries + 1;
2117 unsigned int opt_on = 1;
2118
2119 /* TCP Keepalive options */
2120 kernel_setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
2121 (char *)&opt_on, sizeof(opt_on));
2122 kernel_setsockopt(sock, SOL_TCP, TCP_KEEPIDLE,
2123 (char *)&keepidle, sizeof(keepidle));
2124 kernel_setsockopt(sock, SOL_TCP, TCP_KEEPINTVL,
2125 (char *)&keepidle, sizeof(keepidle));
2126 kernel_setsockopt(sock, SOL_TCP, TCP_KEEPCNT,
2127 (char *)&keepcnt, sizeof(keepcnt));
2115 2128
2116 write_lock_bh(&sk->sk_callback_lock); 2129 write_lock_bh(&sk->sk_callback_lock);
2117 2130