Skip to content

Commit 98d81f0

Browse files
lostandy26axboe
authored andcommitted
nvme: use blk_mq_[un]quiesce_tagset
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). nvme connect_q should not be quiesced when quiesce tagset, so set the QUEUE_FLAG_SKIP_TAGSET_QUIESCE to skip it when init connect_q. Currently we 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. In addition, we never really quiesce a single namespace. It is a better choice to move the flag from ns to ctrl. Signed-off-by: Chao Leng <[email protected]> [hch: rebased on top of prep patches] Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Keith Busch <[email protected]> Reviewed-by: Chao Leng <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 414dd48 commit 98d81f0

File tree

2 files changed

+9
-27
lines changed

2 files changed

+9
-27
lines changed

drivers/nvme/host/core.c

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4895,6 +4895,8 @@ int nvme_alloc_io_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set,
48954895
ret = PTR_ERR(ctrl->connect_q);
48964896
goto out_free_tag_set;
48974897
}
4898+
blk_queue_flag_set(QUEUE_FLAG_SKIP_TAGSET_QUIESCE,
4899+
ctrl->connect_q);
48984900
}
48994901

49004902
ctrl->tagset = set;
@@ -5096,20 +5098,6 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,
50965098
}
50975099
EXPORT_SYMBOL_GPL(nvme_init_ctrl);
50985100

5099-
static void nvme_start_ns_queue(struct nvme_ns *ns)
5100-
{
5101-
if (test_and_clear_bit(NVME_NS_STOPPED, &ns->flags))
5102-
blk_mq_unquiesce_queue(ns->queue);
5103-
}
5104-
5105-
static void nvme_stop_ns_queue(struct nvme_ns *ns)
5106-
{
5107-
if (!test_and_set_bit(NVME_NS_STOPPED, &ns->flags))
5108-
blk_mq_quiesce_queue(ns->queue);
5109-
else
5110-
blk_mq_wait_quiesce_done(ns->queue->tag_set);
5111-
}
5112-
51135101
/* let I/O to all namespaces fail in preparation for surprise removal */
51145102
void nvme_mark_namespaces_dead(struct nvme_ctrl *ctrl)
51155103
{
@@ -5172,23 +5160,17 @@ EXPORT_SYMBOL_GPL(nvme_start_freeze);
51725160

51735161
void nvme_stop_queues(struct nvme_ctrl *ctrl)
51745162
{
5175-
struct nvme_ns *ns;
5176-
5177-
down_read(&ctrl->namespaces_rwsem);
5178-
list_for_each_entry(ns, &ctrl->namespaces, list)
5179-
nvme_stop_ns_queue(ns);
5180-
up_read(&ctrl->namespaces_rwsem);
5163+
if (!test_and_set_bit(NVME_CTRL_STOPPED, &ctrl->flags))
5164+
blk_mq_quiesce_tagset(ctrl->tagset);
5165+
else
5166+
blk_mq_wait_quiesce_done(ctrl->tagset);
51815167
}
51825168
EXPORT_SYMBOL_GPL(nvme_stop_queues);
51835169

51845170
void nvme_start_queues(struct nvme_ctrl *ctrl)
51855171
{
5186-
struct nvme_ns *ns;
5187-
5188-
down_read(&ctrl->namespaces_rwsem);
5189-
list_for_each_entry(ns, &ctrl->namespaces, list)
5190-
nvme_start_ns_queue(ns);
5191-
up_read(&ctrl->namespaces_rwsem);
5172+
if (test_and_clear_bit(NVME_CTRL_STOPPED, &ctrl->flags))
5173+
blk_mq_unquiesce_tagset(ctrl->tagset);
51925174
}
51935175
EXPORT_SYMBOL_GPL(nvme_start_queues);
51945176

drivers/nvme/host/nvme.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ enum nvme_ctrl_flags {
237237
NVME_CTRL_FAILFAST_EXPIRED = 0,
238238
NVME_CTRL_ADMIN_Q_STOPPED = 1,
239239
NVME_CTRL_STARTED_ONCE = 2,
240+
NVME_CTRL_STOPPED = 3,
240241
};
241242

242243
struct nvme_ctrl {
@@ -486,7 +487,6 @@ struct nvme_ns {
486487
#define NVME_NS_ANA_PENDING 2
487488
#define NVME_NS_FORCE_RO 3
488489
#define NVME_NS_READY 4
489-
#define NVME_NS_STOPPED 5
490490

491491
struct cdev cdev;
492492
struct device cdev_device;

0 commit comments

Comments
 (0)