NVMe: Memory barrier before queue_count is incremented
authorJon Derrick <jonathan.derrick@intel.com>
Wed, 27 May 2015 18:26:23 +0000 (12:26 -0600)
committerJens Axboe <axboe@fb.com>
Fri, 5 Jun 2015 16:33:34 +0000 (10:33 -0600)
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>
drivers/block/nvme-core.c

index 9682e29b417146ab10b6a578d81d73dee12f3403..cae7cac6cc439cec7c35fa7b2ad98d87d2fd5052 100644 (file)
@@ -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:
This page took 0.027264 seconds and 5 git commands to generate.