Once a linkgroup is created successfully, it stays alive for a
certain time to service more connections potentially created.
If one of the initialization steps for a new linkgroup fails,
the linkgroup should not be reused by other connections following.

Signed-off-by: Ursula Braun <ubr...@linux.vnet.ibm.com>
---
 net/smc/af_smc.c   | 17 +++++++++++++++++
 net/smc/smc_core.c |  3 +++
 2 files changed, 20 insertions(+)

diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index 05cbcd3a6f60..cf0e11978b66 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -377,6 +377,15 @@ 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)
 {
@@ -513,6 +522,8 @@ static int smc_connect_rdma(struct smc_sock *smc)
        return rc ? rc : local_contact;
 
 decline_rdma_unlock:
+       if (local_contact == SMC_FIRST_CONTACT)
+               smc_lgr_forget(smc->conn.lgr);
        mutex_unlock(&smc_create_lgr_pending);
        smc_conn_free(&smc->conn);
 decline_rdma:
@@ -526,6 +537,8 @@ static int smc_connect_rdma(struct smc_sock *smc)
        goto out_connected;
 
 out_err_unlock:
+       if (local_contact == SMC_FIRST_CONTACT)
+               smc_lgr_forget(smc->conn.lgr);
        mutex_unlock(&smc_create_lgr_pending);
        smc_conn_free(&smc->conn);
 out_err:
@@ -906,6 +919,8 @@ static void smc_listen_work(struct work_struct *work)
        return;
 
 decline_rdma_unlock:
+       if (local_contact == SMC_FIRST_CONTACT)
+               smc_lgr_forget(new_smc->conn.lgr);
        mutex_unlock(&smc_create_lgr_pending);
 decline_rdma:
        /* RDMA setup failed, switch back to TCP */
@@ -918,6 +933,8 @@ static void smc_listen_work(struct work_struct *work)
        goto out_connected;
 
 out_err_unlock:
+       if (local_contact == SMC_FIRST_CONTACT)
+               smc_lgr_forget(new_smc->conn.lgr);
        mutex_unlock(&smc_create_lgr_pending);
 out_err:
        newsmcsk->sk_state = SMC_CLOSED;
diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
index 94f21116dac5..7406cbb41856 100644
--- a/net/smc/smc_core.c
+++ b/net/smc/smc_core.c
@@ -128,6 +128,8 @@ static void smc_lgr_free_work(struct work_struct *work)
        bool conns;
 
        spin_lock_bh(&smc_lgr_list.lock);
+       if (list_empty(&lgr->list))
+               goto free;
        read_lock_bh(&lgr->conns_lock);
        conns = RB_EMPTY_ROOT(&lgr->conns_all);
        read_unlock_bh(&lgr->conns_lock);
@@ -136,6 +138,7 @@ static void smc_lgr_free_work(struct work_struct *work)
                return;
        }
        list_del_init(&lgr->list); /* remove from smc_lgr_list */
+free:
        spin_unlock_bh(&smc_lgr_list.lock);
        smc_lgr_free(lgr);
 }
-- 
2.13.5

Reply via email to