Commit b04e8554 authored by Sowmini Varadhan's avatar Sowmini Varadhan Committed by David S. Miller

RDS: TCP: Hooks to set up a single connection path

This patch adds ->conn_path_connect callbacks in the rds_transport
that are used to set up a single connection path.
Acked-by: default avatarSantosh Shilimkar <santosh.shilimkar@oracle.com>
Signed-off-by: default avatarSowmini Varadhan <sowmini.varadhan@oracle.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2da43c4a
...@@ -388,7 +388,7 @@ struct rds_transport rds_ib_transport = { ...@@ -388,7 +388,7 @@ struct rds_transport rds_ib_transport = {
.recv_path = rds_ib_recv_path, .recv_path = rds_ib_recv_path,
.conn_alloc = rds_ib_conn_alloc, .conn_alloc = rds_ib_conn_alloc,
.conn_free = rds_ib_conn_free, .conn_free = rds_ib_conn_free,
.conn_connect = rds_ib_conn_connect, .conn_path_connect = rds_ib_conn_path_connect,
.conn_path_shutdown = rds_ib_conn_path_shutdown, .conn_path_shutdown = rds_ib_conn_path_shutdown,
.inc_copy_to_user = rds_ib_inc_copy_to_user, .inc_copy_to_user = rds_ib_inc_copy_to_user,
.inc_free = rds_ib_inc_free, .inc_free = rds_ib_inc_free,
......
...@@ -328,7 +328,7 @@ extern struct list_head ib_nodev_conns; ...@@ -328,7 +328,7 @@ extern struct list_head ib_nodev_conns;
/* ib_cm.c */ /* ib_cm.c */
int rds_ib_conn_alloc(struct rds_connection *conn, gfp_t gfp); int rds_ib_conn_alloc(struct rds_connection *conn, gfp_t gfp);
void rds_ib_conn_free(void *arg); void rds_ib_conn_free(void *arg);
int rds_ib_conn_connect(struct rds_connection *conn); int rds_ib_conn_path_connect(struct rds_conn_path *cp);
void rds_ib_conn_path_shutdown(struct rds_conn_path *cp); void rds_ib_conn_path_shutdown(struct rds_conn_path *cp);
void rds_ib_state_change(struct sock *sk); void rds_ib_state_change(struct sock *sk);
int rds_ib_listen_init(void); int rds_ib_listen_init(void);
......
...@@ -685,8 +685,9 @@ int rds_ib_cm_initiate_connect(struct rdma_cm_id *cm_id) ...@@ -685,8 +685,9 @@ int rds_ib_cm_initiate_connect(struct rdma_cm_id *cm_id)
return ret; return ret;
} }
int rds_ib_conn_connect(struct rds_connection *conn) int rds_ib_conn_path_connect(struct rds_conn_path *cp)
{ {
struct rds_connection *conn = cp->cp_conn;
struct rds_ib_connection *ic = conn->c_transport_data; struct rds_ib_connection *ic = conn->c_transport_data;
struct sockaddr_in src, dest; struct sockaddr_in src, dest;
int ret; int ret;
......
...@@ -150,9 +150,9 @@ static void rds_loop_conn_free(void *arg) ...@@ -150,9 +150,9 @@ static void rds_loop_conn_free(void *arg)
kfree(lc); kfree(lc);
} }
static int rds_loop_conn_connect(struct rds_connection *conn) static int rds_loop_conn_path_connect(struct rds_conn_path *cp)
{ {
rds_connect_complete(conn); rds_connect_complete(cp->cp_conn);
return 0; return 0;
} }
...@@ -188,7 +188,7 @@ struct rds_transport rds_loop_transport = { ...@@ -188,7 +188,7 @@ struct rds_transport rds_loop_transport = {
.recv_path = rds_loop_recv_path, .recv_path = rds_loop_recv_path,
.conn_alloc = rds_loop_conn_alloc, .conn_alloc = rds_loop_conn_alloc,
.conn_free = rds_loop_conn_free, .conn_free = rds_loop_conn_free,
.conn_connect = rds_loop_conn_connect, .conn_path_connect = rds_loop_conn_path_connect,
.conn_path_shutdown = rds_loop_conn_path_shutdown, .conn_path_shutdown = rds_loop_conn_path_shutdown,
.inc_copy_to_user = rds_message_inc_copy_to_user, .inc_copy_to_user = rds_message_inc_copy_to_user,
.inc_free = rds_loop_inc_free, .inc_free = rds_loop_inc_free,
......
...@@ -454,7 +454,7 @@ struct rds_transport { ...@@ -454,7 +454,7 @@ struct rds_transport {
int (*laddr_check)(struct net *net, __be32 addr); int (*laddr_check)(struct net *net, __be32 addr);
int (*conn_alloc)(struct rds_connection *conn, gfp_t gfp); int (*conn_alloc)(struct rds_connection *conn, gfp_t gfp);
void (*conn_free)(void *data); void (*conn_free)(void *data);
int (*conn_connect)(struct rds_connection *conn); int (*conn_path_connect)(struct rds_conn_path *cp);
void (*conn_path_shutdown)(struct rds_conn_path *conn); void (*conn_path_shutdown)(struct rds_conn_path *conn);
void (*xmit_path_prepare)(struct rds_conn_path *cp); void (*xmit_path_prepare)(struct rds_conn_path *cp);
void (*xmit_path_complete)(struct rds_conn_path *cp); void (*xmit_path_complete)(struct rds_conn_path *cp);
......
...@@ -362,7 +362,7 @@ struct rds_transport rds_tcp_transport = { ...@@ -362,7 +362,7 @@ struct rds_transport rds_tcp_transport = {
.recv_path = rds_tcp_recv_path, .recv_path = rds_tcp_recv_path,
.conn_alloc = rds_tcp_conn_alloc, .conn_alloc = rds_tcp_conn_alloc,
.conn_free = rds_tcp_conn_free, .conn_free = rds_tcp_conn_free,
.conn_connect = rds_tcp_conn_connect, .conn_path_connect = rds_tcp_conn_path_connect,
.conn_path_shutdown = rds_tcp_conn_path_shutdown, .conn_path_shutdown = rds_tcp_conn_path_shutdown,
.inc_copy_to_user = rds_tcp_inc_copy_to_user, .inc_copy_to_user = rds_tcp_inc_copy_to_user,
.inc_free = rds_tcp_inc_free, .inc_free = rds_tcp_inc_free,
......
...@@ -13,7 +13,7 @@ struct rds_tcp_connection { ...@@ -13,7 +13,7 @@ struct rds_tcp_connection {
struct list_head t_tcp_node; struct list_head t_tcp_node;
struct rds_conn_path *t_cpath; struct rds_conn_path *t_cpath;
/* t_conn_path_lock synchronizes the connection establishment between /* t_conn_path_lock synchronizes the connection establishment between
* rds_tcp_accept_one and rds_tcp_conn_connect * rds_tcp_accept_one and rds_tcp_conn_path_connect
*/ */
struct mutex t_conn_path_lock; struct mutex t_conn_path_lock;
struct socket *t_sock; struct socket *t_sock;
...@@ -60,7 +60,7 @@ extern struct rds_transport rds_tcp_transport; ...@@ -60,7 +60,7 @@ extern struct rds_transport rds_tcp_transport;
void rds_tcp_accept_work(struct sock *sk); void rds_tcp_accept_work(struct sock *sk);
/* tcp_connect.c */ /* tcp_connect.c */
int rds_tcp_conn_connect(struct rds_connection *conn); int rds_tcp_conn_path_connect(struct rds_conn_path *cp);
void rds_tcp_conn_path_shutdown(struct rds_conn_path *conn); void rds_tcp_conn_path_shutdown(struct rds_conn_path *conn);
void rds_tcp_state_change(struct sock *sk); void rds_tcp_state_change(struct sock *sk);
......
...@@ -74,17 +74,17 @@ void rds_tcp_state_change(struct sock *sk) ...@@ -74,17 +74,17 @@ void rds_tcp_state_change(struct sock *sk)
state_change(sk); state_change(sk);
} }
int rds_tcp_conn_connect(struct rds_connection *conn) int rds_tcp_conn_path_connect(struct rds_conn_path *cp)
{ {
struct socket *sock = NULL; struct socket *sock = NULL;
struct sockaddr_in src, dest; struct sockaddr_in src, dest;
int ret; int ret;
struct rds_tcp_connection *tc = conn->c_transport_data; struct rds_connection *conn = cp->cp_conn;
struct rds_conn_path *cp = &conn->c_path[0]; struct rds_tcp_connection *tc = cp->cp_transport_data;
mutex_lock(&tc->t_conn_path_lock); mutex_lock(&tc->t_conn_path_lock);
if (rds_conn_up(conn)) { if (rds_conn_path_up(cp)) {
mutex_unlock(&tc->t_conn_path_lock); mutex_unlock(&tc->t_conn_path_lock);
return 0; return 0;
} }
...@@ -118,6 +118,7 @@ int rds_tcp_conn_connect(struct rds_connection *conn) ...@@ -118,6 +118,7 @@ int rds_tcp_conn_connect(struct rds_connection *conn)
ret = sock->ops->connect(sock, (struct sockaddr *)&dest, sizeof(dest), ret = sock->ops->connect(sock, (struct sockaddr *)&dest, sizeof(dest),
O_NONBLOCK); O_NONBLOCK);
cp->cp_outgoing = 1;
rdsdebug("connect to address %pI4 returned %d\n", &conn->c_faddr, ret); rdsdebug("connect to address %pI4 returned %d\n", &conn->c_faddr, ret);
if (ret == -EINPROGRESS) if (ret == -EINPROGRESS)
ret = 0; ret = 0;
...@@ -125,7 +126,7 @@ int rds_tcp_conn_connect(struct rds_connection *conn) ...@@ -125,7 +126,7 @@ int rds_tcp_conn_connect(struct rds_connection *conn)
rds_tcp_keepalive(sock); rds_tcp_keepalive(sock);
sock = NULL; sock = NULL;
} else { } else {
rds_tcp_restore_callbacks(sock, conn->c_transport_data); rds_tcp_restore_callbacks(sock, cp->cp_transport_data);
} }
out: out:
......
...@@ -152,8 +152,9 @@ void rds_connect_worker(struct work_struct *work) ...@@ -152,8 +152,9 @@ void rds_connect_worker(struct work_struct *work)
int ret; int ret;
clear_bit(RDS_RECONNECT_PENDING, &cp->cp_flags); clear_bit(RDS_RECONNECT_PENDING, &cp->cp_flags);
if (rds_conn_path_transition(cp, RDS_CONN_DOWN, RDS_CONN_CONNECTING)) { ret = rds_conn_path_transition(cp, RDS_CONN_DOWN, RDS_CONN_CONNECTING);
ret = conn->c_trans->conn_connect(conn); if (ret) {
ret = conn->c_trans->conn_path_connect(cp);
rdsdebug("conn %p for %pI4 to %pI4 dispatched, ret %d\n", rdsdebug("conn %p for %pI4 to %pI4 dispatched, ret %d\n",
conn, &conn->c_laddr, &conn->c_faddr, ret); conn, &conn->c_laddr, &conn->c_faddr, ret);
......
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