Skip to content

Commit d1f06f4

Browse files
axboeKeith Busch
authored andcommitted
nvme-pci: move ->cq_vector == -1 check outside of ->q_lock
We only clear it dynamically in nvme_suspend_queue(). When we do, ensure to do a full flush so that any nvme_queue_rq() invocation will see it. Ideally we'd kill this check completely, but we're using it to flush requests on a dying queue. Signed-off-by: Jens Axboe <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent f9dde18 commit d1f06f4

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

drivers/nvme/host/pci.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,13 @@ static blk_status_t nvme_queue_rq(struct blk_mq_hw_ctx *hctx,
872872
struct nvme_command cmnd;
873873
blk_status_t ret;
874874

875+
/*
876+
* We should not need to do this, but we're still using this to
877+
* ensure we can drain requests on a dying queue.
878+
*/
879+
if (unlikely(nvmeq->cq_vector < 0))
880+
return BLK_STS_IOERR;
881+
875882
ret = nvme_setup_cmd(ns, req, &cmnd);
876883
if (ret)
877884
return ret;
@@ -889,11 +896,6 @@ static blk_status_t nvme_queue_rq(struct blk_mq_hw_ctx *hctx,
889896
blk_mq_start_request(req);
890897

891898
spin_lock_irq(&nvmeq->q_lock);
892-
if (unlikely(nvmeq->cq_vector < 0)) {
893-
ret = BLK_STS_IOERR;
894-
spin_unlock_irq(&nvmeq->q_lock);
895-
goto out_cleanup_iod;
896-
}
897899
__nvme_submit_cmd(nvmeq, &cmnd);
898900
spin_unlock_irq(&nvmeq->q_lock);
899901
return BLK_STS_OK;
@@ -1321,6 +1323,12 @@ static int nvme_suspend_queue(struct nvme_queue *nvmeq)
13211323
nvmeq->cq_vector = -1;
13221324
spin_unlock_irq(&nvmeq->q_lock);
13231325

1326+
/*
1327+
* Ensure that nvme_queue_rq() sees it ->cq_vector == -1 without
1328+
* having to grab the lock.
1329+
*/
1330+
mb();
1331+
13241332
if (!nvmeq->qid && nvmeq->dev->ctrl.admin_q)
13251333
blk_mq_quiesce_queue(nvmeq->dev->ctrl.admin_q);
13261334

0 commit comments

Comments
 (0)