connection.c (82845079160817cc6ac64e5321bbd935e0a47b3a) | connection.c (ebeeb1ad9b8adcc37c2ec21a96f39e9d35199b46) |
---|---|
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: --- 206 unchanged lines hidden (view full) --- 215 conn->c_trans = trans; 216 217 init_waitqueue_head(&conn->c_hs_waitq); 218 for (i = 0; i < npaths; i++) { 219 __rds_conn_path_init(conn, &conn->c_path[i], 220 is_outgoing); 221 conn->c_path[i].cp_index = i; 222 } | 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: --- 206 unchanged lines hidden (view full) --- 215 conn->c_trans = trans; 216 217 init_waitqueue_head(&conn->c_hs_waitq); 218 for (i = 0; i < npaths; i++) { 219 __rds_conn_path_init(conn, &conn->c_path[i], 220 is_outgoing); 221 conn->c_path[i].cp_index = i; 222 } |
223 ret = trans->conn_alloc(conn, gfp); | 223 rcu_read_lock(); 224 if (rds_destroy_pending(conn)) 225 ret = -ENETDOWN; 226 else 227 ret = trans->conn_alloc(conn, gfp); |
224 if (ret) { | 228 if (ret) { |
229 rcu_read_unlock(); |
|
225 kfree(conn->c_path); 226 kmem_cache_free(rds_conn_slab, conn); 227 conn = ERR_PTR(ret); 228 goto out; 229 } 230 231 rdsdebug("allocated conn %p for %pI4 -> %pI4 over %s %s\n", 232 conn, &laddr, &faddr, --- 45 unchanged lines hidden (view full) --- 278 conn->c_my_gen_num = rds_gen_num; 279 conn->c_peer_gen_num = 0; 280 hlist_add_head_rcu(&conn->c_hash_node, head); 281 rds_cong_add_conn(conn); 282 rds_conn_count++; 283 } 284 } 285 spin_unlock_irqrestore(&rds_conn_lock, flags); | 230 kfree(conn->c_path); 231 kmem_cache_free(rds_conn_slab, conn); 232 conn = ERR_PTR(ret); 233 goto out; 234 } 235 236 rdsdebug("allocated conn %p for %pI4 -> %pI4 over %s %s\n", 237 conn, &laddr, &faddr, --- 45 unchanged lines hidden (view full) --- 283 conn->c_my_gen_num = rds_gen_num; 284 conn->c_peer_gen_num = 0; 285 hlist_add_head_rcu(&conn->c_hash_node, head); 286 rds_cong_add_conn(conn); 287 rds_conn_count++; 288 } 289 } 290 spin_unlock_irqrestore(&rds_conn_lock, flags); |
291 rcu_read_unlock(); |
|
286 287out: 288 return conn; 289} 290 291struct rds_connection *rds_conn_create(struct net *net, 292 __be32 laddr, __be32 faddr, 293 struct rds_transport *trans, gfp_t gfp) --- 83 unchanged lines hidden (view full) --- 377 378/* destroy a single rds_conn_path. rds_conn_destroy() iterates over 379 * all paths using rds_conn_path_destroy() 380 */ 381static void rds_conn_path_destroy(struct rds_conn_path *cp) 382{ 383 struct rds_message *rm, *rtmp; 384 | 292 293out: 294 return conn; 295} 296 297struct rds_connection *rds_conn_create(struct net *net, 298 __be32 laddr, __be32 faddr, 299 struct rds_transport *trans, gfp_t gfp) --- 83 unchanged lines hidden (view full) --- 383 384/* destroy a single rds_conn_path. rds_conn_destroy() iterates over 385 * all paths using rds_conn_path_destroy() 386 */ 387static void rds_conn_path_destroy(struct rds_conn_path *cp) 388{ 389 struct rds_message *rm, *rtmp; 390 |
385 set_bit(RDS_DESTROY_PENDING, &cp->cp_flags); 386 | |
387 if (!cp->cp_transport_data) 388 return; 389 390 /* make sure lingering queued work won't try to ref the conn */ | 391 if (!cp->cp_transport_data) 392 return; 393 394 /* make sure lingering queued work won't try to ref the conn */ |
391 synchronize_rcu(); | |
392 cancel_delayed_work_sync(&cp->cp_send_w); 393 cancel_delayed_work_sync(&cp->cp_recv_w); 394 395 rds_conn_path_drop(cp, true); 396 flush_work(&cp->cp_down_w); 397 398 /* tear down queued messages */ 399 list_for_each_entry_safe(rm, rtmp, --- 286 unchanged lines hidden (view full) --- 686/* 687 * Force a disconnect 688 */ 689void rds_conn_path_drop(struct rds_conn_path *cp, bool destroy) 690{ 691 atomic_set(&cp->cp_state, RDS_CONN_ERROR); 692 693 rcu_read_lock(); | 395 cancel_delayed_work_sync(&cp->cp_send_w); 396 cancel_delayed_work_sync(&cp->cp_recv_w); 397 398 rds_conn_path_drop(cp, true); 399 flush_work(&cp->cp_down_w); 400 401 /* tear down queued messages */ 402 list_for_each_entry_safe(rm, rtmp, --- 286 unchanged lines hidden (view full) --- 689/* 690 * Force a disconnect 691 */ 692void rds_conn_path_drop(struct rds_conn_path *cp, bool destroy) 693{ 694 atomic_set(&cp->cp_state, RDS_CONN_ERROR); 695 696 rcu_read_lock(); |
694 if (!destroy && test_bit(RDS_DESTROY_PENDING, &cp->cp_flags)) { | 697 if (!destroy && rds_destroy_pending(cp->cp_conn)) { |
695 rcu_read_unlock(); 696 return; 697 } 698 queue_work(rds_wq, &cp->cp_down_w); 699 rcu_read_unlock(); 700} 701EXPORT_SYMBOL_GPL(rds_conn_path_drop); 702 --- 6 unchanged lines hidden (view full) --- 709 710/* 711 * If the connection is down, trigger a connect. We may have scheduled a 712 * delayed reconnect however - in this case we should not interfere. 713 */ 714void rds_conn_path_connect_if_down(struct rds_conn_path *cp) 715{ 716 rcu_read_lock(); | 698 rcu_read_unlock(); 699 return; 700 } 701 queue_work(rds_wq, &cp->cp_down_w); 702 rcu_read_unlock(); 703} 704EXPORT_SYMBOL_GPL(rds_conn_path_drop); 705 --- 6 unchanged lines hidden (view full) --- 712 713/* 714 * If the connection is down, trigger a connect. We may have scheduled a 715 * delayed reconnect however - in this case we should not interfere. 716 */ 717void rds_conn_path_connect_if_down(struct rds_conn_path *cp) 718{ 719 rcu_read_lock(); |
717 if (test_bit(RDS_DESTROY_PENDING, &cp->cp_flags)) { | 720 if (rds_destroy_pending(cp->cp_conn)) { |
718 rcu_read_unlock(); 719 return; 720 } 721 if (rds_conn_path_state(cp) == RDS_CONN_DOWN && 722 !test_and_set_bit(RDS_RECONNECT_PENDING, &cp->cp_flags)) 723 queue_delayed_work(rds_wq, &cp->cp_conn_w, 0); 724 rcu_read_unlock(); 725} --- 20 unchanged lines hidden --- | 721 rcu_read_unlock(); 722 return; 723 } 724 if (rds_conn_path_state(cp) == RDS_CONN_DOWN && 725 !test_and_set_bit(RDS_RECONNECT_PENDING, &cp->cp_flags)) 726 queue_delayed_work(rds_wq, &cp->cp_conn_w, 0); 727 rcu_read_unlock(); 728} --- 20 unchanged lines hidden --- |