summaryrefslogtreecommitdiffstats
path: root/fs/dlm
diff options
context:
space:
mode:
authorBob Peterson <rpeterso@redhat.com>2017-09-12 04:55:04 -0400
committerDavid Teigland <teigland@redhat.com>2017-09-25 13:45:21 -0400
commit61d9102b62129e13a2258c1e0566962f9a1732f0 (patch)
tree94f017d688925ebecfd3da5e96735c2f55af1eaf /fs/dlm
parente19b205be43d11bff638cad4487008c48d21c103 (diff)
DLM: Eliminate CF_CONNECT_PENDING flag
Before this patch, there was a flag in the con structure that was used to determine whether or not a connect was needed. The bit was set here and there, and cleared here and there, so it left some race conditions: the bit was set, work was queued, then the worker cleared the bit, allowing someone else to set it while the worker ran. For the most part, this worked okay, but we got into trouble if connections were lost and it needed to reconnect. This patch eliminates the flag in favor of simply checking if we actually have a sock pointer while protected by the mutex. Signed-off-by: Bob Peterson <rpeterso@redhat.com> Reviewed-by: Tadashi Miyauchi <miyauchi@toshiba-tops.co.jp> Signed-off-by: David Teigland <teigland@redhat.com>
Diffstat (limited to 'fs/dlm')
-rw-r--r--fs/dlm/lowcomms.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
index 4813d0e0cd9b..6a7a49b93374 100644
--- a/fs/dlm/lowcomms.c
+++ b/fs/dlm/lowcomms.c
@@ -107,7 +107,6 @@ struct connection {
107 unsigned long flags; 107 unsigned long flags;
108#define CF_READ_PENDING 1 108#define CF_READ_PENDING 1
109#define CF_WRITE_PENDING 2 109#define CF_WRITE_PENDING 2
110#define CF_CONNECT_PENDING 3
111#define CF_INIT_PENDING 4 110#define CF_INIT_PENDING 4
112#define CF_IS_OTHERCON 5 111#define CF_IS_OTHERCON 5
113#define CF_CLOSE 6 112#define CF_CLOSE 6
@@ -435,8 +434,8 @@ static inline void lowcomms_connect_sock(struct connection *con)
435{ 434{
436 if (test_bit(CF_CLOSE, &con->flags)) 435 if (test_bit(CF_CLOSE, &con->flags))
437 return; 436 return;
438 if (!test_and_set_bit(CF_CONNECT_PENDING, &con->flags)) 437 queue_work(send_workqueue, &con->swork);
439 queue_work(send_workqueue, &con->swork); 438 cond_resched();
440} 439}
441 440
442static void lowcomms_state_change(struct sock *sk) 441static void lowcomms_state_change(struct sock *sk)
@@ -579,7 +578,6 @@ static void make_sockaddr(struct sockaddr_storage *saddr, uint16_t port,
579static void close_connection(struct connection *con, bool and_other, 578static void close_connection(struct connection *con, bool and_other,
580 bool tx, bool rx) 579 bool tx, bool rx)
581{ 580{
582 clear_bit(CF_CONNECT_PENDING, &con->flags);
583 clear_bit(CF_WRITE_PENDING, &con->flags); 581 clear_bit(CF_WRITE_PENDING, &con->flags);
584 if (tx && cancel_work_sync(&con->swork)) 582 if (tx && cancel_work_sync(&con->swork))
585 log_print("canceled swork for node %d", con->nodeid); 583 log_print("canceled swork for node %d", con->nodeid);
@@ -1098,7 +1096,6 @@ socket_err:
1098 con->retries, result); 1096 con->retries, result);
1099 mutex_unlock(&con->sock_mutex); 1097 mutex_unlock(&con->sock_mutex);
1100 msleep(1000); 1098 msleep(1000);
1101 clear_bit(CF_CONNECT_PENDING, &con->flags);
1102 lowcomms_connect_sock(con); 1099 lowcomms_connect_sock(con);
1103 return; 1100 return;
1104 } 1101 }
@@ -1194,7 +1191,6 @@ out_err:
1194 con->retries, result); 1191 con->retries, result);
1195 mutex_unlock(&con->sock_mutex); 1192 mutex_unlock(&con->sock_mutex);
1196 msleep(1000); 1193 msleep(1000);
1197 clear_bit(CF_CONNECT_PENDING, &con->flags);
1198 lowcomms_connect_sock(con); 1194 lowcomms_connect_sock(con);
1199 return; 1195 return;
1200 } 1196 }
@@ -1593,7 +1589,7 @@ static void process_send_sockets(struct work_struct *work)
1593{ 1589{
1594 struct connection *con = container_of(work, struct connection, swork); 1590 struct connection *con = container_of(work, struct connection, swork);
1595 1591
1596 if (test_and_clear_bit(CF_CONNECT_PENDING, &con->flags)) 1592 if (con->sock == NULL) /* not mutex protected so check it inside too */
1597 con->connect_action(con); 1593 con->connect_action(con);
1598 if (test_and_clear_bit(CF_WRITE_PENDING, &con->flags)) 1594 if (test_and_clear_bit(CF_WRITE_PENDING, &con->flags))
1599 send_to_sock(con); 1595 send_to_sock(con);