connection.c (d769ef81d5b5932520fbefb02614a4380c132495) | connection.c (3ecc5693c02bb154bc8609c640eb862804c4aabb) |
---|---|
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" | |
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.. */ --- 311 unchanged lines hidden (view full) --- 359 if (conn->c_trans->t_type != RDS_TRANS_TCP || 360 cp->cp_outgoing == 1) 361 rds_queue_reconnect(cp); 362 } else { 363 rcu_read_unlock(); 364 } 365} 366 | 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.. */ --- 311 unchanged lines hidden (view full) --- 358 if (conn->c_trans->t_type != RDS_TRANS_TCP || 359 cp->cp_outgoing == 1) 360 rds_queue_reconnect(cp); 361 } else { 362 rcu_read_unlock(); 363 } 364} 365 |
366/* destroy a single rds_conn_path. rds_conn_destroy() iterates over 367 * all paths using rds_conn_path_destroy() 368 */ 369static void rds_conn_path_destroy(struct rds_conn_path *cp) 370{ 371 struct rds_message *rm, *rtmp; 372 373 rds_conn_path_drop(cp); 374 flush_work(&cp->cp_down_w); 375 376 /* make sure lingering queued work won't try to ref the conn */ 377 cancel_delayed_work_sync(&cp->cp_send_w); 378 cancel_delayed_work_sync(&cp->cp_recv_w); 379 380 /* tear down queued messages */ 381 list_for_each_entry_safe(rm, rtmp, 382 &cp->cp_send_queue, 383 m_conn_item) { 384 list_del_init(&rm->m_conn_item); 385 BUG_ON(!list_empty(&rm->m_sock_item)); 386 rds_message_put(rm); 387 } 388 if (cp->cp_xmit_rm) 389 rds_message_put(cp->cp_xmit_rm); 390 391 cp->cp_conn->c_trans->conn_free(cp->cp_transport_data); 392} 393 |
|
367/* 368 * Stop and free a connection. 369 * 370 * This can only be used in very limited circumstances. It assumes that once 371 * the conn has been shutdown that no one else is referencing the connection. 372 * We can only ensure this in the rmmod path in the current code. 373 */ 374void rds_conn_destroy(struct rds_connection *conn) 375{ | 394/* 395 * Stop and free a connection. 396 * 397 * This can only be used in very limited circumstances. It assumes that once 398 * the conn has been shutdown that no one else is referencing the connection. 399 * We can only ensure this in the rmmod path in the current code. 400 */ 401void rds_conn_destroy(struct rds_connection *conn) 402{ |
376 struct rds_message *rm, *rtmp; | |
377 unsigned long flags; 378 379 rdsdebug("freeing conn %p for %pI4 -> " 380 "%pI4\n", conn, &conn->c_laddr, 381 &conn->c_faddr); 382 383 /* Ensure conn will not be scheduled for reconnect */ 384 spin_lock_irq(&rds_conn_lock); 385 hlist_del_init_rcu(&conn->c_hash_node); 386 spin_unlock_irq(&rds_conn_lock); 387 synchronize_rcu(); 388 389 /* shut the connection down */ | 403 unsigned long flags; 404 405 rdsdebug("freeing conn %p for %pI4 -> " 406 "%pI4\n", conn, &conn->c_laddr, 407 &conn->c_faddr); 408 409 /* Ensure conn will not be scheduled for reconnect */ 410 spin_lock_irq(&rds_conn_lock); 411 hlist_del_init_rcu(&conn->c_hash_node); 412 spin_unlock_irq(&rds_conn_lock); 413 synchronize_rcu(); 414 415 /* shut the connection down */ |
390 rds_conn_drop(conn); 391 flush_work(&conn->c_down_w); | 416 if (!conn->c_trans->t_mp_capable) { 417 rds_conn_path_destroy(&conn->c_path[0]); 418 BUG_ON(!list_empty(&conn->c_path[0].cp_retrans)); 419 } else { 420 int i; 421 struct rds_conn_path *cp; |
392 | 422 |
393 /* make sure lingering queued work won't try to ref the conn */ 394 cancel_delayed_work_sync(&conn->c_send_w); 395 cancel_delayed_work_sync(&conn->c_recv_w); 396 397 /* tear down queued messages */ 398 list_for_each_entry_safe(rm, rtmp, 399 &conn->c_send_queue, 400 m_conn_item) { 401 list_del_init(&rm->m_conn_item); 402 BUG_ON(!list_empty(&rm->m_sock_item)); 403 rds_message_put(rm); | 423 for (i = 0; i < RDS_MPATH_WORKERS; i++) { 424 cp = &conn->c_path[i]; 425 rds_conn_path_destroy(cp); 426 BUG_ON(!list_empty(&cp->cp_retrans)); 427 } |
404 } | 428 } |
405 if (conn->c_xmit_rm) 406 rds_message_put(conn->c_xmit_rm); | |
407 | 429 |
408 conn->c_trans->conn_free(conn->c_transport_data); 409 | |
410 /* 411 * The congestion maps aren't freed up here. They're 412 * freed by rds_cong_exit() after all the connections 413 * have been freed. 414 */ 415 rds_cong_remove_conn(conn); 416 | 430 /* 431 * The congestion maps aren't freed up here. They're 432 * freed by rds_cong_exit() after all the connections 433 * have been freed. 434 */ 435 rds_cong_remove_conn(conn); 436 |
417 BUG_ON(!list_empty(&conn->c_retrans)); | |
418 kmem_cache_free(rds_conn_slab, conn); 419 420 spin_lock_irqsave(&rds_conn_lock, flags); 421 rds_conn_count--; 422 spin_unlock_irqrestore(&rds_conn_lock, flags); 423} 424EXPORT_SYMBOL_GPL(rds_conn_destroy); 425 --- 279 unchanged lines hidden --- | 437 kmem_cache_free(rds_conn_slab, conn); 438 439 spin_lock_irqsave(&rds_conn_lock, flags); 440 rds_conn_count--; 441 spin_unlock_irqrestore(&rds_conn_lock, flags); 442} 443EXPORT_SYMBOL_GPL(rds_conn_destroy); 444 --- 279 unchanged lines hidden --- |