connection.c (9938b04472d5c59f8bd8152a548533a8599596a2) connection.c (0cb43965d42a21a7af41f88f1021b478dc102425)
1/*
2 * Copyright (c) 2006 Oracle. All rights reserved.
3 *
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:

--- 22 unchanged lines hidden (view full) ---

31 *
32 */
33#include <linux/kernel.h>
34#include <linux/list.h>
35#include <linux/slab.h>
36#include <linux/export.h>
37#include <net/inet_hashtables.h>
38
1/*
2 * Copyright (c) 2006 Oracle. All rights reserved.
3 *
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:

--- 22 unchanged lines hidden (view full) ---

31 *
32 */
33#include <linux/kernel.h>
34#include <linux/list.h>
35#include <linux/slab.h>
36#include <linux/export.h>
37#include <net/inet_hashtables.h>
38
39#include "rds_single_path.h"
39#include "rds.h"
40#include "loop.h"
41
42#define RDS_CONNECTION_HASH_BITS 12
43#define RDS_CONNECTION_HASH_ENTRIES (1 << RDS_CONNECTION_HASH_BITS)
44#define RDS_CONNECTION_HASH_MASK (RDS_CONNECTION_HASH_ENTRIES - 1)
45
46/* converting this to RCU is a chore for another day.. */

--- 103 unchanged lines hidden (view full) ---

150 goto out;
151 }
152
153 INIT_HLIST_NODE(&conn->c_hash_node);
154 conn->c_laddr = laddr;
155 conn->c_faddr = faddr;
156 spin_lock_init(&conn->c_lock);
157 conn->c_next_tx_seq = 1;
40#include "rds.h"
41#include "loop.h"
42
43#define RDS_CONNECTION_HASH_BITS 12
44#define RDS_CONNECTION_HASH_ENTRIES (1 << RDS_CONNECTION_HASH_BITS)
45#define RDS_CONNECTION_HASH_MASK (RDS_CONNECTION_HASH_ENTRIES - 1)
46
47/* converting this to RCU is a chore for another day.. */

--- 103 unchanged lines hidden (view full) ---

151 goto out;
152 }
153
154 INIT_HLIST_NODE(&conn->c_hash_node);
155 conn->c_laddr = laddr;
156 conn->c_faddr = faddr;
157 spin_lock_init(&conn->c_lock);
158 conn->c_next_tx_seq = 1;
159 conn->c_path[0].cp_conn = conn;
158 rds_conn_net_set(conn, net);
159
160 init_waitqueue_head(&conn->c_waitq);
161 INIT_LIST_HEAD(&conn->c_send_queue);
162 INIT_LIST_HEAD(&conn->c_retrans);
163
164 ret = rds_cong_get_maps(conn);
165 if (ret) {

--- 26 unchanged lines hidden (view full) ---

192 if (ret) {
193 kmem_cache_free(rds_conn_slab, conn);
194 conn = ERR_PTR(ret);
195 goto out;
196 }
197
198 atomic_set(&conn->c_state, RDS_CONN_DOWN);
199 conn->c_send_gen = 0;
160 rds_conn_net_set(conn, net);
161
162 init_waitqueue_head(&conn->c_waitq);
163 INIT_LIST_HEAD(&conn->c_send_queue);
164 INIT_LIST_HEAD(&conn->c_retrans);
165
166 ret = rds_cong_get_maps(conn);
167 if (ret) {

--- 26 unchanged lines hidden (view full) ---

194 if (ret) {
195 kmem_cache_free(rds_conn_slab, conn);
196 conn = ERR_PTR(ret);
197 goto out;
198 }
199
200 atomic_set(&conn->c_state, RDS_CONN_DOWN);
201 conn->c_send_gen = 0;
200 conn->c_outgoing = (is_outgoing ? 1 : 0);
202 conn->c_path[0].cp_outgoing = (is_outgoing ? 1 : 0);
201 conn->c_reconnect_jiffies = 0;
202 INIT_DELAYED_WORK(&conn->c_send_w, rds_send_worker);
203 INIT_DELAYED_WORK(&conn->c_recv_w, rds_recv_worker);
204 INIT_DELAYED_WORK(&conn->c_conn_w, rds_connect_worker);
205 INIT_WORK(&conn->c_down_w, rds_shutdown_worker);
206 mutex_init(&conn->c_cm_lock);
207 conn->c_flags = 0;
208

--- 106 unchanged lines hidden (view full) ---

315 * The passive side of an IB loopback connection is never added
316 * to the conn hash, so we never trigger a reconnect on this
317 * conn - the reconnect is always triggered by the active peer. */
318 cancel_delayed_work_sync(&conn->c_conn_w);
319 rcu_read_lock();
320 if (!hlist_unhashed(&conn->c_hash_node)) {
321 rcu_read_unlock();
322 if (conn->c_trans->t_type != RDS_TRANS_TCP ||
203 conn->c_reconnect_jiffies = 0;
204 INIT_DELAYED_WORK(&conn->c_send_w, rds_send_worker);
205 INIT_DELAYED_WORK(&conn->c_recv_w, rds_recv_worker);
206 INIT_DELAYED_WORK(&conn->c_conn_w, rds_connect_worker);
207 INIT_WORK(&conn->c_down_w, rds_shutdown_worker);
208 mutex_init(&conn->c_cm_lock);
209 conn->c_flags = 0;
210

--- 106 unchanged lines hidden (view full) ---

317 * The passive side of an IB loopback connection is never added
318 * to the conn hash, so we never trigger a reconnect on this
319 * conn - the reconnect is always triggered by the active peer. */
320 cancel_delayed_work_sync(&conn->c_conn_w);
321 rcu_read_lock();
322 if (!hlist_unhashed(&conn->c_hash_node)) {
323 rcu_read_unlock();
324 if (conn->c_trans->t_type != RDS_TRANS_TCP ||
323 conn->c_outgoing == 1)
324 rds_queue_reconnect(conn);
325 conn->c_path[0].cp_outgoing == 1)
326 rds_queue_reconnect(&conn->c_path[0]);
325 } else {
326 rcu_read_unlock();
327 }
328}
329
330/*
331 * Stop and free a connection.
332 *

--- 215 unchanged lines hidden (view full) ---

548 rds_conn_message_info_send);
549 rds_info_deregister_func(RDS_INFO_RETRANS_MESSAGES,
550 rds_conn_message_info_retrans);
551}
552
553/*
554 * Force a disconnect
555 */
327 } else {
328 rcu_read_unlock();
329 }
330}
331
332/*
333 * Stop and free a connection.
334 *

--- 215 unchanged lines hidden (view full) ---

550 rds_conn_message_info_send);
551 rds_info_deregister_func(RDS_INFO_RETRANS_MESSAGES,
552 rds_conn_message_info_retrans);
553}
554
555/*
556 * Force a disconnect
557 */
558void rds_conn_path_drop(struct rds_conn_path *cp)
559{
560 atomic_set(&cp->cp_state, RDS_CONN_ERROR);
561 queue_work(rds_wq, &cp->cp_down_w);
562}
563EXPORT_SYMBOL_GPL(rds_conn_path_drop);
564
556void rds_conn_drop(struct rds_connection *conn)
557{
565void rds_conn_drop(struct rds_connection *conn)
566{
558 atomic_set(&conn->c_state, RDS_CONN_ERROR);
559 queue_work(rds_wq, &conn->c_down_w);
567 rds_conn_path_drop(&conn->c_path[0]);
560}
561EXPORT_SYMBOL_GPL(rds_conn_drop);
562
563/*
564 * If the connection is down, trigger a connect. We may have scheduled a
565 * delayed reconnect however - in this case we should not interfere.
566 */
567void rds_conn_connect_if_down(struct rds_connection *conn)

--- 21 unchanged lines hidden ---
568}
569EXPORT_SYMBOL_GPL(rds_conn_drop);
570
571/*
572 * If the connection is down, trigger a connect. We may have scheduled a
573 * delayed reconnect however - in this case we should not interfere.
574 */
575void rds_conn_connect_if_down(struct rds_connection *conn)

--- 21 unchanged lines hidden ---