From: Sagi Grimberg <sagi@grimberg.me>
To: linux-nvme@lists.infradead.org
Cc: Christoph Hellwig <hch@lst.de>,
Keith Busch <keith.busch@intel.com>,
linux-block@vger.kernel.org
Subject: [PATCH rfc 02/30] nvme-rdma: Don't alloc/free the tagset on reset
Date: Sun, 18 Jun 2017 18:21:36 +0300 [thread overview]
Message-ID: <1497799324-19598-3-git-send-email-sagi@grimberg.me> (raw)
In-Reply-To: <1497799324-19598-1-git-send-email-sagi@grimberg.me>
Also the admin and admin_connect request queues. This
is not something we should do on controller resets.
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
---
drivers/nvme/host/rdma.c | 118 ++++++++++++++++++++++++++---------------------
1 file changed, 65 insertions(+), 53 deletions(-)
diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index cb7f81d9098f..3e4c6aa119ee 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -656,15 +656,19 @@ static int nvme_rdma_init_io_queues(struct nvme_rdma_ctrl *ctrl)
return ret;
}
-static void nvme_rdma_destroy_admin_queue(struct nvme_rdma_ctrl *ctrl)
+static void nvme_rdma_destroy_admin_queue(struct nvme_rdma_ctrl *ctrl, bool remove)
{
+ nvme_rdma_stop_queue(&ctrl->queues[0]);
+ if (remove) {
+ blk_cleanup_queue(ctrl->ctrl.admin_connect_q);
+ blk_cleanup_queue(ctrl->ctrl.admin_q);
+ blk_mq_free_tag_set(&ctrl->admin_tag_set);
+ nvme_rdma_dev_put(ctrl->device);
+ }
+
nvme_rdma_free_qe(ctrl->queues[0].device->dev, &ctrl->async_event_sqe,
sizeof(struct nvme_command), DMA_TO_DEVICE);
- nvme_rdma_stop_and_free_queue(&ctrl->queues[0]);
- blk_cleanup_queue(ctrl->ctrl.admin_connect_q);
- blk_cleanup_queue(ctrl->ctrl.admin_q);
- blk_mq_free_tag_set(&ctrl->admin_tag_set);
- nvme_rdma_dev_put(ctrl->device);
+ nvme_rdma_free_queue(&ctrl->queues[0]);
}
static void nvme_rdma_free_ctrl(struct nvme_ctrl *nctrl)
@@ -1542,7 +1546,7 @@ static const struct blk_mq_ops nvme_rdma_admin_mq_ops = {
.timeout = nvme_rdma_timeout,
};
-static int nvme_rdma_configure_admin_queue(struct nvme_rdma_ctrl *ctrl)
+static int nvme_rdma_configure_admin_queue(struct nvme_rdma_ctrl *ctrl, bool new)
{
int error;
@@ -1551,43 +1555,44 @@ static int nvme_rdma_configure_admin_queue(struct nvme_rdma_ctrl *ctrl)
return error;
ctrl->device = ctrl->queues[0].device;
-
- /*
- * We need a reference on the device as long as the tag_set is alive,
- * as the MRs in the request structures need a valid ib_device.
- */
- error = -EINVAL;
- if (!nvme_rdma_dev_get(ctrl->device))
- goto out_free_queue;
-
ctrl->max_fr_pages = min_t(u32, NVME_RDMA_MAX_SEGMENTS,
ctrl->device->dev->attrs.max_fast_reg_page_list_len);
- memset(&ctrl->admin_tag_set, 0, sizeof(ctrl->admin_tag_set));
- ctrl->admin_tag_set.ops = &nvme_rdma_admin_mq_ops;
- ctrl->admin_tag_set.queue_depth = NVME_RDMA_AQ_BLKMQ_DEPTH;
- ctrl->admin_tag_set.reserved_tags = 2; /* connect + keep-alive */
- ctrl->admin_tag_set.numa_node = NUMA_NO_NODE;
- ctrl->admin_tag_set.cmd_size = sizeof(struct nvme_rdma_request) +
- SG_CHUNK_SIZE * sizeof(struct scatterlist);
- ctrl->admin_tag_set.driver_data = ctrl;
- ctrl->admin_tag_set.nr_hw_queues = 1;
- ctrl->admin_tag_set.timeout = ADMIN_TIMEOUT;
-
- error = blk_mq_alloc_tag_set(&ctrl->admin_tag_set);
- if (error)
- goto out_put_dev;
-
- ctrl->ctrl.admin_q = blk_mq_init_queue(&ctrl->admin_tag_set);
- if (IS_ERR(ctrl->ctrl.admin_q)) {
- error = PTR_ERR(ctrl->ctrl.admin_q);
- goto out_free_tagset;
- }
+ if (new) {
+ /*
+ * We need a reference on the device as long as the tag_set is alive,
+ * as the MRs in the request structures need a valid ib_device.
+ */
+ error = -EINVAL;
+ if (!nvme_rdma_dev_get(ctrl->device))
+ goto out_free_queue;
+
+ memset(&ctrl->admin_tag_set, 0, sizeof(ctrl->admin_tag_set));
+ ctrl->admin_tag_set.ops = &nvme_rdma_admin_mq_ops;
+ ctrl->admin_tag_set.queue_depth = NVME_RDMA_AQ_BLKMQ_DEPTH;
+ ctrl->admin_tag_set.reserved_tags = 2; /* connect + keep-alive */
+ ctrl->admin_tag_set.numa_node = NUMA_NO_NODE;
+ ctrl->admin_tag_set.cmd_size = sizeof(struct nvme_rdma_request) +
+ SG_CHUNK_SIZE * sizeof(struct scatterlist);
+ ctrl->admin_tag_set.driver_data = ctrl;
+ ctrl->admin_tag_set.nr_hw_queues = 1;
+ ctrl->admin_tag_set.timeout = ADMIN_TIMEOUT;
+
+ error = blk_mq_alloc_tag_set(&ctrl->admin_tag_set);
+ if (error)
+ goto out_put_dev;
+
+ ctrl->ctrl.admin_q = blk_mq_init_queue(&ctrl->admin_tag_set);
+ if (IS_ERR(ctrl->ctrl.admin_q)) {
+ error = PTR_ERR(ctrl->ctrl.admin_q);
+ goto out_free_tagset;
+ }
- ctrl->ctrl.admin_connect_q = blk_mq_init_queue(&ctrl->admin_tag_set);
- if (IS_ERR(ctrl->ctrl.admin_connect_q)) {
- error = PTR_ERR(ctrl->ctrl.admin_connect_q);
- goto out_cleanup_queue;
+ ctrl->ctrl.admin_connect_q = blk_mq_init_queue(&ctrl->admin_tag_set);
+ if (IS_ERR(ctrl->ctrl.admin_connect_q)) {
+ error = PTR_ERR(ctrl->ctrl.admin_connect_q);
+ goto out_cleanup_queue;
+ }
}
error = nvmf_connect_admin_queue(&ctrl->ctrl);
@@ -1596,6 +1601,8 @@ static int nvme_rdma_configure_admin_queue(struct nvme_rdma_ctrl *ctrl)
set_bit(NVME_RDMA_Q_LIVE, &ctrl->queues[0].flags);
+ blk_mq_start_stopped_hw_queues(ctrl->ctrl.admin_q, true);
+
error = nvmf_reg_read64(&ctrl->ctrl, NVME_REG_CAP, &ctrl->cap);
if (error) {
dev_err(ctrl->ctrl.device,
@@ -1628,21 +1635,26 @@ static int nvme_rdma_configure_admin_queue(struct nvme_rdma_ctrl *ctrl)
return 0;
out_cleanup_connect_queue:
- blk_cleanup_queue(ctrl->ctrl.admin_connect_q);
+ if (new)
+ blk_cleanup_queue(ctrl->ctrl.admin_connect_q);
out_cleanup_queue:
- blk_cleanup_queue(ctrl->ctrl.admin_q);
+ if (new)
+ blk_cleanup_queue(ctrl->ctrl.admin_q);
out_free_tagset:
- /* disconnect and drain the queue before freeing the tagset */
- nvme_rdma_stop_queue(&ctrl->queues[0]);
- blk_mq_free_tag_set(&ctrl->admin_tag_set);
+ if (new) {
+ /* disconnect and drain the queue before freeing the tagset */
+ nvme_rdma_stop_queue(&ctrl->queues[0]);
+ blk_mq_free_tag_set(&ctrl->admin_tag_set);
+ }
out_put_dev:
- nvme_rdma_dev_put(ctrl->device);
+ if (new)
+ nvme_rdma_dev_put(ctrl->device);
out_free_queue:
nvme_rdma_free_queue(&ctrl->queues[0]);
return error;
}
-static void nvme_rdma_shutdown_ctrl(struct nvme_rdma_ctrl *ctrl)
+static void nvme_rdma_shutdown_ctrl(struct nvme_rdma_ctrl *ctrl, bool shutdown)
{
nvme_stop_keep_alive(&ctrl->ctrl);
cancel_work_sync(&ctrl->err_work);
@@ -1661,14 +1673,14 @@ static void nvme_rdma_shutdown_ctrl(struct nvme_rdma_ctrl *ctrl)
blk_mq_stop_hw_queues(ctrl->ctrl.admin_q);
blk_mq_tagset_busy_iter(&ctrl->admin_tag_set,
nvme_cancel_request, &ctrl->ctrl);
- nvme_rdma_destroy_admin_queue(ctrl);
+ nvme_rdma_destroy_admin_queue(ctrl, shutdown);
}
static void __nvme_rdma_remove_ctrl(struct nvme_rdma_ctrl *ctrl, bool shutdown)
{
nvme_uninit_ctrl(&ctrl->ctrl);
if (shutdown)
- nvme_rdma_shutdown_ctrl(ctrl);
+ nvme_rdma_shutdown_ctrl(ctrl, shutdown);
if (ctrl->ctrl.tagset) {
blk_cleanup_queue(ctrl->ctrl.connect_q);
@@ -1731,9 +1743,9 @@ static void nvme_rdma_reset_ctrl_work(struct work_struct *work)
int ret;
bool changed;
- nvme_rdma_shutdown_ctrl(ctrl);
+ nvme_rdma_shutdown_ctrl(ctrl, false);
- ret = nvme_rdma_configure_admin_queue(ctrl);
+ ret = nvme_rdma_configure_admin_queue(ctrl, false);
if (ret) {
/* ctrl is already shutdown, just remove the ctrl */
INIT_WORK(&ctrl->delete_work, nvme_rdma_remove_ctrl_work);
@@ -1898,7 +1910,7 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev,
if (!ctrl->queues)
goto out_uninit_ctrl;
- ret = nvme_rdma_configure_admin_queue(ctrl);
+ ret = nvme_rdma_configure_admin_queue(ctrl, true);
if (ret)
goto out_kfree_queues;
@@ -1959,7 +1971,7 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev,
out_remove_admin_queue:
nvme_stop_keep_alive(&ctrl->ctrl);
- nvme_rdma_destroy_admin_queue(ctrl);
+ nvme_rdma_destroy_admin_queue(ctrl, true);
out_kfree_queues:
kfree(ctrl->queues);
out_uninit_ctrl:
--
2.7.4
next prev parent reply other threads:[~2017-06-18 15:22 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-18 15:21 [PATCH rfc 00/30] centralize nvme controller reset, delete and periodic reconnects Sagi Grimberg
2017-06-18 15:21 ` [PATCH rfc 01/30] nvme: Add admin connect request queue Sagi Grimberg
2017-06-19 7:13 ` Christoph Hellwig
2017-06-19 7:49 ` Sagi Grimberg
2017-06-19 12:30 ` Christoph Hellwig
2017-06-19 15:56 ` Hannes Reinecke
2017-06-18 15:21 ` Sagi Grimberg [this message]
2017-06-19 7:18 ` [PATCH rfc 02/30] nvme-rdma: Don't alloc/free the tagset on reset Christoph Hellwig
2017-06-19 7:59 ` Sagi Grimberg
2017-06-19 12:35 ` Christoph Hellwig
2017-07-10 18:50 ` James Smart
2017-06-18 15:21 ` [PATCH rfc 03/30] nvme-rdma: reuse configure/destroy admin queue Sagi Grimberg
2017-06-19 7:20 ` Christoph Hellwig
2017-06-19 8:00 ` Sagi Grimberg
2017-06-18 15:21 ` [PATCH rfc 04/30] nvme-rdma: introduce configure/destroy io queues Sagi Grimberg
2017-06-19 12:35 ` Christoph Hellwig
2017-06-18 15:21 ` [PATCH rfc 05/30] nvme-rdma: introduce nvme_rdma_start_queue Sagi Grimberg
2017-06-19 12:38 ` Christoph Hellwig
2017-06-18 15:21 ` [PATCH rfc 06/30] nvme-rdma: rename nvme_rdma_init_queue to nvme_rdma_alloc_queue Sagi Grimberg
2017-06-19 12:38 ` Christoph Hellwig
2017-06-18 15:21 ` [PATCH rfc 07/30] nvme-rdma: make stop/free queue receive a ctrl and qid struct Sagi Grimberg
2017-06-19 12:39 ` Christoph Hellwig
2017-06-18 15:21 ` [PATCH rfc 08/30] nvme-rdma: cleanup error path in controller reset Sagi Grimberg
2017-06-19 12:40 ` Christoph Hellwig
2017-07-10 18:57 ` James Smart
2017-06-18 15:21 ` [PATCH rfc 09/30] nvme: Move queue_count to the nvme_ctrl Sagi Grimberg
2017-06-19 12:41 ` Christoph Hellwig
2017-06-18 15:21 ` [PATCH rfc 10/30] nvme: Add admin_tagset pointer to nvme_ctrl Sagi Grimberg
2017-06-19 12:41 ` Christoph Hellwig
2017-06-19 13:58 ` Sagi Grimberg
2017-06-18 15:21 ` [PATCH rfc 11/30] nvme: move controller cap to struct nvme_ctrl Sagi Grimberg
2017-06-19 12:42 ` Christoph Hellwig
2017-06-18 15:21 ` [PATCH rfc 12/30] nvme-rdma: disable controller in reset instead of shutdown Sagi Grimberg
2017-06-19 12:43 ` Christoph Hellwig
2017-06-18 15:21 ` [PATCH rfc 13/30] nvme-rdma: move queue LIVE/DELETING flags settings to queue routines Sagi Grimberg
2017-06-19 12:44 ` Christoph Hellwig
2017-06-18 15:21 ` [PATCH rfc 14/30] nvme-rdma: stop queues instead of simply flipping their state Sagi Grimberg
2017-06-19 12:44 ` Christoph Hellwig
2017-06-18 15:21 ` [PATCH rfc 15/30] nvme-rdma: don't check queue state for shutdown/disable Sagi Grimberg
2017-06-19 12:44 ` Christoph Hellwig
2017-06-18 15:21 ` [PATCH rfc 16/30] nvme-rdma: move tagset allocation to a dedicated routine Sagi Grimberg
2017-06-19 12:45 ` Christoph Hellwig
2017-06-18 15:21 ` [PATCH rfc 17/30] nvme-rdma: move admin specific resources to alloc_queue Sagi Grimberg
2017-06-19 12:46 ` Christoph Hellwig
2017-06-18 15:21 ` [PATCH rfc 18/30] nvme-rdma: limit max_queues to rdma device number of completion vectors Sagi Grimberg
2017-06-18 15:21 ` [PATCH rfc 19/30] nvme-rdma: call ops->reg_read64 instead of nvmf_reg_read64 Sagi Grimberg
2017-06-18 15:21 ` [PATCH rfc 20/30] nvme: add err, reconnect and delete work items to nvme core Sagi Grimberg
2017-06-19 12:49 ` Christoph Hellwig
2017-06-19 14:14 ` Sagi Grimberg
2017-06-18 15:21 ` [PATCH rfc 21/30] nvme-rdma: plumb nvme_ctrl down the calls tack Sagi Grimberg
2017-06-18 15:21 ` [PATCH rfc 22/30] nvme-rdma: Split create_ctrl to transport specific and generic parts Sagi Grimberg
2017-06-18 15:21 ` [PATCH rfc 23/30] nvme: add low level queue and tagset controller ops Sagi Grimberg
2017-06-18 15:21 ` [PATCH rfc 24/30] nvme-pci: rename to nvme_pci_configure_admin_queue Sagi Grimberg
2017-06-19 7:20 ` Christoph Hellwig
2017-06-18 15:21 ` [PATCH rfc 25/30] nvme: move control plane handling to nvme core Sagi Grimberg
2017-06-19 12:55 ` Christoph Hellwig
2017-06-19 16:24 ` Sagi Grimberg
2017-06-18 15:22 ` [PATCH rfc 26/30] nvme-fabrics: handle reconnects in fabrics library Sagi Grimberg
2017-06-18 15:22 ` [PATCH rfc 27/30] nvme-loop: convert to nvme-core control plane management Sagi Grimberg
2017-06-18 15:22 ` [PATCH rfc 28/30] nvme: update tagset nr_hw_queues when reallocating io queues Sagi Grimberg
2017-06-19 7:21 ` Christoph Hellwig
2017-06-19 8:06 ` Ming Lei
2017-06-19 16:21 ` Sagi Grimberg
2017-06-18 15:22 ` [PATCH rfc 29/30] nvme: add sed-opal ctrl manipulation in admin configuration Sagi Grimberg
2017-06-19 7:22 ` Christoph Hellwig
2017-06-19 8:03 ` Sagi Grimberg
2017-06-19 12:55 ` Christoph Hellwig
2017-06-18 15:22 ` [PATCH rfc 30/30] nvme: Add queue freeze/unfreeze handling on controller resets Sagi Grimberg
2017-06-18 15:24 ` [PATCH rfc 00/30] centralize nvme controller reset, delete and periodic reconnects 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=1497799324-19598-3-git-send-email-sagi@grimberg.me \
--to=sagi@grimberg.me \
--cc=hch@lst.de \
--cc=keith.busch@intel.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).