Skip to content

Commit 549f39a

Browse files
Tetsuo Handajgunthorpe
authored andcommitted
IB/isert: Avoid flush_scheduled_work() usage
Flushing system-wide workqueues is dangerous and will be forbidden. Replace system_wq with local isert_login_wq. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Tetsuo Handa <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 988d74d commit 549f39a

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

drivers/infiniband/ulp/isert/ib_isert.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ MODULE_PARM_DESC(sg_tablesize,
4242

4343
static DEFINE_MUTEX(device_list_mutex);
4444
static LIST_HEAD(device_list);
45+
static struct workqueue_struct *isert_login_wq;
4546
static struct workqueue_struct *isert_comp_wq;
4647
static struct workqueue_struct *isert_release_wq;
4748

@@ -1017,7 +1018,7 @@ isert_rx_login_req(struct isert_conn *isert_conn)
10171018
complete(&isert_conn->login_comp);
10181019
return;
10191020
}
1020-
schedule_delayed_work(&conn->login_work, 0);
1021+
queue_delayed_work(isert_login_wq, &conn->login_work, 0);
10211022
}
10221023

10231024
static struct iscsi_cmd
@@ -2348,9 +2349,9 @@ isert_get_login_rx(struct iscsi_conn *conn, struct iscsi_login *login)
23482349

23492350
/*
23502351
* For login requests after the first PDU, isert_rx_login_req() will
2351-
* kick schedule_delayed_work(&conn->login_work) as the packet is
2352-
* received, which turns this callback from iscsi_target_do_login_rx()
2353-
* into a NOP.
2352+
* kick queue_delayed_work(isert_login_wq, &conn->login_work) as
2353+
* the packet is received, which turns this callback from
2354+
* iscsi_target_do_login_rx() into a NOP.
23542355
*/
23552356
if (!login->first_request)
23562357
return 0;
@@ -2606,20 +2607,23 @@ static struct iscsit_transport iser_target_transport = {
26062607

26072608
static int __init isert_init(void)
26082609
{
2609-
int ret;
2610+
isert_login_wq = alloc_workqueue("isert_login_wq", 0, 0);
2611+
if (!isert_login_wq) {
2612+
isert_err("Unable to allocate isert_login_wq\n");
2613+
return -ENOMEM;
2614+
}
26102615

26112616
isert_comp_wq = alloc_workqueue("isert_comp_wq",
26122617
WQ_UNBOUND | WQ_HIGHPRI, 0);
26132618
if (!isert_comp_wq) {
26142619
isert_err("Unable to allocate isert_comp_wq\n");
2615-
return -ENOMEM;
2620+
goto destroy_login_wq;
26162621
}
26172622

26182623
isert_release_wq = alloc_workqueue("isert_release_wq", WQ_UNBOUND,
26192624
WQ_UNBOUND_MAX_ACTIVE);
26202625
if (!isert_release_wq) {
26212626
isert_err("Unable to allocate isert_release_wq\n");
2622-
ret = -ENOMEM;
26232627
goto destroy_comp_wq;
26242628
}
26252629

@@ -2630,17 +2634,20 @@ static int __init isert_init(void)
26302634

26312635
destroy_comp_wq:
26322636
destroy_workqueue(isert_comp_wq);
2637+
destroy_login_wq:
2638+
destroy_workqueue(isert_login_wq);
26332639

2634-
return ret;
2640+
return -ENOMEM;
26352641
}
26362642

26372643
static void __exit isert_exit(void)
26382644
{
2639-
flush_scheduled_work();
2645+
flush_workqueue(isert_login_wq);
26402646
destroy_workqueue(isert_release_wq);
26412647
destroy_workqueue(isert_comp_wq);
26422648
iscsit_unregister_transport(&iser_target_transport);
26432649
isert_info("iSER_TARGET[0] - Released iser_target_transport\n");
2650+
destroy_workqueue(isert_login_wq);
26442651
}
26452652

26462653
MODULE_DESCRIPTION("iSER-Target for mainline target infrastructure");

0 commit comments

Comments
 (0)