Skip to content

Commit 1037c2a

Browse files
Alexander Aringteigland
authored andcommitted
fs: dlm: use listen sock as dlm running indicator
This patch will switch from dlm_allow_conn to check if dlm lowcomms is running or not to if we actually have a listen socket set or not. The list socket will be set and unset in lowcomms start and shutdown functionality. To synchronize with data_ready() callback we will set the socket callback to NULL while socket lock is held. Signed-off-by: Alexander Aring <[email protected]> Signed-off-by: David Teigland <[email protected]>
1 parent dd070a5 commit 1037c2a

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

fs/dlm/config.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ static int dlm_check_protocol_and_dlm_running(unsigned int x)
183183
return -EINVAL;
184184
}
185185

186-
if (dlm_allow_conn)
186+
if (dlm_lowcomms_is_running())
187187
return -EBUSY;
188188

189189
return 0;
@@ -194,7 +194,7 @@ static int dlm_check_zero_and_dlm_running(unsigned int x)
194194
if (!x)
195195
return -EINVAL;
196196

197-
if (dlm_allow_conn)
197+
if (dlm_lowcomms_is_running())
198198
return -EBUSY;
199199

200200
return 0;

fs/dlm/lowcomms.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ static DEFINE_SPINLOCK(dlm_node_addrs_spin);
176176
static struct listen_connection listen_con;
177177
static struct sockaddr_storage *dlm_local_addr[DLM_MAX_ADDR_COUNT];
178178
static int dlm_local_count;
179-
int dlm_allow_conn;
180179

181180
/* Work queues */
182181
static struct workqueue_struct *recv_workqueue;
@@ -191,6 +190,11 @@ static const struct dlm_proto_ops *dlm_proto_ops;
191190
static void process_recv_sockets(struct work_struct *work);
192191
static void process_send_sockets(struct work_struct *work);
193192

193+
bool dlm_lowcomms_is_running(void)
194+
{
195+
return !!listen_con.sock;
196+
}
197+
194198
static void writequeue_entry_ctor(void *data)
195199
{
196200
struct writequeue_entry *entry = data;
@@ -511,9 +515,6 @@ static void lowcomms_data_ready(struct sock *sk)
511515

512516
static void lowcomms_listen_data_ready(struct sock *sk)
513517
{
514-
if (!dlm_allow_conn)
515-
return;
516-
517518
queue_work(recv_workqueue, &listen_con.rwork);
518519
}
519520

@@ -1689,10 +1690,7 @@ void dlm_lowcomms_shutdown(void)
16891690
{
16901691
int idx;
16911692

1692-
/* Set all the flags to prevent any
1693-
* socket activity.
1694-
*/
1695-
dlm_allow_conn = 0;
1693+
restore_callbacks(listen_con.sock);
16961694

16971695
if (recv_workqueue)
16981696
flush_workqueue(recv_workqueue);
@@ -1995,8 +1993,6 @@ int dlm_lowcomms_start(void)
19951993
if (error)
19961994
goto fail_local;
19971995

1998-
dlm_allow_conn = 1;
1999-
20001996
/* Start listening */
20011997
switch (dlm_config.ci_protocol) {
20021998
case DLM_PROTO_TCP:
@@ -2021,7 +2017,6 @@ int dlm_lowcomms_start(void)
20212017
fail_listen:
20222018
dlm_proto_ops = NULL;
20232019
fail_proto_ops:
2024-
dlm_allow_conn = 0;
20252020
work_stop();
20262021
fail_local:
20272022
deinit_local();

fs/dlm/lowcomms.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ static inline int nodeid_hash(int nodeid)
2929
return nodeid & (CONN_HASH_SIZE-1);
3030
}
3131

32-
/* switch to check if dlm is running */
33-
extern int dlm_allow_conn;
32+
/* check if dlm is running */
33+
bool dlm_lowcomms_is_running(void);
3434

3535
int dlm_lowcomms_start(void);
3636
void dlm_lowcomms_shutdown(void);

0 commit comments

Comments
 (0)