RDS: use locking on the connection hash list
[linux-2.6.git] / net / rds / connection.c
index 7e4e9df..87df15b 100644 (file)
@@ -148,6 +148,7 @@ static struct rds_connection *__rds_conn_create(__be32 laddr, __be32 faddr,
 
        spin_lock_init(&conn->c_send_lock);
        atomic_set(&conn->c_send_generation, 1);
+       atomic_set(&conn->c_senders, 0);
        INIT_LIST_HEAD(&conn->c_send_queue);
        INIT_LIST_HEAD(&conn->c_retrans);
 
@@ -276,6 +277,12 @@ void rds_conn_shutdown(struct rds_connection *conn)
                spin_lock_irq(&conn->c_send_lock);
                spin_unlock_irq(&conn->c_send_lock);
 
+               while(atomic_read(&conn->c_senders)) {
+                       schedule_timeout(1);
+                       spin_lock_irq(&conn->c_send_lock);
+                       spin_unlock_irq(&conn->c_send_lock);
+               }
+
                conn->c_trans->conn_shutdown(conn);
                rds_conn_reset(conn);
 
@@ -314,7 +321,10 @@ void rds_conn_destroy(struct rds_connection *conn)
                 "%pI4\n", conn, &conn->c_laddr,
                 &conn->c_faddr);
 
+       /* Ensure conn will not be scheduled for reconnect */
+       spin_lock_irq(&rds_conn_lock);
        hlist_del_init(&conn->c_hash_node);
+       spin_unlock_irq(&rds_conn_lock);
 
        /* wait for the rds thread to shut it down */
        atomic_set(&conn->c_state, RDS_CONN_ERROR);