Commit 549f39a5 authored by Tetsuo Handa's avatar Tetsuo Handa Committed by Jason Gunthorpe

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/fbe5e9a8-0110-0c22-b7d6-74d53948d042@I-love.SAKURA.ne.jpSigned-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Reviewed-by: default avatarSagi Grimberg <sagi@grimberg.me>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent 988d74de
...@@ -42,6 +42,7 @@ MODULE_PARM_DESC(sg_tablesize, ...@@ -42,6 +42,7 @@ MODULE_PARM_DESC(sg_tablesize,
static DEFINE_MUTEX(device_list_mutex); static DEFINE_MUTEX(device_list_mutex);
static LIST_HEAD(device_list); static LIST_HEAD(device_list);
static struct workqueue_struct *isert_login_wq;
static struct workqueue_struct *isert_comp_wq; static struct workqueue_struct *isert_comp_wq;
static struct workqueue_struct *isert_release_wq; static struct workqueue_struct *isert_release_wq;
...@@ -1017,7 +1018,7 @@ isert_rx_login_req(struct isert_conn *isert_conn) ...@@ -1017,7 +1018,7 @@ isert_rx_login_req(struct isert_conn *isert_conn)
complete(&isert_conn->login_comp); complete(&isert_conn->login_comp);
return; return;
} }
schedule_delayed_work(&conn->login_work, 0); queue_delayed_work(isert_login_wq, &conn->login_work, 0);
} }
static struct iscsi_cmd static struct iscsi_cmd
...@@ -2348,9 +2349,9 @@ isert_get_login_rx(struct iscsi_conn *conn, struct iscsi_login *login) ...@@ -2348,9 +2349,9 @@ isert_get_login_rx(struct iscsi_conn *conn, struct iscsi_login *login)
/* /*
* For login requests after the first PDU, isert_rx_login_req() will * For login requests after the first PDU, isert_rx_login_req() will
* kick schedule_delayed_work(&conn->login_work) as the packet is * kick queue_delayed_work(isert_login_wq, &conn->login_work) as
* received, which turns this callback from iscsi_target_do_login_rx() * the packet is received, which turns this callback from
* into a NOP. * iscsi_target_do_login_rx() into a NOP.
*/ */
if (!login->first_request) if (!login->first_request)
return 0; return 0;
...@@ -2606,20 +2607,23 @@ static struct iscsit_transport iser_target_transport = { ...@@ -2606,20 +2607,23 @@ static struct iscsit_transport iser_target_transport = {
static int __init isert_init(void) static int __init isert_init(void)
{ {
int ret; isert_login_wq = alloc_workqueue("isert_login_wq", 0, 0);
if (!isert_login_wq) {
isert_err("Unable to allocate isert_login_wq\n");
return -ENOMEM;
}
isert_comp_wq = alloc_workqueue("isert_comp_wq", isert_comp_wq = alloc_workqueue("isert_comp_wq",
WQ_UNBOUND | WQ_HIGHPRI, 0); WQ_UNBOUND | WQ_HIGHPRI, 0);
if (!isert_comp_wq) { if (!isert_comp_wq) {
isert_err("Unable to allocate isert_comp_wq\n"); isert_err("Unable to allocate isert_comp_wq\n");
return -ENOMEM; goto destroy_login_wq;
} }
isert_release_wq = alloc_workqueue("isert_release_wq", WQ_UNBOUND, isert_release_wq = alloc_workqueue("isert_release_wq", WQ_UNBOUND,
WQ_UNBOUND_MAX_ACTIVE); WQ_UNBOUND_MAX_ACTIVE);
if (!isert_release_wq) { if (!isert_release_wq) {
isert_err("Unable to allocate isert_release_wq\n"); isert_err("Unable to allocate isert_release_wq\n");
ret = -ENOMEM;
goto destroy_comp_wq; goto destroy_comp_wq;
} }
...@@ -2630,17 +2634,20 @@ static int __init isert_init(void) ...@@ -2630,17 +2634,20 @@ static int __init isert_init(void)
destroy_comp_wq: destroy_comp_wq:
destroy_workqueue(isert_comp_wq); destroy_workqueue(isert_comp_wq);
destroy_login_wq:
destroy_workqueue(isert_login_wq);
return ret; return -ENOMEM;
} }
static void __exit isert_exit(void) static void __exit isert_exit(void)
{ {
flush_scheduled_work(); flush_workqueue(isert_login_wq);
destroy_workqueue(isert_release_wq); destroy_workqueue(isert_release_wq);
destroy_workqueue(isert_comp_wq); destroy_workqueue(isert_comp_wq);
iscsit_unregister_transport(&iser_target_transport); iscsit_unregister_transport(&iser_target_transport);
isert_info("iSER_TARGET[0] - Released iser_target_transport\n"); isert_info("iSER_TARGET[0] - Released iser_target_transport\n");
destroy_workqueue(isert_login_wq);
} }
MODULE_DESCRIPTION("iSER-Target for mainline target infrastructure"); MODULE_DESCRIPTION("iSER-Target for mainline target infrastructure");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment