Skip to content

Commit 610db66

Browse files
Ursula Braundavem330
authored andcommitted
net/smc: do not reuse a linkgroup with setup problems
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b4772b3 commit 610db66

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

net/smc/af_smc.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,15 @@ static void smc_link_save_peer_info(struct smc_link *link,
377377
link->peer_mtu = clc->qp_mtu;
378378
}
379379

380+
static void smc_lgr_forget(struct smc_link_group *lgr)
381+
{
382+
spin_lock_bh(&smc_lgr_list.lock);
383+
/* do not use this link group for new connections */
384+
if (!list_empty(&lgr->list))
385+
list_del_init(&lgr->list);
386+
spin_unlock_bh(&smc_lgr_list.lock);
387+
}
388+
380389
/* setup for RDMA connection of client */
381390
static int smc_connect_rdma(struct smc_sock *smc)
382391
{
@@ -513,6 +522,8 @@ static int smc_connect_rdma(struct smc_sock *smc)
513522
return rc ? rc : local_contact;
514523

515524
decline_rdma_unlock:
525+
if (local_contact == SMC_FIRST_CONTACT)
526+
smc_lgr_forget(smc->conn.lgr);
516527
mutex_unlock(&smc_create_lgr_pending);
517528
smc_conn_free(&smc->conn);
518529
decline_rdma:
@@ -526,6 +537,8 @@ static int smc_connect_rdma(struct smc_sock *smc)
526537
goto out_connected;
527538

528539
out_err_unlock:
540+
if (local_contact == SMC_FIRST_CONTACT)
541+
smc_lgr_forget(smc->conn.lgr);
529542
mutex_unlock(&smc_create_lgr_pending);
530543
smc_conn_free(&smc->conn);
531544
out_err:
@@ -906,6 +919,8 @@ static void smc_listen_work(struct work_struct *work)
906919
return;
907920

908921
decline_rdma_unlock:
922+
if (local_contact == SMC_FIRST_CONTACT)
923+
smc_lgr_forget(new_smc->conn.lgr);
909924
mutex_unlock(&smc_create_lgr_pending);
910925
decline_rdma:
911926
/* RDMA setup failed, switch back to TCP */
@@ -918,6 +933,8 @@ static void smc_listen_work(struct work_struct *work)
918933
goto out_connected;
919934

920935
out_err_unlock:
936+
if (local_contact == SMC_FIRST_CONTACT)
937+
smc_lgr_forget(new_smc->conn.lgr);
921938
mutex_unlock(&smc_create_lgr_pending);
922939
out_err:
923940
newsmcsk->sk_state = SMC_CLOSED;

net/smc/smc_core.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ static void smc_lgr_free_work(struct work_struct *work)
128128
bool conns;
129129

130130
spin_lock_bh(&smc_lgr_list.lock);
131+
if (list_empty(&lgr->list))
132+
goto free;
131133
read_lock_bh(&lgr->conns_lock);
132134
conns = RB_EMPTY_ROOT(&lgr->conns_all);
133135
read_unlock_bh(&lgr->conns_lock);
@@ -136,6 +138,7 @@ static void smc_lgr_free_work(struct work_struct *work)
136138
return;
137139
}
138140
list_del_init(&lgr->list); /* remove from smc_lgr_list */
141+
free:
139142
spin_unlock_bh(&smc_lgr_list.lock);
140143
smc_lgr_free(lgr);
141144
}

0 commit comments

Comments
 (0)