rds: Use atomic flag to track connections being destroyed
authorSowmini Varadhan <sowmini.varadhan@oracle.com>
Thu, 4 Jan 2018 14:52:59 +0000 (06:52 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 5 Jan 2018 18:39:18 +0000 (13:39 -0500)
Replace c_destroy_in_prog by using a bit in cp_flags that
can set/tested atomically.

Signed-off-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/rds/connection.c
net/rds/rds.h
net/rds/tcp_connect.c

index 6492c0b608a4361fd3dfa7820ae7745032800560..1eed197e694f6ed75e9019c5a925c6e91ccd3713 100644 (file)
@@ -366,7 +366,7 @@ void rds_conn_shutdown(struct rds_conn_path *cp)
         * to the conn hash, so we never trigger a reconnect on this
         * conn - the reconnect is always triggered by the active peer. */
        cancel_delayed_work_sync(&cp->cp_conn_w);
-       if (conn->c_destroy_in_prog)
+       if (test_bit(RDS_DESTROY_PENDING, &cp->cp_flags))
                return;
        rcu_read_lock();
        if (!hlist_unhashed(&conn->c_hash_node)) {
@@ -384,6 +384,8 @@ static void rds_conn_path_destroy(struct rds_conn_path *cp)
 {
        struct rds_message *rm, *rtmp;
 
+       set_bit(RDS_DESTROY_PENDING, &cp->cp_flags);
+
        if (!cp->cp_transport_data)
                return;
 
@@ -426,7 +428,6 @@ void rds_conn_destroy(struct rds_connection *conn)
                 "%pI4\n", conn, &conn->c_laddr,
                 &conn->c_faddr);
 
-       conn->c_destroy_in_prog = 1;
        /* Ensure conn will not be scheduled for reconnect */
        spin_lock_irq(&rds_conn_lock);
        hlist_del_init_rcu(&conn->c_hash_node);
@@ -685,7 +686,7 @@ void rds_conn_path_drop(struct rds_conn_path *cp, bool destroy)
 {
        atomic_set(&cp->cp_state, RDS_CONN_ERROR);
 
-       if (!destroy && cp->cp_conn->c_destroy_in_prog)
+       if (!destroy && test_bit(RDS_DESTROY_PENDING, &cp->cp_flags))
                return;
 
        queue_work(rds_wq, &cp->cp_down_w);
index d09f6c1facb4a83c5d47340e5ae7134230089388..374ae83b60d48e5b7974aa6c5990daa6e353cd57 100644 (file)
@@ -88,6 +88,7 @@ enum {
 #define RDS_RECONNECT_PENDING  1
 #define RDS_IN_XMIT            2
 #define RDS_RECV_REFILL                3
+#define        RDS_DESTROY_PENDING     4
 
 /* Max number of multipaths per RDS connection. Must be a power of 2 */
 #define        RDS_MPATH_WORKERS       8
@@ -139,8 +140,7 @@ struct rds_connection {
        __be32                  c_faddr;
        unsigned int            c_loopback:1,
                                c_ping_triggered:1,
-                               c_destroy_in_prog:1,
-                               c_pad_to_32:29;
+                               c_pad_to_32:30;
        int                     c_npaths;
        struct rds_connection   *c_passive;
        struct rds_transport    *c_trans;
index 46f74dad0e164438594d9f195d906c9921bb8b23..534c67aeb20f8a9babf3e133e18db5af14be4867 100644 (file)
@@ -170,7 +170,7 @@ void rds_tcp_conn_path_shutdown(struct rds_conn_path *cp)
                 cp->cp_conn, tc, sock);
 
        if (sock) {
-               if (cp->cp_conn->c_destroy_in_prog)
+               if (test_bit(RDS_DESTROY_PENDING, &cp->cp_flags))
                        rds_tcp_set_linger(sock);
                sock->ops->shutdown(sock, RCV_SHUTDOWN | SEND_SHUTDOWN);
                lock_sock(sock->sk);