]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/dlm/lowcomms.c
[ARM] 4978/1: [AT91] KB9260 (CAM60) board support
[linux-2.6-omap-h63xx.git] / fs / dlm / lowcomms.c
index 9e9d2e82f40fb36a62307e92b5ab48285a3c4654..7c1e5e5cccd8ae97a87a618ad9818d5b35721553 100644 (file)
@@ -334,18 +334,8 @@ static void close_connection(struct connection *con, bool and_other)
                con->rx_page = NULL;
        }
 
-       /* If we are an 'othercon' then NULL the pointer to us
-          from the parent and tidy ourself up */
-       if (test_bit(CF_IS_OTHERCON, &con->flags)) {
-               struct connection *parent = __nodeid2con(con->nodeid, 0);
-               parent->othercon = NULL;
-               kmem_cache_free(con_cache, con);
-       }
-       else {
-               /* Parent connections get reused */
-               con->retries = 0;
-               mutex_unlock(&con->sock_mutex);
-       }
+       con->retries = 0;
+       mutex_unlock(&con->sock_mutex);
 }
 
 /* We only send shutdown messages to nodes that are not part of the cluster */
@@ -731,6 +721,8 @@ static int tcp_accept_from_sock(struct connection *con)
                        INIT_WORK(&othercon->swork, process_send_sockets);
                        INIT_WORK(&othercon->rwork, process_recv_sockets);
                        set_bit(CF_IS_OTHERCON, &othercon->flags);
+               }
+               if (!othercon->sock) {
                        newcon->othercon = othercon;
                        othercon->sock = newsock;
                        newsock->sk->sk_user_data = othercon;
@@ -872,7 +864,7 @@ static void sctp_init_assoc(struct connection *con)
 static void tcp_connect_to_sock(struct connection *con)
 {
        int result = -EHOSTUNREACH;
-       struct sockaddr_storage saddr;
+       struct sockaddr_storage saddr, src_addr;
        int addr_len;
        struct socket *sock;
 
@@ -906,6 +898,17 @@ static void tcp_connect_to_sock(struct connection *con)
        con->connect_action = tcp_connect_to_sock;
        add_sock(sock, con);
 
+       /* Bind to our cluster-known address connecting to avoid
+          routing problems */
+       memcpy(&src_addr, dlm_local_addr[0], sizeof(src_addr));
+       make_sockaddr(&src_addr, 0, &addr_len);
+       result = sock->ops->bind(sock, (struct sockaddr *) &src_addr,
+                                addr_len);
+       if (result < 0) {
+               log_print("could not bind for connect: %d", result);
+               /* This *may* not indicate a critical error */
+       }
+
        make_sockaddr(&saddr, dlm_config.ci_tcp_port, &addr_len);
 
        log_print("connecting to %d", con->nodeid);
@@ -1070,7 +1073,7 @@ static int sctp_listen_for_all(void)
        subscribe.sctp_shutdown_event = 1;
        subscribe.sctp_partial_delivery_event = 1;
 
-       result = kernel_setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
+       result = kernel_setsockopt(sock, SOL_SOCKET, SO_RCVBUFFORCE,
                                 (char *)&bufsize, sizeof(bufsize));
        if (result)
                log_print("Error increasing buffer space on socket %d", result);
@@ -1272,14 +1275,15 @@ static void send_to_sock(struct connection *con)
                if (len) {
                        ret = sendpage(con->sock, e->page, offset, len,
                                       msg_flags);
-                       if (ret == -EAGAIN || ret == 0)
+                       if (ret == -EAGAIN || ret == 0) {
+                               cond_resched();
                                goto out;
+                       }
                        if (ret <= 0)
                                goto send_error;
-               } else {
+               }
                        /* Don't starve people filling buffers */
                        cond_resched();
-               }
 
                spin_lock(&con->writequeue_lock);
                e->offset += ret;
@@ -1433,6 +1437,8 @@ void dlm_lowcomms_stop(void)
                con = __nodeid2con(i, 0);
                if (con) {
                        close_connection(con, true);
+                       if (con->othercon)
+                               kmem_cache_free(con_cache, con->othercon);
                        kmem_cache_free(con_cache, con);
                }
        }
@@ -1461,10 +1467,6 @@ int dlm_lowcomms_start(void)
        if (!con_cache)
                goto out;
 
-       /* Set some sysctl minima */
-       if (sysctl_rmem_max < NEEDED_RMEM)
-               sysctl_rmem_max = NEEDED_RMEM;
-
        /* Start listening */
        if (dlm_config.ci_protocol == 0)
                error = tcp_listen_for_all();