Skip to content

Commit c3d88df

Browse files
Alexander Aringteigland
authored andcommitted
fs: dlm: cleanup listen sock handling
This patch removes save_listen_callbacks() and add_listen_sock() as they are only used once in lowcomms functionality. For shutdown lowcomms it's not necessary to whole flush the workqueues to synchronize with restoring the old sk_data_ready() callback. Only the listen con receive work need to be cancelled. For each individual node shutdown we should be sure that last ack was been transmitted which is done by flushing per connection swork worker. Signed-off-by: Alexander Aring <[email protected]> Signed-off-by: David Teigland <[email protected]>
1 parent 4f567ac commit c3d88df

File tree

1 file changed

+17
-34
lines changed

1 file changed

+17
-34
lines changed

fs/dlm/lowcomms.c

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -647,17 +647,6 @@ static void lowcomms_error_report(struct sock *sk)
647647
orig_report(sk);
648648
}
649649

650-
/* Note: sk_callback_lock must be locked before calling this function. */
651-
static void save_listen_callbacks(struct socket *sock)
652-
{
653-
struct sock *sk = sock->sk;
654-
655-
listen_sock.sk_data_ready = sk->sk_data_ready;
656-
listen_sock.sk_state_change = sk->sk_state_change;
657-
listen_sock.sk_write_space = sk->sk_write_space;
658-
listen_sock.sk_error_report = sk->sk_error_report;
659-
}
660-
661650
static void restore_callbacks(struct socket *sock)
662651
{
663652
struct sock *sk = sock->sk;
@@ -671,21 +660,6 @@ static void restore_callbacks(struct socket *sock)
671660
release_sock(sk);
672661
}
673662

674-
static void add_listen_sock(struct socket *sock, struct listen_connection *con)
675-
{
676-
struct sock *sk = sock->sk;
677-
678-
lock_sock(sk);
679-
save_listen_callbacks(sock);
680-
con->sock = sock;
681-
682-
sk->sk_user_data = con;
683-
sk->sk_allocation = GFP_NOFS;
684-
/* Install a data_ready callback */
685-
sk->sk_data_ready = lowcomms_listen_data_ready;
686-
release_sock(sk);
687-
}
688-
689663
/* Make a socket active */
690664
static void add_sock(struct socket *sock, struct connection *con)
691665
{
@@ -1593,13 +1567,12 @@ static int work_start(void)
15931567

15941568
void dlm_lowcomms_shutdown(void)
15951569
{
1596-
restore_callbacks(listen_con.sock);
1597-
1598-
if (recv_workqueue)
1599-
flush_workqueue(recv_workqueue);
1600-
if (send_workqueue)
1601-
flush_workqueue(send_workqueue);
1570+
/* stop lowcomms_listen_data_ready calls */
1571+
lock_sock(listen_con.sock->sk);
1572+
listen_con.sock->sk->sk_data_ready = listen_sock.sk_data_ready;
1573+
release_sock(listen_con.sock->sk);
16021574

1575+
cancel_work_sync(&listen_con.rwork);
16031576
dlm_close_sock(&listen_con.sock);
16041577
}
16051578

@@ -1615,6 +1588,7 @@ void dlm_lowcomms_shutdown_node(int nodeid, bool force)
16151588
return;
16161589
}
16171590

1591+
flush_work(&con->swork);
16181592
WARN_ON_ONCE(!force && !list_empty(&con->writequeue));
16191593
clean_one_writequeue(con);
16201594
if (con->othercon)
@@ -1736,8 +1710,17 @@ static int dlm_listen_for_all(void)
17361710
if (result < 0)
17371711
goto out;
17381712

1739-
save_listen_callbacks(sock);
1740-
add_listen_sock(sock, &listen_con);
1713+
lock_sock(sock->sk);
1714+
listen_sock.sk_data_ready = sock->sk->sk_data_ready;
1715+
listen_sock.sk_write_space = sock->sk->sk_write_space;
1716+
listen_sock.sk_error_report = sock->sk->sk_error_report;
1717+
listen_sock.sk_state_change = sock->sk->sk_state_change;
1718+
1719+
listen_con.sock = sock;
1720+
1721+
sock->sk->sk_allocation = GFP_NOFS;
1722+
sock->sk->sk_data_ready = lowcomms_listen_data_ready;
1723+
release_sock(sock->sk);
17411724

17421725
result = sock->ops->listen(sock, 5);
17431726
if (result < 0) {

0 commit comments

Comments
 (0)