From: Christoph Hellwig <hch@lst.de>
To: Keith Busch <kbusch@kernel.org>, Sagi Grimberg <sagi@grimberg.me>,
James Smart <james.smart@broadcom.com>
Cc: linux-nvme@lists.infradead.org
Subject: [PATCH 09/13] nvme-fc: use the tagset alloc/free helpers
Date: Tue, 20 Sep 2022 19:16:07 +0200 [thread overview]
Message-ID: <20220920171611.1289361-10-hch@lst.de> (raw)
In-Reply-To: <20220920171611.1289361-1-hch@lst.de>
Use the common helpers to allocate and free the tagsets. To make this
work the generic nvme_ctrl now needs to be stored in the hctx private
data instead of the nvme_fc_ctrl.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/nvme/host/fc.c | 83 +++++++++---------------------------------
1 file changed, 17 insertions(+), 66 deletions(-)
diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index d707cf93f1f4b..5d57a042dbcad 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -2383,10 +2383,8 @@ nvme_fc_ctrl_free(struct kref *ref)
container_of(ref, struct nvme_fc_ctrl, ref);
unsigned long flags;
- if (ctrl->ctrl.tagset) {
- blk_mq_destroy_queue(ctrl->ctrl.connect_q);
- blk_mq_free_tag_set(&ctrl->tag_set);
- }
+ if (ctrl->ctrl.tagset)
+ nvme_remove_io_tag_set(&ctrl->ctrl);
/* remove from rport list */
spin_lock_irqsave(&ctrl->rport->lock, flags);
@@ -2394,9 +2392,7 @@ nvme_fc_ctrl_free(struct kref *ref)
spin_unlock_irqrestore(&ctrl->rport->lock, flags);
nvme_start_admin_queue(&ctrl->ctrl);
- blk_mq_destroy_queue(ctrl->ctrl.admin_q);
- blk_mq_destroy_queue(ctrl->ctrl.fabrics_q);
- blk_mq_free_tag_set(&ctrl->admin_tag_set);
+ nvme_remove_admin_tag_set(&ctrl->ctrl);
kfree(ctrl->queues);
@@ -2906,32 +2902,16 @@ nvme_fc_create_io_queues(struct nvme_fc_ctrl *ctrl)
nvme_fc_init_io_queues(ctrl);
- memset(&ctrl->tag_set, 0, sizeof(ctrl->tag_set));
- ctrl->tag_set.ops = &nvme_fc_mq_ops;
- ctrl->tag_set.queue_depth = ctrl->ctrl.opts->queue_size;
- ctrl->tag_set.reserved_tags = NVMF_RESERVED_TAGS;
- ctrl->tag_set.numa_node = ctrl->ctrl.numa_node;
- ctrl->tag_set.flags = BLK_MQ_F_SHOULD_MERGE;
- ctrl->tag_set.cmd_size =
- struct_size((struct nvme_fcp_op_w_sgl *)NULL, priv,
- ctrl->lport->ops->fcprqst_priv_sz);
- ctrl->tag_set.driver_data = &ctrl->ctrl;
- ctrl->tag_set.nr_hw_queues = ctrl->ctrl.queue_count - 1;
- ctrl->tag_set.timeout = NVME_IO_TIMEOUT;
-
- ret = blk_mq_alloc_tag_set(&ctrl->tag_set);
+ ret = nvme_alloc_io_tag_set(&ctrl->ctrl, &ctrl->tag_set,
+ &nvme_fc_mq_ops, BLK_MQ_F_SHOULD_MERGE,
+ struct_size((struct nvme_fcp_op_w_sgl *)NULL, priv,
+ ctrl->lport->ops->fcprqst_priv_sz));
if (ret)
return ret;
- ctrl->ctrl.tagset = &ctrl->tag_set;
-
- ret = nvme_ctrl_init_connect_q(&(ctrl->ctrl));
- if (ret)
- goto out_free_tag_set;
-
ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize + 1);
if (ret)
- goto out_cleanup_blk_queue;
+ goto out_cleanup_tagset;
ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.sqsize + 1);
if (ret)
@@ -2943,10 +2923,8 @@ nvme_fc_create_io_queues(struct nvme_fc_ctrl *ctrl)
out_delete_hw_queues:
nvme_fc_delete_hw_io_queues(ctrl);
-out_cleanup_blk_queue:
- blk_mq_destroy_queue(ctrl->ctrl.connect_q);
-out_free_tag_set:
- blk_mq_free_tag_set(&ctrl->tag_set);
+out_cleanup_tagset:
+ nvme_remove_io_tag_set(&ctrl->ctrl);
nvme_fc_free_io_queues(ctrl);
/* force put free routine to ignore io queues */
@@ -3530,35 +3508,12 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
nvme_fc_init_queue(ctrl, 0);
- memset(&ctrl->admin_tag_set, 0, sizeof(ctrl->admin_tag_set));
- ctrl->admin_tag_set.ops = &nvme_fc_admin_mq_ops;
- ctrl->admin_tag_set.queue_depth = NVME_AQ_MQ_TAG_DEPTH;
- ctrl->admin_tag_set.reserved_tags = NVMF_RESERVED_TAGS;
- ctrl->admin_tag_set.numa_node = ctrl->ctrl.numa_node;
- ctrl->admin_tag_set.cmd_size =
- struct_size((struct nvme_fcp_op_w_sgl *)NULL, priv,
- ctrl->lport->ops->fcprqst_priv_sz);
- ctrl->admin_tag_set.driver_data = &ctrl->ctrl;
- ctrl->admin_tag_set.nr_hw_queues = 1;
- ctrl->admin_tag_set.timeout = NVME_ADMIN_TIMEOUT;
- ctrl->admin_tag_set.flags = BLK_MQ_F_NO_SCHED;
-
- ret = blk_mq_alloc_tag_set(&ctrl->admin_tag_set);
+ ret = nvme_alloc_admin_tag_set(&ctrl->ctrl, &ctrl->admin_tag_set,
+ &nvme_fc_admin_mq_ops, BLK_MQ_F_NO_SCHED,
+ struct_size((struct nvme_fcp_op_w_sgl *)NULL, priv,
+ ctrl->lport->ops->fcprqst_priv_sz));
if (ret)
goto out_free_queues;
- ctrl->ctrl.admin_tagset = &ctrl->admin_tag_set;
-
- ctrl->ctrl.fabrics_q = blk_mq_init_queue(&ctrl->admin_tag_set);
- if (IS_ERR(ctrl->ctrl.fabrics_q)) {
- ret = PTR_ERR(ctrl->ctrl.fabrics_q);
- goto out_free_admin_tag_set;
- }
-
- ctrl->ctrl.admin_q = blk_mq_init_queue(&ctrl->admin_tag_set);
- if (IS_ERR(ctrl->ctrl.admin_q)) {
- ret = PTR_ERR(ctrl->ctrl.admin_q);
- goto out_cleanup_fabrics_q;
- }
/*
* Would have been nice to init io queues tag set as well.
@@ -3569,7 +3524,7 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
ret = nvme_init_ctrl(&ctrl->ctrl, dev, &nvme_fc_ctrl_ops, 0);
if (ret)
- goto out_cleanup_admin_q;
+ goto out_cleanup_tagset;
/* at this point, teardown path changes to ref counting on nvme ctrl */
@@ -3624,12 +3579,8 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
return ERR_PTR(-EIO);
-out_cleanup_admin_q:
- blk_mq_destroy_queue(ctrl->ctrl.admin_q);
-out_cleanup_fabrics_q:
- blk_mq_destroy_queue(ctrl->ctrl.fabrics_q);
-out_free_admin_tag_set:
- blk_mq_free_tag_set(&ctrl->admin_tag_set);
+out_cleanup_tagset:
+ nvme_remove_admin_tag_set(&ctrl->ctrl);
out_free_queues:
kfree(ctrl->queues);
out_free_ida:
--
2.30.2
next prev parent reply other threads:[~2022-09-20 17:17 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-20 17:15 consolidate tagset / misc request_queue allocation Christoph Hellwig
2022-09-20 17:15 ` [PATCH 01/13] nvme: add common helpers to allocate and free tagsets Christoph Hellwig
2022-09-20 21:42 ` Chaitanya Kulkarni
2022-09-21 3:37 ` Chao Leng
2022-09-22 5:45 ` Christoph Hellwig
2022-09-22 8:02 ` Chao Leng
2022-09-22 14:18 ` Christoph Hellwig
2022-09-21 8:25 ` Sagi Grimberg
2022-09-22 5:48 ` Christoph Hellwig
2022-09-22 8:09 ` Chao Leng
2022-09-22 14:19 ` Christoph Hellwig
2022-09-20 17:16 ` [PATCH 02/13] nvme-tcp: remove the unused queue_size member in nvme_tcp_queue Christoph Hellwig
2022-09-20 21:43 ` Chaitanya Kulkarni
2022-09-21 9:24 ` Sagi Grimberg
2022-09-20 17:16 ` [PATCH 03/13] nvme-tcp: store the generic nvme_ctrl in set->driver_data Christoph Hellwig
2022-09-20 21:43 ` Chaitanya Kulkarni
2022-09-21 9:25 ` Sagi Grimberg
2022-09-20 17:16 ` [PATCH 04/13] nvme-tcp: use the tagset alloc/free helpers Christoph Hellwig
2022-09-20 21:44 ` Chaitanya Kulkarni
2022-09-21 9:26 ` Sagi Grimberg
2022-09-20 17:16 ` [PATCH 05/13] nvme-rdma: store the generic nvme_ctrl in set->driver_data Christoph Hellwig
2022-09-20 21:44 ` Chaitanya Kulkarni
2022-09-21 9:26 ` Sagi Grimberg
2022-09-20 17:16 ` [PATCH 06/13] nvme-rdma: use the tagset alloc/free helpers Christoph Hellwig
2022-09-20 21:45 ` Chaitanya Kulkarni
2022-09-21 9:29 ` Sagi Grimberg
2022-09-20 17:16 ` [PATCH 07/13] nvme-fc: keep ctrl->sqsize in sync with opts->queue_size Christoph Hellwig
2022-09-21 9:30 ` Sagi Grimberg
2022-09-22 22:48 ` James Smart
2022-09-20 17:16 ` [PATCH 08/13] nvme-fc: store the generic nvme_ctrl in set->driver_data Christoph Hellwig
2022-09-21 9:32 ` Sagi Grimberg
2022-09-22 22:51 ` James Smart
2022-09-20 17:16 ` Christoph Hellwig [this message]
2022-09-21 9:33 ` [PATCH 09/13] nvme-fc: use the tagset alloc/free helpers Sagi Grimberg
2022-09-22 22:56 ` James Smart
2022-09-20 17:16 ` [PATCH 10/13] nvme-loop: initialize sqsize later Christoph Hellwig
2022-09-20 21:45 ` Chaitanya Kulkarni
2022-09-21 9:33 ` Sagi Grimberg
2022-09-20 17:16 ` [PATCH 11/13] nvme-loop: store the generic nvme_ctrl in set->driver_data Christoph Hellwig
2022-09-20 21:46 ` Chaitanya Kulkarni
2022-09-21 9:34 ` Sagi Grimberg
2022-09-20 17:16 ` [PATCH 12/13] nvme-loop: use the tagset alloc/free helpers Christoph Hellwig
2022-09-20 21:46 ` Chaitanya Kulkarni
2022-09-21 9:34 ` Sagi Grimberg
2022-09-20 17:16 ` [PATCH 13/13] nvme: remove nvme_ctrl_init_connect_q Christoph Hellwig
2022-09-20 21:46 ` Chaitanya Kulkarni
2022-09-21 9:34 ` Sagi Grimberg
2022-09-27 7:27 ` consolidate tagset / misc request_queue allocation Christoph Hellwig
2022-09-28 6:47 ` Sagi Grimberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220920171611.1289361-10-hch@lst.de \
--to=hch@lst.de \
--cc=james.smart@broadcom.com \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox