From: Chao Leng <lengchao@huawei.com>
To: <linux-nvme@lists.infradead.org>, <linux-block@vger.kernel.org>
Cc: <hch@lst.de>, <sagi@grimberg.me>, <kbusch@kernel.org>,
<lengchao@huawei.com>, <ming.lei@redhat.com>, <axboe@kernel.dk>
Subject: [PATCH v2 2/2] nvme: use blk_mq_[un]quiesce_tagset
Date: Thu, 13 Oct 2022 17:44:50 +0800 [thread overview]
Message-ID: <20221013094450.5947-3-lengchao@huawei.com> (raw)
In-Reply-To: <20221013094450.5947-1-lengchao@huawei.com>
All controller namespaces share the same tagset, so we can use this
interface which does the optimal operation for parallel quiesce based on
the tagset type(e.g. blocking tagsets and non-blocking tagsets).
Now use NVME_NS_STOPPED to ensure pairing quiescing and unquiescing.
If use blk_mq_[un]quiesce_tagset, NVME_NS_STOPPED will be invalided,
so introduce NVME_CTRL_STOPPED to replace NVME_NS_STOPPED.
nvme connect_q should be never quiesced, so set QUEUE_FLAG_NOQUIESCED
when init connect_q.
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Chao Leng <lengchao@huawei.com>
---
drivers/nvme/host/core.c | 42 +++++++++++++-----------------------------
drivers/nvme/host/nvme.h | 2 +-
2 files changed, 14 insertions(+), 30 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 059737c1a2c1..0d07a07e02ff 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -4890,6 +4890,7 @@ int nvme_alloc_io_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set,
ret = PTR_ERR(ctrl->connect_q);
goto out_free_tag_set;
}
+ blk_queue_flag_set(QUEUE_FLAG_NOQUIESCED, ctrl->connect_q);
}
ctrl->tagset = set;
@@ -5089,20 +5090,6 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,
}
EXPORT_SYMBOL_GPL(nvme_init_ctrl);
-static void nvme_start_ns_queue(struct nvme_ns *ns)
-{
- if (test_and_clear_bit(NVME_NS_STOPPED, &ns->flags))
- blk_mq_unquiesce_queue(ns->queue);
-}
-
-static void nvme_stop_ns_queue(struct nvme_ns *ns)
-{
- if (!test_and_set_bit(NVME_NS_STOPPED, &ns->flags))
- blk_mq_quiesce_queue(ns->queue);
- else
- blk_mq_wait_quiesce_done(ns->queue);
-}
-
/*
* Prepare a queue for teardown.
*
@@ -5111,13 +5098,14 @@ static void nvme_stop_ns_queue(struct nvme_ns *ns)
* holding bd_butex. This will end buffered writers dirtying pages that can't
* be synced.
*/
-static void nvme_set_queue_dying(struct nvme_ns *ns)
+static void nvme_set_queue_dying(struct nvme_ns *ns, bool start_queue)
{
if (test_and_set_bit(NVME_NS_DEAD, &ns->flags))
return;
blk_mark_disk_dead(ns->disk);
- nvme_start_ns_queue(ns);
+ if (start_queue)
+ blk_mq_unquiesce_queue(ns->queue);
set_capacity_and_notify(ns->disk, 0);
}
@@ -5132,6 +5120,7 @@ static void nvme_set_queue_dying(struct nvme_ns *ns)
void nvme_kill_queues(struct nvme_ctrl *ctrl)
{
struct nvme_ns *ns;
+ bool start_queue = false;
down_read(&ctrl->namespaces_rwsem);
@@ -5139,8 +5128,11 @@ void nvme_kill_queues(struct nvme_ctrl *ctrl)
if (ctrl->admin_q && !blk_queue_dying(ctrl->admin_q))
nvme_start_admin_queue(ctrl);
+ if (test_and_clear_bit(NVME_CTRL_STOPPED, &ctrl->flags))
+ start_queue = true;
+
list_for_each_entry(ns, &ctrl->namespaces, list)
- nvme_set_queue_dying(ns);
+ nvme_set_queue_dying(ns, start_queue);
up_read(&ctrl->namespaces_rwsem);
}
@@ -5196,23 +5188,15 @@ EXPORT_SYMBOL_GPL(nvme_start_freeze);
void nvme_stop_queues(struct nvme_ctrl *ctrl)
{
- struct nvme_ns *ns;
-
- down_read(&ctrl->namespaces_rwsem);
- list_for_each_entry(ns, &ctrl->namespaces, list)
- nvme_stop_ns_queue(ns);
- up_read(&ctrl->namespaces_rwsem);
+ if (!test_and_set_bit(NVME_CTRL_STOPPED, &ctrl->flags))
+ blk_mq_quiesce_tagset(ctrl->tagset);
}
EXPORT_SYMBOL_GPL(nvme_stop_queues);
void nvme_start_queues(struct nvme_ctrl *ctrl)
{
- struct nvme_ns *ns;
-
- down_read(&ctrl->namespaces_rwsem);
- list_for_each_entry(ns, &ctrl->namespaces, list)
- nvme_start_ns_queue(ns);
- up_read(&ctrl->namespaces_rwsem);
+ if (test_and_clear_bit(NVME_CTRL_STOPPED, &ctrl->flags))
+ blk_mq_unquiesce_tagset(ctrl->tagset);
}
EXPORT_SYMBOL_GPL(nvme_start_queues);
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index a29877217ee6..8e2f13a1e23a 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -237,6 +237,7 @@ enum nvme_ctrl_flags {
NVME_CTRL_FAILFAST_EXPIRED = 0,
NVME_CTRL_ADMIN_Q_STOPPED = 1,
NVME_CTRL_STARTED_ONCE = 2,
+ NVME_CTRL_STOPPED = 3,
};
struct nvme_ctrl {
@@ -487,7 +488,6 @@ struct nvme_ns {
#define NVME_NS_ANA_PENDING 2
#define NVME_NS_FORCE_RO 3
#define NVME_NS_READY 4
-#define NVME_NS_STOPPED 5
struct cdev cdev;
struct device cdev_device;
--
2.16.4
next prev parent reply other threads:[~2022-10-13 9:45 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-13 9:44 [PATCH v2 0/2] improve nvme quiesce time for large amount of namespaces Chao Leng
2022-10-13 9:44 ` [PATCH v2 1/2] blk-mq: add tagset quiesce interface Chao Leng
2022-10-13 10:28 ` Sagi Grimberg
2022-10-14 2:09 ` Chao Leng
2022-10-17 13:43 ` Christoph Hellwig
2022-10-18 9:51 ` Chao Leng
2022-10-17 13:39 ` Christoph Hellwig
2022-10-17 13:42 ` Christoph Hellwig
2022-10-18 8:39 ` Sagi Grimberg
2022-10-18 8:55 ` Christoph Hellwig
2022-10-18 9:06 ` Sagi Grimberg
2022-10-18 11:05 ` Christoph Hellwig
2022-10-18 9:52 ` Chao Leng
2022-10-17 15:21 ` Paul E. McKenney
2022-10-17 15:31 ` Christoph Hellwig
2022-10-17 22:41 ` Paul E. McKenney
2022-10-18 5:19 ` Christoph Hellwig
2022-10-19 0:35 ` Ming Lei
2022-10-19 7:15 ` Sagi Grimberg
2022-10-19 7:25 ` Christoph Hellwig
2022-10-19 7:27 ` Christoph Hellwig
2022-10-19 7:30 ` Sagi Grimberg
2022-10-19 7:32 ` Christoph Hellwig
2022-10-19 7:57 ` Sagi Grimberg
2022-10-19 8:17 ` Christoph Hellwig
2022-10-19 8:29 ` Sagi Grimberg
2022-10-18 9:52 ` Chao Leng
2022-10-18 15:04 ` Paul E. McKenney
2022-10-19 2:39 ` Chao Leng
2022-10-18 9:52 ` Chao Leng
2022-10-13 9:44 ` Chao Leng [this message]
2022-10-13 10:22 ` [PATCH v2 2/2] nvme: use blk_mq_[un]quiesce_tagset Sagi Grimberg
2022-10-14 2:09 ` Chao Leng
2022-10-17 13:48 ` Christoph Hellwig
2022-10-13 14:32 ` [PATCH v2 0/2] improve nvme quiesce time for large amount of namespaces Chaitanya Kulkarni
2022-10-14 2:12 ` Chao Leng
2022-10-15 0:30 ` Chaitanya Kulkarni
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=20221013094450.5947-3-lengchao@huawei.com \
--to=lengchao@huawei.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=ming.lei@redhat.com \
--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