Commit 8730c1dd authored by Hannes Reinecke's avatar Hannes Reinecke Committed by Christoph Hellwig

nvme-fc: use separate work queue to avoid warning

When tearing down a controller the following warning is issued:

WARNING: CPU: 0 PID: 30681 at ../kernel/workqueue.c:2418 check_flush_dependency

This happens as the err_work workqueue item is scheduled on the
system workqueue (which has WQ_MEM_RECLAIM not set), but is flushed
from a workqueue which has WQ_MEM_RECLAIM set.

Fix this by providing an FC-NVMe specific workqueue.

Fixes: 4cff280a ("nvme-fc: resolve io failures during connect")
Signed-off-by: default avatarHannes Reinecke <hare@suse.com>
Reviewed-by: default avatarJames Smart <james.smart@broadcom.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 87fd1253
...@@ -202,7 +202,7 @@ static LIST_HEAD(nvme_fc_lport_list); ...@@ -202,7 +202,7 @@ static LIST_HEAD(nvme_fc_lport_list);
static DEFINE_IDA(nvme_fc_local_port_cnt); static DEFINE_IDA(nvme_fc_local_port_cnt);
static DEFINE_IDA(nvme_fc_ctrl_cnt); static DEFINE_IDA(nvme_fc_ctrl_cnt);
static struct workqueue_struct *nvme_fc_wq;
/* /*
* These items are short-term. They will eventually be moved into * These items are short-term. They will eventually be moved into
...@@ -2054,7 +2054,7 @@ nvme_fc_error_recovery(struct nvme_fc_ctrl *ctrl, char *errmsg) ...@@ -2054,7 +2054,7 @@ nvme_fc_error_recovery(struct nvme_fc_ctrl *ctrl, char *errmsg)
*/ */
if (ctrl->ctrl.state == NVME_CTRL_CONNECTING) { if (ctrl->ctrl.state == NVME_CTRL_CONNECTING) {
active = atomic_xchg(&ctrl->err_work_active, 1); active = atomic_xchg(&ctrl->err_work_active, 1);
if (!active && !schedule_work(&ctrl->err_work)) { if (!active && !queue_work(nvme_fc_wq, &ctrl->err_work)) {
atomic_set(&ctrl->err_work_active, 0); atomic_set(&ctrl->err_work_active, 0);
WARN_ON(1); WARN_ON(1);
} }
...@@ -3399,6 +3399,10 @@ static int __init nvme_fc_init_module(void) ...@@ -3399,6 +3399,10 @@ static int __init nvme_fc_init_module(void)
{ {
int ret; int ret;
nvme_fc_wq = alloc_workqueue("nvme_fc_wq", WQ_MEM_RECLAIM, 0);
if (!nvme_fc_wq)
return -ENOMEM;
/* /*
* NOTE: * NOTE:
* It is expected that in the future the kernel will combine * It is expected that in the future the kernel will combine
...@@ -3416,7 +3420,7 @@ static int __init nvme_fc_init_module(void) ...@@ -3416,7 +3420,7 @@ static int __init nvme_fc_init_module(void)
ret = class_register(&fc_class); ret = class_register(&fc_class);
if (ret) { if (ret) {
pr_err("couldn't register class fc\n"); pr_err("couldn't register class fc\n");
return ret; goto out_destroy_wq;
} }
/* /*
...@@ -3440,6 +3444,9 @@ static int __init nvme_fc_init_module(void) ...@@ -3440,6 +3444,9 @@ static int __init nvme_fc_init_module(void)
device_destroy(&fc_class, MKDEV(0, 0)); device_destroy(&fc_class, MKDEV(0, 0));
out_destroy_class: out_destroy_class:
class_unregister(&fc_class); class_unregister(&fc_class);
out_destroy_wq:
destroy_workqueue(nvme_fc_wq);
return ret; return ret;
} }
...@@ -3456,6 +3463,7 @@ static void __exit nvme_fc_exit_module(void) ...@@ -3456,6 +3463,7 @@ static void __exit nvme_fc_exit_module(void)
device_destroy(&fc_class, MKDEV(0, 0)); device_destroy(&fc_class, MKDEV(0, 0));
class_unregister(&fc_class); class_unregister(&fc_class);
destroy_workqueue(nvme_fc_wq);
} }
module_init(nvme_fc_init_module); module_init(nvme_fc_init_module);
......
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