Skip to content

Commit

Permalink
NVMe: Memory barrier before queue_count is incremented
Browse files Browse the repository at this point in the history
Protects against reordering and/or preempting which would allow the
kthread to access the queue descriptor before it is set up

Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
Acked-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
  • Loading branch information
Jon Derrick authored and Jens Axboe committed Jun 5, 2015
1 parent 4cc0652 commit 36a7e99
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/block/nvme-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1453,9 +1453,12 @@ static struct nvme_queue *nvme_alloc_queue(struct nvme_dev *dev, int qid,
nvmeq->q_db = &dev->dbs[qid * 2 * dev->db_stride];
nvmeq->q_depth = depth;
nvmeq->qid = qid;
dev->queue_count++;
dev->queues[qid] = nvmeq;

/* make sure queue descriptor is set before queue count, for kthread */
mb();
dev->queue_count++;

return nvmeq;

free_cqdma:
Expand Down

0 comments on commit 36a7e99

Please sign in to comment.