]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/patches/suse-2.6.27.39/patches.fixes/dlm-close-connection-2.patch
Imported linux-2.6.27.39 suse/xen patches.
[people/teissler/ipfire-2.x.git] / src / patches / suse-2.6.27.39 / patches.fixes / dlm-close-connection-2.patch
1 commit 063c4c99630c0b06afad080d2a18bda64172c1a2
2 Author: Lars Marowsky-Bree <lmb@suse.de>
3 From: Lars Marowsky-Bree <lmb@suse.de>
4 Date: Tue Aug 11 16:18:23 2009 -0500
5 Reference: bnc#524222
6 Subject: dlm: fix connection close handling
7
8 Closing a connection to a node can create problems if there are
9 outstanding messages for that node. The problems include dlm_send
10 spinning attempting to reconnect, or BUG from tcp_connect_to_sock()
11 attempting to use a partially closed connection.
12
13 To cleanly close a connection, we now first attempt to send any pending
14 messages, cancel any remaining workqueue work, and flag the connection
15 as closed to avoid reconnect attempts.
16
17 Signed-off-by: Lars Marowsky-Bree <lmb@suse.de>
18 Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
19 Signed-off-by: David Teigland <teigland@redhat.com>
20
21 diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
22 index 210d52c..bda690c 100644
23 --- a/fs/dlm/lowcomms.c
24 +++ b/fs/dlm/lowcomms.c
25 @@ -106,6 +106,7 @@ struct connection {
26 #define CF_CONNECT_PENDING 3
27 #define CF_INIT_PENDING 4
28 #define CF_IS_OTHERCON 5
29 +#define CF_CLOSE 6
30 struct list_head writequeue; /* List of outgoing writequeue_entries */
31 spinlock_t writequeue_lock;
32 int (*rx_action) (struct connection *); /* What to do when active */
33 @@ -299,6 +300,8 @@ static void lowcomms_write_space(struct sock *sk)
34
35 static inline void lowcomms_connect_sock(struct connection *con)
36 {
37 + if (test_bit(CF_CLOSE, &con->flags))
38 + return;
39 if (!test_and_set_bit(CF_CONNECT_PENDING, &con->flags))
40 queue_work(send_workqueue, &con->swork);
41 }
42 @@ -1368,6 +1371,13 @@ int dlm_lowcomms_close(int nodeid)
43 log_print("closing connection to node %d", nodeid);
44 con = nodeid2con(nodeid, 0);
45 if (con) {
46 + clear_bit(CF_CONNECT_PENDING, &con->flags);
47 + clear_bit(CF_WRITE_PENDING, &con->flags);
48 + set_bit(CF_CLOSE, &con->flags);
49 + if (cancel_work_sync(&con->swork))
50 + log_print("canceled swork for node %d", nodeid);
51 + if (cancel_work_sync(&con->rwork))
52 + log_print("canceled rwork for node %d", nodeid);
53 clean_one_writequeue(con);
54 close_connection(con, true);
55 }
56 @@ -1393,9 +1403,10 @@ static void process_send_sockets(struct work_struct *work)
57
58 if (test_and_clear_bit(CF_CONNECT_PENDING, &con->flags)) {
59 con->connect_action(con);
60 + set_bit(CF_WRITE_PENDING, &con->flags);
61 }
62 - clear_bit(CF_WRITE_PENDING, &con->flags);
63 - send_to_sock(con);
64 + if (test_and_clear_bit(CF_WRITE_PENDING, &con->flags))
65 + send_to_sock(con);
66 }
67
68