NVMe: Correctly handle IOCTL_SUBMIT_IO when cpus > online queues
authorSam Bradshaw <sbradshaw@micron.com>
Tue, 29 Jul 2014 20:31:36 +0000 (13:31 -0700)
committerJens Axboe <axboe@fb.com>
Tue, 4 Nov 2014 20:17:08 +0000 (13:17 -0700)
nvme_submit_io_cmd() uses smp_processor_id() to pick an IO queue index.
This patch fixes the case where there are more cpus from which the ioctl
call can originate than online queues, which can happen when a device
supports or was allocated fewer interrupt vectors than exist cpu cores.

Thanks to Keith Busch for the implementation suggestion.

Signed-off-by: Sam Bradshaw <sbradshaw@micron.com>
Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
drivers/block/nvme-core.c

index 48a1be4..5d44c93 100644 (file)
@@ -984,8 +984,8 @@ int nvme_submit_admin_cmd(struct nvme_dev *dev, struct nvme_command *cmd,
 int nvme_submit_io_cmd(struct nvme_dev *dev, struct nvme_command *cmd,
                                                                u32 *result)
 {
-       return nvme_submit_sync_cmd(dev, smp_processor_id() + 1, cmd, result,
-                                                       NVME_IO_TIMEOUT);
+       return nvme_submit_sync_cmd(dev, this_cpu_read(*dev->io_queue), cmd,
+                                               result, NVME_IO_TIMEOUT);
 }
 
 static int nvme_submit_admin_cmd_async(struct nvme_dev *dev,