Commit 5ea7c133 authored by Jack Wang's avatar Jack Wang Committed by Jens Axboe

block/rnbd-clt: Avoid flush_workqueue(system_long_wq) usage

Flushing system-wide workqueues is dangerous and will be forbidden.

Replace system_long_wq with local rnbd_clt_wq.

Link: https://lkml.kernel.org/r/49925af7-78a8-a3dd-bce6-cfc02e1a9236@I-love.SAKURA.ne.jp

Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: default avatarJack Wang <jinpu.wang@ionos.com>
Reviewed-by: default avatarSantosh Kumar Pradhan <santosh.pradhan@ionos.com>
Link: https://lore.kernel.org/r/20220413123420.66470-1-jinpu.wang@ionos.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent d292dc80
...@@ -25,6 +25,7 @@ static int rnbd_client_major; ...@@ -25,6 +25,7 @@ static int rnbd_client_major;
static DEFINE_IDA(index_ida); static DEFINE_IDA(index_ida);
static DEFINE_MUTEX(sess_lock); static DEFINE_MUTEX(sess_lock);
static LIST_HEAD(sess_list); static LIST_HEAD(sess_list);
static struct workqueue_struct *rnbd_clt_wq;
/* /*
* Maximum number of partitions an instance can have. * Maximum number of partitions an instance can have.
...@@ -1759,12 +1760,12 @@ static void rnbd_destroy_sessions(void) ...@@ -1759,12 +1760,12 @@ static void rnbd_destroy_sessions(void)
* procedure takes minutes. * procedure takes minutes.
*/ */
INIT_WORK(&dev->unmap_on_rmmod_work, unmap_device_work); INIT_WORK(&dev->unmap_on_rmmod_work, unmap_device_work);
queue_work(system_long_wq, &dev->unmap_on_rmmod_work); queue_work(rnbd_clt_wq, &dev->unmap_on_rmmod_work);
} }
rnbd_clt_put_sess(sess); rnbd_clt_put_sess(sess);
} }
/* Wait for all scheduled unmap works */ /* Wait for all scheduled unmap works */
flush_workqueue(system_long_wq); flush_workqueue(rnbd_clt_wq);
WARN_ON(!list_empty(&sess_list)); WARN_ON(!list_empty(&sess_list));
} }
...@@ -1789,6 +1790,14 @@ static int __init rnbd_client_init(void) ...@@ -1789,6 +1790,14 @@ static int __init rnbd_client_init(void)
pr_err("Failed to load module, creating sysfs device files failed, err: %d\n", pr_err("Failed to load module, creating sysfs device files failed, err: %d\n",
err); err);
unregister_blkdev(rnbd_client_major, "rnbd"); unregister_blkdev(rnbd_client_major, "rnbd");
return err;
}
rnbd_clt_wq = alloc_workqueue("rnbd_clt_wq", 0, 0);
if (!rnbd_clt_wq) {
pr_err("Failed to load module, alloc_workqueue failed.\n");
rnbd_clt_destroy_sysfs_files();
unregister_blkdev(rnbd_client_major, "rnbd");
err = -ENOMEM;
} }
return err; return err;
...@@ -1799,6 +1808,7 @@ static void __exit rnbd_client_exit(void) ...@@ -1799,6 +1808,7 @@ static void __exit rnbd_client_exit(void)
rnbd_destroy_sessions(); rnbd_destroy_sessions();
unregister_blkdev(rnbd_client_major, "rnbd"); unregister_blkdev(rnbd_client_major, "rnbd");
ida_destroy(&index_ida); ida_destroy(&index_ida);
destroy_workqueue(rnbd_clt_wq);
} }
module_init(rnbd_client_init); module_init(rnbd_client_init);
......
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