net/smc: prevent new connections on link group
authorKarsten Graul <kgraul@linux.vnet.ibm.com>
Thu, 1 Mar 2018 12:51:33 +0000 (13:51 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 1 Mar 2018 18:21:31 +0000 (13:21 -0500)
When the processing of a DELETE LINK message has started,
new connections should not be added to the link group that
is about to terminate.

Signed-off-by: Karsten Graul <kgraul@linux.vnet.ibm.com>
Signed-off-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/smc/af_smc.c
net/smc/smc_core.c
net/smc/smc_core.h
net/smc/smc_llc.c

index 5267ed19b67d3c144d3383cc711d4915785ab177..26684e0867501f99ad1f0c5b282fac6644c93276 100644 (file)
@@ -356,15 +356,6 @@ static void smc_link_save_peer_info(struct smc_link *link,
        link->peer_mtu = clc->qp_mtu;
 }
 
-static void smc_lgr_forget(struct smc_link_group *lgr)
-{
-       spin_lock_bh(&smc_lgr_list.lock);
-       /* do not use this link group for new connections */
-       if (!list_empty(&lgr->list))
-               list_del_init(&lgr->list);
-       spin_unlock_bh(&smc_lgr_list.lock);
-}
-
 /* setup for RDMA connection of client */
 static int smc_connect_rdma(struct smc_sock *smc)
 {
index eb343e15a7235a0541b3860d5ecb36f3d3912900..702ce5f85e97487f53ee03e2495de038fa8e744c 100644 (file)
@@ -308,6 +308,15 @@ void smc_lgr_free(struct smc_link_group *lgr)
        kfree(lgr);
 }
 
+void smc_lgr_forget(struct smc_link_group *lgr)
+{
+       spin_lock_bh(&smc_lgr_list.lock);
+       /* do not use this link group for new connections */
+       if (!list_empty(&lgr->list))
+               list_del_init(&lgr->list);
+       spin_unlock_bh(&smc_lgr_list.lock);
+}
+
 /* terminate linkgroup abnormally */
 void smc_lgr_terminate(struct smc_link_group *lgr)
 {
@@ -315,15 +324,7 @@ void smc_lgr_terminate(struct smc_link_group *lgr)
        struct smc_sock *smc;
        struct rb_node *node;
 
-       spin_lock_bh(&smc_lgr_list.lock);
-       if (list_empty(&lgr->list)) {
-               /* termination already triggered */
-               spin_unlock_bh(&smc_lgr_list.lock);
-               return;
-       }
-       /* do not use this link group for new connections */
-       list_del_init(&lgr->list);
-       spin_unlock_bh(&smc_lgr_list.lock);
+       smc_lgr_forget(lgr);
 
        write_lock_bh(&lgr->conns_lock);
        node = rb_first(&lgr->conns_all);
index cead2093c4b404409584fbca2a65465d3aaba35d..07e2a393e6d98b672d4160ff1486c0bd6e43df4b 100644 (file)
@@ -197,6 +197,7 @@ struct smc_sock;
 struct smc_clc_msg_accept_confirm;
 
 void smc_lgr_free(struct smc_link_group *lgr);
+void smc_lgr_forget(struct smc_link_group *lgr);
 void smc_lgr_terminate(struct smc_link_group *lgr);
 int smc_buf_create(struct smc_sock *smc);
 int smc_rmb_rtoken_handling(struct smc_connection *conn,
index 45b3e0211c3945f272ae8e698f31ba375a11e6f4..54e8d6dc9201442df39a9980cb260912e39363eb 100644 (file)
@@ -384,6 +384,7 @@ static void smc_llc_rx_delete_link(struct smc_link *link,
                        smc_lgr_terminate(lgr);
        } else {
                if (lgr->role == SMC_SERV) {
+                       smc_lgr_forget(lgr);
                        smc_llc_send_delete_link(link, SMC_LLC_REQ);
                } else {
                        smc_llc_send_delete_link(link, SMC_LLC_RESP);