Skip to content

Commit fb1911e

Browse files
Alexander Aringteigland
authored andcommitted
dlm: do synchronized socket connect call
To avoid -EINPROGRESS cases on connect that just ends in a retry we just call connect in a synchronized way to wait until its done. Since commit dbb751f ("fs: dlm: parallelize lowcomms socket handling") we have a non ordered workqueue running for serving the DLM sockets that allows us to call send/recv for each DLM socket connection in parallel. Before each worker needed to wait until the previous worker was done and probably the reason why connect() was called in an asynchronous way to not block other workers. This is however not necessary anymore as other socket handling workers don't need to wait. Signed-off-by: Alexander Aring <aahringo@redhat.com> Signed-off-by: David Teigland <teigland@redhat.com>
1 parent c846f73 commit fb1911e

File tree

1 file changed

+1
-35
lines changed

1 file changed

+1
-35
lines changed

fs/dlm/lowcomms.c

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,6 @@ struct dlm_proto_ops {
161161
const char *name;
162162
int proto;
163163

164-
int (*connect)(struct connection *con, struct socket *sock,
165-
struct sockaddr *addr, int addr_len);
166164
void (*sockopts)(struct socket *sock);
167165
int (*bind)(struct socket *sock);
168166
int (*listen_validate)(void);
@@ -1599,8 +1597,7 @@ static int dlm_connect(struct connection *con)
15991597

16001598
log_print_ratelimited("connecting to %d", con->nodeid);
16011599
make_sockaddr(&addr, dlm_config.ci_tcp_port, &addr_len);
1602-
result = dlm_proto_ops->connect(con, sock, (struct sockaddr *)&addr,
1603-
addr_len);
1600+
result = kernel_connect(sock, (struct sockaddr *)&addr, addr_len, 0);
16041601
switch (result) {
16051602
case -EINPROGRESS:
16061603
/* not an error */
@@ -1634,13 +1631,6 @@ static void process_send_sockets(struct work_struct *work)
16341631
switch (ret) {
16351632
case 0:
16361633
break;
1637-
case -EINPROGRESS:
1638-
/* avoid spamming resched on connection
1639-
* we might can switch to a state_change
1640-
* event based mechanism if established
1641-
*/
1642-
msleep(100);
1643-
break;
16441634
default:
16451635
/* CF_SEND_PENDING not cleared */
16461636
up_write(&con->sock_lock);
@@ -1831,12 +1821,6 @@ static int dlm_tcp_bind(struct socket *sock)
18311821
return 0;
18321822
}
18331823

1834-
static int dlm_tcp_connect(struct connection *con, struct socket *sock,
1835-
struct sockaddr *addr, int addr_len)
1836-
{
1837-
return kernel_connect(sock, addr, addr_len, O_NONBLOCK);
1838-
}
1839-
18401824
static int dlm_tcp_listen_validate(void)
18411825
{
18421826
/* We don't support multi-homed hosts */
@@ -1873,7 +1857,6 @@ static int dlm_tcp_listen_bind(struct socket *sock)
18731857
static const struct dlm_proto_ops dlm_tcp_ops = {
18741858
.name = "TCP",
18751859
.proto = IPPROTO_TCP,
1876-
.connect = dlm_tcp_connect,
18771860
.sockopts = dlm_tcp_sockopts,
18781861
.bind = dlm_tcp_bind,
18791862
.listen_validate = dlm_tcp_listen_validate,
@@ -1886,22 +1869,6 @@ static int dlm_sctp_bind(struct socket *sock)
18861869
return sctp_bind_addrs(sock, 0);
18871870
}
18881871

1889-
static int dlm_sctp_connect(struct connection *con, struct socket *sock,
1890-
struct sockaddr *addr, int addr_len)
1891-
{
1892-
int ret;
1893-
1894-
/*
1895-
* Make kernel_connect() function return in specified time,
1896-
* since O_NONBLOCK argument in connect() function does not work here,
1897-
* then, we should restore the default value of this attribute.
1898-
*/
1899-
sock_set_sndtimeo(sock->sk, 5);
1900-
ret = kernel_connect(sock, addr, addr_len, 0);
1901-
sock_set_sndtimeo(sock->sk, 0);
1902-
return ret;
1903-
}
1904-
19051872
static int dlm_sctp_listen_validate(void)
19061873
{
19071874
if (!IS_ENABLED(CONFIG_IP_SCTP)) {
@@ -1929,7 +1896,6 @@ static const struct dlm_proto_ops dlm_sctp_ops = {
19291896
.name = "SCTP",
19301897
.proto = IPPROTO_SCTP,
19311898
.try_new_addr = true,
1932-
.connect = dlm_sctp_connect,
19331899
.sockopts = dlm_sctp_sockopts,
19341900
.bind = dlm_sctp_bind,
19351901
.listen_validate = dlm_sctp_listen_validate,

0 commit comments

Comments
 (0)