Commit eac3e990 authored by Philipp Reisner's avatar Philipp Reisner

drbd: Converted drbd_try_connect() from mdev to tconn

Signed-off-by: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
parent 60ae4966
...@@ -572,7 +572,7 @@ static void drbd_setbufsize(struct socket *sock, unsigned int snd, ...@@ -572,7 +572,7 @@ static void drbd_setbufsize(struct socket *sock, unsigned int snd,
} }
} }
static struct socket *drbd_try_connect(struct drbd_conf *mdev) static struct socket *drbd_try_connect(struct drbd_tconn *tconn)
{ {
const char *what; const char *what;
struct socket *sock; struct socket *sock;
...@@ -580,11 +580,11 @@ static struct socket *drbd_try_connect(struct drbd_conf *mdev) ...@@ -580,11 +580,11 @@ static struct socket *drbd_try_connect(struct drbd_conf *mdev)
int err; int err;
int disconnect_on_error = 1; int disconnect_on_error = 1;
if (!get_net_conf(mdev->tconn)) if (!get_net_conf(tconn))
return NULL; return NULL;
what = "sock_create_kern"; what = "sock_create_kern";
err = sock_create_kern(((struct sockaddr *)mdev->tconn->net_conf->my_addr)->sa_family, err = sock_create_kern(((struct sockaddr *)tconn->net_conf->my_addr)->sa_family,
SOCK_STREAM, IPPROTO_TCP, &sock); SOCK_STREAM, IPPROTO_TCP, &sock);
if (err < 0) { if (err < 0) {
sock = NULL; sock = NULL;
...@@ -592,9 +592,9 @@ static struct socket *drbd_try_connect(struct drbd_conf *mdev) ...@@ -592,9 +592,9 @@ static struct socket *drbd_try_connect(struct drbd_conf *mdev)
} }
sock->sk->sk_rcvtimeo = sock->sk->sk_rcvtimeo =
sock->sk->sk_sndtimeo = mdev->tconn->net_conf->try_connect_int*HZ; sock->sk->sk_sndtimeo = tconn->net_conf->try_connect_int*HZ;
drbd_setbufsize(sock, mdev->tconn->net_conf->sndbuf_size, drbd_setbufsize(sock, tconn->net_conf->sndbuf_size,
mdev->tconn->net_conf->rcvbuf_size); tconn->net_conf->rcvbuf_size);
/* explicitly bind to the configured IP as source IP /* explicitly bind to the configured IP as source IP
* for the outgoing connections. * for the outgoing connections.
...@@ -603,9 +603,9 @@ static struct socket *drbd_try_connect(struct drbd_conf *mdev) ...@@ -603,9 +603,9 @@ static struct socket *drbd_try_connect(struct drbd_conf *mdev)
* Make sure to use 0 as port number, so linux selects * Make sure to use 0 as port number, so linux selects
* a free one dynamically. * a free one dynamically.
*/ */
memcpy(&src_in6, mdev->tconn->net_conf->my_addr, memcpy(&src_in6, tconn->net_conf->my_addr,
min_t(int, mdev->tconn->net_conf->my_addr_len, sizeof(src_in6))); min_t(int, tconn->net_conf->my_addr_len, sizeof(src_in6)));
if (((struct sockaddr *)mdev->tconn->net_conf->my_addr)->sa_family == AF_INET6) if (((struct sockaddr *)tconn->net_conf->my_addr)->sa_family == AF_INET6)
src_in6.sin6_port = 0; src_in6.sin6_port = 0;
else else
((struct sockaddr_in *)&src_in6)->sin_port = 0; /* AF_INET & AF_SCI */ ((struct sockaddr_in *)&src_in6)->sin_port = 0; /* AF_INET & AF_SCI */
...@@ -613,7 +613,7 @@ static struct socket *drbd_try_connect(struct drbd_conf *mdev) ...@@ -613,7 +613,7 @@ static struct socket *drbd_try_connect(struct drbd_conf *mdev)
what = "bind before connect"; what = "bind before connect";
err = sock->ops->bind(sock, err = sock->ops->bind(sock,
(struct sockaddr *) &src_in6, (struct sockaddr *) &src_in6,
mdev->tconn->net_conf->my_addr_len); tconn->net_conf->my_addr_len);
if (err < 0) if (err < 0)
goto out; goto out;
...@@ -622,8 +622,8 @@ static struct socket *drbd_try_connect(struct drbd_conf *mdev) ...@@ -622,8 +622,8 @@ static struct socket *drbd_try_connect(struct drbd_conf *mdev)
disconnect_on_error = 0; disconnect_on_error = 0;
what = "connect"; what = "connect";
err = sock->ops->connect(sock, err = sock->ops->connect(sock,
(struct sockaddr *)mdev->tconn->net_conf->peer_addr, (struct sockaddr *)tconn->net_conf->peer_addr,
mdev->tconn->net_conf->peer_addr_len, 0); tconn->net_conf->peer_addr_len, 0);
out: out:
if (err < 0) { if (err < 0) {
...@@ -641,12 +641,12 @@ static struct socket *drbd_try_connect(struct drbd_conf *mdev) ...@@ -641,12 +641,12 @@ static struct socket *drbd_try_connect(struct drbd_conf *mdev)
disconnect_on_error = 0; disconnect_on_error = 0;
break; break;
default: default:
dev_err(DEV, "%s failed, err = %d\n", what, err); conn_err(tconn, "%s failed, err = %d\n", what, err);
} }
if (disconnect_on_error) if (disconnect_on_error)
drbd_force_state(mdev, NS(conn, C_DISCONNECTING)); drbd_force_state(tconn->volume0, NS(conn, C_DISCONNECTING));
} }
put_net_conf(mdev->tconn); put_net_conf(tconn);
return sock; return sock;
} }
...@@ -774,7 +774,7 @@ static int drbd_connect(struct drbd_conf *mdev) ...@@ -774,7 +774,7 @@ static int drbd_connect(struct drbd_conf *mdev)
do { do {
for (try = 0;;) { for (try = 0;;) {
/* 3 tries, this should take less than a second! */ /* 3 tries, this should take less than a second! */
s = drbd_try_connect(mdev); s = drbd_try_connect(mdev->tconn);
if (s || ++try >= 3) if (s || ++try >= 3)
break; break;
/* give the other side time to call bind() & listen() */ /* give the other side time to call bind() & listen() */
......
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