Commit 2de18105 authored by David S. Miller's avatar David S. Miller

Merge branch 'rds-tcp-fixes'

Sowmini Varadhan says:

====================
rds: tcp: fixes

Patch1 is a bug fix for correct reconnect when a connection
is restarted. Patch 2 accelerates cleanup by setting linger
to 1 and sending a RST to the peer.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 6d659237 c14b0366
...@@ -412,6 +412,7 @@ void rds_conn_destroy(struct rds_connection *conn) ...@@ -412,6 +412,7 @@ void rds_conn_destroy(struct rds_connection *conn)
"%pI4\n", conn, &conn->c_laddr, "%pI4\n", conn, &conn->c_laddr,
&conn->c_faddr); &conn->c_faddr);
conn->c_destroy_in_prog = 1;
/* Ensure conn will not be scheduled for reconnect */ /* Ensure conn will not be scheduled for reconnect */
spin_lock_irq(&rds_conn_lock); spin_lock_irq(&rds_conn_lock);
hlist_del_init_rcu(&conn->c_hash_node); hlist_del_init_rcu(&conn->c_hash_node);
......
...@@ -137,7 +137,8 @@ struct rds_connection { ...@@ -137,7 +137,8 @@ struct rds_connection {
__be32 c_faddr; __be32 c_faddr;
unsigned int c_loopback:1, unsigned int c_loopback:1,
c_ping_triggered:1, c_ping_triggered:1,
c_pad_to_32:30; c_destroy_in_prog:1,
c_pad_to_32:29;
int c_npaths; int c_npaths;
struct rds_connection *c_passive; struct rds_connection *c_passive;
struct rds_transport *c_trans; struct rds_transport *c_trans;
...@@ -827,6 +828,7 @@ void rds_send_drop_acked(struct rds_connection *conn, u64 ack, ...@@ -827,6 +828,7 @@ void rds_send_drop_acked(struct rds_connection *conn, u64 ack,
is_acked_func is_acked); is_acked_func is_acked);
void rds_send_path_drop_acked(struct rds_conn_path *cp, u64 ack, void rds_send_path_drop_acked(struct rds_conn_path *cp, u64 ack,
is_acked_func is_acked); is_acked_func is_acked);
void rds_send_ping(struct rds_connection *conn, int cp_index);
int rds_send_pong(struct rds_conn_path *cp, __be16 dport); int rds_send_pong(struct rds_conn_path *cp, __be16 dport);
/* rdma.c */ /* rdma.c */
......
...@@ -227,6 +227,7 @@ static void rds_recv_hs_exthdrs(struct rds_header *hdr, ...@@ -227,6 +227,7 @@ static void rds_recv_hs_exthdrs(struct rds_header *hdr,
} }
/* if RDS_EXTHDR_NPATHS was not found, default to a single-path */ /* if RDS_EXTHDR_NPATHS was not found, default to a single-path */
conn->c_npaths = max_t(int, conn->c_npaths, 1); conn->c_npaths = max_t(int, conn->c_npaths, 1);
conn->c_ping_triggered = 0;
rds_conn_peer_gen_update(conn, new_peer_gen_num); rds_conn_peer_gen_update(conn, new_peer_gen_num);
} }
...@@ -244,8 +245,7 @@ static void rds_recv_hs_exthdrs(struct rds_header *hdr, ...@@ -244,8 +245,7 @@ static void rds_recv_hs_exthdrs(struct rds_header *hdr,
* called after reception of the probe-pong on all mprds_paths. * called after reception of the probe-pong on all mprds_paths.
* Otherwise (sender of probe-ping is not the smaller ip addr): just call * Otherwise (sender of probe-ping is not the smaller ip addr): just call
* rds_conn_path_connect_if_down on the hashed path. (see rule 4) * rds_conn_path_connect_if_down on the hashed path. (see rule 4)
* 4. when cp_index > 0, rds_connect_worker must only trigger * 4. rds_connect_worker must only trigger a connection if laddr < faddr.
* a connection if laddr < faddr.
* 5. sender may end up queuing the packet on the cp. will get sent out later. * 5. sender may end up queuing the packet on the cp. will get sent out later.
* when connection is completed. * when connection is completed.
*/ */
...@@ -256,7 +256,7 @@ static void rds_start_mprds(struct rds_connection *conn) ...@@ -256,7 +256,7 @@ static void rds_start_mprds(struct rds_connection *conn)
if (conn->c_npaths > 1 && if (conn->c_npaths > 1 &&
IS_CANONICAL(conn->c_laddr, conn->c_faddr)) { IS_CANONICAL(conn->c_laddr, conn->c_faddr)) {
for (i = 1; i < conn->c_npaths; i++) { for (i = 0; i < conn->c_npaths; i++) {
cp = &conn->c_path[i]; cp = &conn->c_path[i];
rds_conn_path_connect_if_down(cp); rds_conn_path_connect_if_down(cp);
} }
......
...@@ -971,8 +971,6 @@ static int rds_cmsg_send(struct rds_sock *rs, struct rds_message *rm, ...@@ -971,8 +971,6 @@ static int rds_cmsg_send(struct rds_sock *rs, struct rds_message *rm,
return ret; return ret;
} }
static void rds_send_ping(struct rds_connection *conn);
static int rds_send_mprds_hash(struct rds_sock *rs, struct rds_connection *conn) static int rds_send_mprds_hash(struct rds_sock *rs, struct rds_connection *conn)
{ {
int hash; int hash;
...@@ -982,7 +980,7 @@ static int rds_send_mprds_hash(struct rds_sock *rs, struct rds_connection *conn) ...@@ -982,7 +980,7 @@ static int rds_send_mprds_hash(struct rds_sock *rs, struct rds_connection *conn)
else else
hash = RDS_MPATH_HASH(rs, conn->c_npaths); hash = RDS_MPATH_HASH(rs, conn->c_npaths);
if (conn->c_npaths == 0 && hash != 0) { if (conn->c_npaths == 0 && hash != 0) {
rds_send_ping(conn); rds_send_ping(conn, 0);
if (conn->c_npaths == 0) { if (conn->c_npaths == 0) {
wait_event_interruptible(conn->c_hs_waitq, wait_event_interruptible(conn->c_hs_waitq,
...@@ -1282,11 +1280,11 @@ rds_send_pong(struct rds_conn_path *cp, __be16 dport) ...@@ -1282,11 +1280,11 @@ rds_send_pong(struct rds_conn_path *cp, __be16 dport)
return rds_send_probe(cp, 0, dport, 0); return rds_send_probe(cp, 0, dport, 0);
} }
static void void
rds_send_ping(struct rds_connection *conn) rds_send_ping(struct rds_connection *conn, int cp_index)
{ {
unsigned long flags; unsigned long flags;
struct rds_conn_path *cp = &conn->c_path[0]; struct rds_conn_path *cp = &conn->c_path[cp_index];
spin_lock_irqsave(&cp->cp_lock, flags); spin_lock_irqsave(&cp->cp_lock, flags);
if (conn->c_ping_triggered) { if (conn->c_ping_triggered) {
...@@ -1295,6 +1293,6 @@ rds_send_ping(struct rds_connection *conn) ...@@ -1295,6 +1293,6 @@ rds_send_ping(struct rds_connection *conn)
} }
conn->c_ping_triggered = 1; conn->c_ping_triggered = 1;
spin_unlock_irqrestore(&cp->cp_lock, flags); spin_unlock_irqrestore(&cp->cp_lock, flags);
rds_send_probe(&conn->c_path[0], cpu_to_be16(RDS_FLAG_PROBE_PORT), rds_send_probe(cp, cpu_to_be16(RDS_FLAG_PROBE_PORT), 0, 0);
0, 0);
} }
EXPORT_SYMBOL_GPL(rds_send_ping);
...@@ -71,6 +71,7 @@ void rds_tcp_listen_data_ready(struct sock *sk); ...@@ -71,6 +71,7 @@ void rds_tcp_listen_data_ready(struct sock *sk);
int rds_tcp_accept_one(struct socket *sock); int rds_tcp_accept_one(struct socket *sock);
int rds_tcp_keepalive(struct socket *sock); int rds_tcp_keepalive(struct socket *sock);
void *rds_tcp_listen_sock_def_readable(struct net *net); void *rds_tcp_listen_sock_def_readable(struct net *net);
void rds_tcp_set_linger(struct socket *sock);
/* tcp_recv.c */ /* tcp_recv.c */
int rds_tcp_recv_init(void); int rds_tcp_recv_init(void);
......
...@@ -170,6 +170,8 @@ void rds_tcp_conn_path_shutdown(struct rds_conn_path *cp) ...@@ -170,6 +170,8 @@ void rds_tcp_conn_path_shutdown(struct rds_conn_path *cp)
cp->cp_conn, tc, sock); cp->cp_conn, tc, sock);
if (sock) { if (sock) {
if (cp->cp_conn->c_destroy_in_prog)
rds_tcp_set_linger(sock);
sock->ops->shutdown(sock, RCV_SHUTDOWN | SEND_SHUTDOWN); sock->ops->shutdown(sock, RCV_SHUTDOWN | SEND_SHUTDOWN);
lock_sock(sock->sk); lock_sock(sock->sk);
rds_tcp_restore_callbacks(sock, tc); /* tc->tc_sock = NULL */ rds_tcp_restore_callbacks(sock, tc); /* tc->tc_sock = NULL */
......
...@@ -112,7 +112,7 @@ struct rds_tcp_connection *rds_tcp_accept_one_path(struct rds_connection *conn) ...@@ -112,7 +112,7 @@ struct rds_tcp_connection *rds_tcp_accept_one_path(struct rds_connection *conn)
return NULL; return NULL;
} }
static void rds_tcp_set_linger(struct socket *sock) void rds_tcp_set_linger(struct socket *sock)
{ {
struct linger no_linger = { struct linger no_linger = {
.l_onoff = 1, .l_onoff = 1,
...@@ -192,6 +192,8 @@ int rds_tcp_accept_one(struct socket *sock) ...@@ -192,6 +192,8 @@ int rds_tcp_accept_one(struct socket *sock)
} }
new_sock = NULL; new_sock = NULL;
ret = 0; ret = 0;
if (conn->c_npaths == 0)
rds_send_ping(cp->cp_conn, cp->cp_index);
goto out; goto out;
rst_nsk: rst_nsk:
/* reset the newly returned accept sock and bail. /* reset the newly returned accept sock and bail.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment