aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunxiao Bi <junxiao.bi@oracle.com>2014-08-29 18:19:02 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-08-29 19:28:16 -0400
commit8e9801dfe37c9e68cdbfcd15988df2187191864e (patch)
tree27b0c2499e1a11a2ad5b8a8b1d0bfcae5f25cd8e
parentc43c363def04cdaed0d9e26dae846081f55714e7 (diff)
ocfs2: o2net: set tcp user timeout to max value
When tcp retransmit timeout(15mins), the connection will be closed. Pending messages may be lost during this time. So we set tcp user timeout to override the retransmit timeout to the max value. This is OK for ocfs2 since we have disk heartbeat, if peer crash, the disk heartbeat will timeout and it will be evicted, if disk heartbeat not timeout and connection idle for a long time, then this means the cluster enters split-brain state, since fence can't happen, we'd better keep the connection and wait network recover. Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com> Reviewed-by: Srinivas Eeda <srinivas.eeda@oracle.com> Reviewed-by: Mark Fasheh <mfasheh@suse.de> Cc: Joel Becker <jlbec@evilplan.org> Cc: Joseph Qi <joseph.qi@huawei.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/ocfs2/cluster/tcp.c20
-rw-r--r--fs/ocfs2/cluster/tcp.h1
2 files changed, 21 insertions, 0 deletions
diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c
index 2334bfc966c1..ea34952f9496 100644
--- a/fs/ocfs2/cluster/tcp.c
+++ b/fs/ocfs2/cluster/tcp.c
@@ -1480,6 +1480,14 @@ static int o2net_set_nodelay(struct socket *sock)
1480 return ret; 1480 return ret;
1481} 1481}
1482 1482
1483static int o2net_set_usertimeout(struct socket *sock)
1484{
1485 int user_timeout = O2NET_TCP_USER_TIMEOUT;
1486
1487 return kernel_setsockopt(sock, SOL_TCP, TCP_USER_TIMEOUT,
1488 (char *)&user_timeout, sizeof(user_timeout));
1489}
1490
1483static void o2net_initialize_handshake(void) 1491static void o2net_initialize_handshake(void)
1484{ 1492{
1485 o2net_hand->o2hb_heartbeat_timeout_ms = cpu_to_be32( 1493 o2net_hand->o2hb_heartbeat_timeout_ms = cpu_to_be32(
@@ -1663,6 +1671,12 @@ static void o2net_start_connect(struct work_struct *work)
1663 goto out; 1671 goto out;
1664 } 1672 }
1665 1673
1674 ret = o2net_set_usertimeout(sock);
1675 if (ret) {
1676 mlog(ML_ERROR, "set TCP_USER_TIMEOUT failed with %d\n", ret);
1677 goto out;
1678 }
1679
1666 o2net_register_callbacks(sc->sc_sock->sk, sc); 1680 o2net_register_callbacks(sc->sc_sock->sk, sc);
1667 1681
1668 spin_lock(&nn->nn_lock); 1682 spin_lock(&nn->nn_lock);
@@ -1844,6 +1858,12 @@ static int o2net_accept_one(struct socket *sock, int *more)
1844 goto out; 1858 goto out;
1845 } 1859 }
1846 1860
1861 ret = o2net_set_usertimeout(new_sock);
1862 if (ret) {
1863 mlog(ML_ERROR, "set TCP_USER_TIMEOUT failed with %d\n", ret);
1864 goto out;
1865 }
1866
1847 slen = sizeof(sin); 1867 slen = sizeof(sin);
1848 ret = new_sock->ops->getname(new_sock, (struct sockaddr *) &sin, 1868 ret = new_sock->ops->getname(new_sock, (struct sockaddr *) &sin,
1849 &slen, 1); 1869 &slen, 1);
diff --git a/fs/ocfs2/cluster/tcp.h b/fs/ocfs2/cluster/tcp.h
index 5bada2a69b50..c571e849fda4 100644
--- a/fs/ocfs2/cluster/tcp.h
+++ b/fs/ocfs2/cluster/tcp.h
@@ -63,6 +63,7 @@ typedef void (o2net_post_msg_handler_func)(int status, void *data,
63#define O2NET_KEEPALIVE_DELAY_MS_DEFAULT 2000 63#define O2NET_KEEPALIVE_DELAY_MS_DEFAULT 2000
64#define O2NET_IDLE_TIMEOUT_MS_DEFAULT 30000 64#define O2NET_IDLE_TIMEOUT_MS_DEFAULT 30000
65 65
66#define O2NET_TCP_USER_TIMEOUT 0x7fffffff
66 67
67/* TODO: figure this out.... */ 68/* TODO: figure this out.... */
68static inline int o2net_link_down(int err, struct socket *sock) 69static inline int o2net_link_down(int err, struct socket *sock)