Skip to content

Commit f528ba2

Browse files
Ursula BraunJakub Kicinski
authored andcommitted
net/smc: introduce link group termination worker
Use a worker for link group termination to guarantee process context. Signed-off-by: Ursula Braun <[email protected]> Signed-off-by: Karsten Graul <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 2a0674f commit f528ba2

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

net/smc/smc_core.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,14 @@ static void smc_lgr_free_work(struct work_struct *work)
219219
smc_lgr_free(lgr);
220220
}
221221

222+
static void smc_lgr_terminate_work(struct work_struct *work)
223+
{
224+
struct smc_link_group *lgr = container_of(work, struct smc_link_group,
225+
terminate_work);
226+
227+
smc_lgr_terminate(lgr);
228+
}
229+
222230
/* create a new SMC link group */
223231
static int smc_lgr_create(struct smc_sock *smc, struct smc_init_info *ini)
224232
{
@@ -258,6 +266,7 @@ static int smc_lgr_create(struct smc_sock *smc, struct smc_init_info *ini)
258266
smc_lgr_list.num += SMC_LGR_NUM_INCR;
259267
memcpy(&lgr->id, (u8 *)&smc_lgr_list.num, SMC_LGR_ID_SIZE);
260268
INIT_DELAYED_WORK(&lgr->free_work, smc_lgr_free_work);
269+
INIT_WORK(&lgr->terminate_work, smc_lgr_terminate_work);
261270
lgr->conns_all = RB_ROOT;
262271
if (ini->is_smcd) {
263272
/* SMC-D specific settings */

net/smc/smc_core.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ struct smc_link_group {
202202

203203
u8 id[SMC_LGR_ID_SIZE]; /* unique lgr id */
204204
struct delayed_work free_work; /* delayed freeing of an lgr */
205+
struct work_struct terminate_work; /* abnormal lgr termination */
205206
u8 sync_err : 1; /* lgr no longer fits to peer */
206207
u8 terminating : 1;/* lgr is terminating */
207208
u8 freefast : 1; /* free worker scheduled fast */
@@ -282,6 +283,12 @@ static inline struct smc_connection *smc_lgr_find_conn(
282283
return res;
283284
}
284285

286+
static inline void smc_lgr_terminate_sched(struct smc_link_group *lgr)
287+
{
288+
if (!lgr->terminating)
289+
schedule_work(&lgr->terminate_work);
290+
}
291+
285292
struct smc_sock;
286293
struct smc_clc_msg_accept_confirm;
287294
struct smc_clc_msg_local;

net/smc/smc_llc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ static void smc_llc_rx_delete_link(struct smc_link *link,
475475
smc_llc_prep_delete_link(llc, link, SMC_LLC_RESP, true);
476476
}
477477
smc_llc_send_message(link, llc, sizeof(*llc));
478-
smc_lgr_schedule_free_work_fast(lgr);
478+
smc_lgr_terminate_sched(lgr);
479479
}
480480
}
481481

net/smc/smc_wr.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static inline void smc_wr_tx_process_cqe(struct ib_wc *wc)
101101
clear_bit(i, link->wr_tx_mask);
102102
}
103103
/* terminate connections of this link group abnormally */
104-
smc_lgr_terminate(smc_get_lgr(link));
104+
smc_lgr_terminate_sched(smc_get_lgr(link));
105105
}
106106
if (pnd_snd.handler)
107107
pnd_snd.handler(&pnd_snd.priv, link, wc->status);
@@ -191,7 +191,7 @@ int smc_wr_tx_get_free_slot(struct smc_link *link,
191191
SMC_WR_TX_WAIT_FREE_SLOT_TIME);
192192
if (!rc) {
193193
/* timeout - terminate connections */
194-
smc_lgr_terminate(smc_get_lgr(link));
194+
smc_lgr_terminate_sched(smc_get_lgr(link));
195195
return -EPIPE;
196196
}
197197
if (idx == link->wr_tx_cnt)
@@ -247,7 +247,7 @@ int smc_wr_tx_send(struct smc_link *link, struct smc_wr_tx_pend_priv *priv)
247247
rc = ib_post_send(link->roce_qp, &link->wr_tx_ibs[pend->idx], NULL);
248248
if (rc) {
249249
smc_wr_tx_put_slot(link, priv);
250-
smc_lgr_terminate(smc_get_lgr(link));
250+
smc_lgr_terminate_sched(smc_get_lgr(link));
251251
}
252252
return rc;
253253
}
@@ -272,7 +272,7 @@ int smc_wr_reg_send(struct smc_link *link, struct ib_mr *mr)
272272
SMC_WR_REG_MR_WAIT_TIME);
273273
if (!rc) {
274274
/* timeout - terminate connections */
275-
smc_lgr_terminate(smc_get_lgr(link));
275+
smc_lgr_terminate_sched(smc_get_lgr(link));
276276
return -EPIPE;
277277
}
278278
if (rc == -ERESTARTSYS)
@@ -373,7 +373,7 @@ static inline void smc_wr_rx_process_cqes(struct ib_wc wc[], int num)
373373
/* terminate connections of this link group
374374
* abnormally
375375
*/
376-
smc_lgr_terminate(smc_get_lgr(link));
376+
smc_lgr_terminate_sched(smc_get_lgr(link));
377377
break;
378378
default:
379379
smc_wr_rx_post(link); /* refill WR RX */

0 commit comments

Comments
 (0)