nvmet: use shared workqueue for file-ns
Subsystems (2)
PATCH 1/1 nvmet: use shared workqueue for file-ns
This patch removes the per-ns workqueue and adds per-subsys workqueue which is shared by all the namespaces belongs to the same subsystem to offload the I/O submission for buffered I/Os for the file-backed namespace.
Signed-off-by Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
--- drivers/nvme/target/core.c | 7 +++++++ drivers/nvme/target/io-cmd-file.c | 17 +++-------------- drivers/nvme/target/nvmet.h | 2 +- 3 files changed, 11 insertions(+), 15 deletions(-)
drivers/nvme/target/core.c +7 -0
@@ -1077,6 +1077,12 @@ struct nvmet_subsys *nvmet_subsys_alloc(const char *subsysnqn,INIT_LIST_HEAD (&subsys->ctrls);INIT_LIST_HEAD (&subsys->hosts); + subsys->file_wq =alloc_workqueue ("nvmet-file" ,WQ_MEM_RECLAIM ,0 ); +if (!subsys->file_wq) { +kfree (subsys->subsysnqn); +kfree (subsys); +return NULL ; + }return subsys; }
@@ -1087,6 +1093,7 @@ static void nvmet_subsys_free(struct kref *ref)WARN_ON_ONCE (!list_empty (&subsys->namespaces)); +destroy_workqueue (subsys->file_wq);kfree (subsys->subsysnqn);kfree (subsys); }
drivers/nvme/target/io-cmd-file.c +3 -14
@@ -16,11 +16,8 @@void nvmet_file_ns_disable (struct nvmet_ns *ns) {if (ns->file) { -if (ns->buffered_io) { -flush_workqueue (ns->file_wq); -destroy_workqueue (ns->file_wq); - ns->file_wq =NULL ; - } +if (ns->buffered_io) +flush_workqueue (ns->subsys->file_wq);mempool_destroy (ns->bvec_pool); ns->bvec_pool =NULL ;kmem_cache_destroy (ns->bvec_cache);
@@ -70,14 +67,6 @@ int nvmet_file_ns_enable(struct nvmet_ns *ns) goto err; } -if (ns->buffered_io) { - ns->file_wq =alloc_workqueue ("nvmet-file" ,WQ_MEM_RECLAIM ,0 ); -if (!ns->file_wq) { - ret = -ENOMEM ; - goto err; - } - } -return ret; err: ns->size =0 ;
@@ -215,7 +204,7 @@ static void nvmet_file_buffered_io_work(struct work_struct *w)static void nvmet_file_execute_rw_buffered_io (struct nvmet_req *req) {INIT_WORK (&req->f.work, nvmet_file_buffered_io_work); -queue_work (req->ns->file_wq, &req->f.work); +queue_work (req->ns->subsys->file_wq, &req->f.work); }static void nvmet_file_flush_work (struct work_struct *w)
drivers/nvme/target/nvmet.h +1 -1
@@ -66,7 +66,6 @@ struct nvmet_ns {uuid_t uuid;bool buffered_io; -struct workqueue_struct *file_wq;bool enabled;struct nvmet_subsys *subsys;const char *device_path;
@@ -181,6 +180,7 @@ struct nvmet_subsys {u64 serial;char *subsysnqn; +struct workqueue_struct *file_wq;struct config_group group;struct config_group namespaces_group;
Signature · 1 line
2.17.0
PATCH 1/1 nvmet: use shared workqueue for file-ns
Quoted 3 lines · Chaitanya Kulkarni
This patch removes the per-ns workqueue and adds per-subsys workqueue which is shared by all the namespaces belongs to the same subsystem to offload the I/O submission for buffered I/Os for the file-backed namespace.
I think we can just have an entirely global workqueue instead of the per-subsystem one. We can then also use it directly instead of needing the pointer in struct nvmet_ns.