aboutsummaryrefslogtreecommitdiffstats
path: root/fs/dlm/lowcomms.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/dlm/lowcomms.c')
-rw-r--r--fs/dlm/lowcomms.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
index 7c1e5e5cccd8..3962262f991a 100644
--- a/fs/dlm/lowcomms.c
+++ b/fs/dlm/lowcomms.c
@@ -50,6 +50,7 @@
50#include <linux/pagemap.h> 50#include <linux/pagemap.h>
51#include <linux/idr.h> 51#include <linux/idr.h>
52#include <linux/file.h> 52#include <linux/file.h>
53#include <linux/mutex.h>
53#include <linux/sctp.h> 54#include <linux/sctp.h>
54#include <net/sctp/user.h> 55#include <net/sctp/user.h>
55 56
@@ -138,7 +139,7 @@ static struct workqueue_struct *recv_workqueue;
138static struct workqueue_struct *send_workqueue; 139static struct workqueue_struct *send_workqueue;
139 140
140static DEFINE_IDR(connections_idr); 141static DEFINE_IDR(connections_idr);
141static DECLARE_MUTEX(connections_lock); 142static DEFINE_MUTEX(connections_lock);
142static int max_nodeid; 143static int max_nodeid;
143static struct kmem_cache *con_cache; 144static struct kmem_cache *con_cache;
144 145
@@ -205,9 +206,9 @@ static struct connection *nodeid2con(int nodeid, gfp_t allocation)
205{ 206{
206 struct connection *con; 207 struct connection *con;
207 208
208 down(&connections_lock); 209 mutex_lock(&connections_lock);
209 con = __nodeid2con(nodeid, allocation); 210 con = __nodeid2con(nodeid, allocation);
210 up(&connections_lock); 211 mutex_unlock(&connections_lock);
211 212
212 return con; 213 return con;
213} 214}
@@ -218,15 +219,15 @@ static struct connection *assoc2con(int assoc_id)
218 int i; 219 int i;
219 struct connection *con; 220 struct connection *con;
220 221
221 down(&connections_lock); 222 mutex_lock(&connections_lock);
222 for (i=0; i<=max_nodeid; i++) { 223 for (i=0; i<=max_nodeid; i++) {
223 con = __nodeid2con(i, 0); 224 con = __nodeid2con(i, 0);
224 if (con && con->sctp_assoc == assoc_id) { 225 if (con && con->sctp_assoc == assoc_id) {
225 up(&connections_lock); 226 mutex_unlock(&connections_lock);
226 return con; 227 return con;
227 } 228 }
228 } 229 }
229 up(&connections_lock); 230 mutex_unlock(&connections_lock);
230 return NULL; 231 return NULL;
231} 232}
232 233
@@ -381,7 +382,7 @@ static void sctp_init_failed(void)
381 int i; 382 int i;
382 struct connection *con; 383 struct connection *con;
383 384
384 down(&connections_lock); 385 mutex_lock(&connections_lock);
385 for (i=1; i<=max_nodeid; i++) { 386 for (i=1; i<=max_nodeid; i++) {
386 con = __nodeid2con(i, 0); 387 con = __nodeid2con(i, 0);
387 if (!con) 388 if (!con)
@@ -393,7 +394,7 @@ static void sctp_init_failed(void)
393 } 394 }
394 } 395 }
395 } 396 }
396 up(&connections_lock); 397 mutex_unlock(&connections_lock);
397} 398}
398 399
399/* Something happened to an association */ 400/* Something happened to an association */
@@ -890,8 +891,10 @@ static void tcp_connect_to_sock(struct connection *con)
890 goto out_err; 891 goto out_err;
891 892
892 memset(&saddr, 0, sizeof(saddr)); 893 memset(&saddr, 0, sizeof(saddr));
893 if (dlm_nodeid_to_addr(con->nodeid, &saddr)) 894 if (dlm_nodeid_to_addr(con->nodeid, &saddr)) {
895 sock_release(sock);
894 goto out_err; 896 goto out_err;
897 }
895 898
896 sock->sk->sk_user_data = con; 899 sock->sk->sk_user_data = con;
897 con->rx_action = receive_from_sock; 900 con->rx_action = receive_from_sock;
@@ -930,7 +933,7 @@ out_err:
930 * errors we try again until the max number of retries is reached. 933 * errors we try again until the max number of retries is reached.
931 */ 934 */
932 if (result != -EHOSTUNREACH && result != -ENETUNREACH && 935 if (result != -EHOSTUNREACH && result != -ENETUNREACH &&
933 result != -ENETDOWN && result != EINVAL 936 result != -ENETDOWN && result != -EINVAL
934 && result != -EPROTONOSUPPORT) { 937 && result != -EPROTONOSUPPORT) {
935 lowcomms_connect_sock(con); 938 lowcomms_connect_sock(con);
936 result = 0; 939 result = 0;
@@ -1417,7 +1420,7 @@ void dlm_lowcomms_stop(void)
1417 /* Set all the flags to prevent any 1420 /* Set all the flags to prevent any
1418 socket activity. 1421 socket activity.
1419 */ 1422 */
1420 down(&connections_lock); 1423 mutex_lock(&connections_lock);
1421 for (i = 0; i <= max_nodeid; i++) { 1424 for (i = 0; i <= max_nodeid; i++) {
1422 con = __nodeid2con(i, 0); 1425 con = __nodeid2con(i, 0);
1423 if (con) { 1426 if (con) {
@@ -1426,11 +1429,11 @@ void dlm_lowcomms_stop(void)
1426 con->sock->sk->sk_user_data = NULL; 1429 con->sock->sk->sk_user_data = NULL;
1427 } 1430 }
1428 } 1431 }
1429 up(&connections_lock); 1432 mutex_unlock(&connections_lock);
1430 1433
1431 work_stop(); 1434 work_stop();
1432 1435
1433 down(&connections_lock); 1436 mutex_lock(&connections_lock);
1434 clean_writequeues(); 1437 clean_writequeues();
1435 1438
1436 for (i = 0; i <= max_nodeid; i++) { 1439 for (i = 0; i <= max_nodeid; i++) {
@@ -1443,7 +1446,7 @@ void dlm_lowcomms_stop(void)
1443 } 1446 }
1444 } 1447 }
1445 max_nodeid = 0; 1448 max_nodeid = 0;
1446 up(&connections_lock); 1449 mutex_unlock(&connections_lock);
1447 kmem_cache_destroy(con_cache); 1450 kmem_cache_destroy(con_cache);
1448 idr_init(&connections_idr); 1451 idr_init(&connections_idr);
1449} 1452}