Avoid that nvme_queue_rq() is still running when nvme_stop_queues()
returns. Untested.

Signed-off-by: Bart Van Assche <bart.vanass...@sandisk.com>
Cc: Keith Busch <keith.bu...@intel.com>
Cc: Christoph Hellwig <h...@lst.de>
Cc: Sagi Grimberg <s...@grimberg.me>
---
 drivers/nvme/host/core.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 057f1fa..6e2bf6a 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -201,13 +201,9 @@ fail:
 
 void nvme_requeue_req(struct request *req)
 {
-       unsigned long flags;
-
        blk_mq_requeue_request(req);
-       spin_lock_irqsave(req->q->queue_lock, flags);
-       if (!blk_mq_queue_stopped(req->q))
-               blk_mq_kick_requeue_list(req->q);
-       spin_unlock_irqrestore(req->q->queue_lock, flags);
+       WARN_ON_ONCE(blk_mq_queue_stopped(req->q));
+       blk_mq_kick_requeue_list(req->q);
 }
 EXPORT_SYMBOL_GPL(nvme_requeue_req);
 
@@ -2079,11 +2075,15 @@ EXPORT_SYMBOL_GPL(nvme_kill_queues);
 void nvme_stop_queues(struct nvme_ctrl *ctrl)
 {
        struct nvme_ns *ns;
+       struct request_queue *q;
 
        mutex_lock(&ctrl->namespaces_mutex);
        list_for_each_entry(ns, &ctrl->namespaces, list) {
-               blk_mq_cancel_requeue_work(ns->queue);
-               blk_mq_stop_hw_queues(ns->queue);
+               q = ns->queue;
+               blk_quiesce_queue(q);
+               blk_mq_cancel_requeue_work(q);
+               blk_mq_stop_hw_queues(q);
+               blk_resume_queue(q);
        }
        mutex_unlock(&ctrl->namespaces_mutex);
 }
-- 
2.10.0

--
To unsubscribe from this list: send the line "unsubscribe linux-block" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to