Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvme: Add error checking in nvme_create_io_queues
@ 2015-09-24 18:20 Jon Derrick
  2015-09-24 19:23 ` Keith Busch
  0 siblings, 1 reply; 7+ messages in thread
From: Jon Derrick @ 2015-09-24 18:20 UTC (permalink / raw)


allow nvme_create_io_queues to return an error if the first io queue
fails to be allocated or initialized

Signed-off-by: Jon Derrick <jonathan.derrick at intel.com>
---
 drivers/block/nvme-core.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c
index b97fc3f..e0ec139 100644
--- a/drivers/block/nvme-core.c
+++ b/drivers/block/nvme-core.c
@@ -2186,17 +2186,25 @@ static void nvme_alloc_ns(struct nvme_dev *dev, unsigned nsid)
 	kfree(ns);
 }
 
-static void nvme_create_io_queues(struct nvme_dev *dev)
+static int nvme_create_io_queues(struct nvme_dev *dev)
 {
 	unsigned i;
 
 	for (i = dev->queue_count; i <= dev->max_qid; i++)
-		if (!nvme_alloc_queue(dev, i, dev->q_depth))
+		if (!nvme_alloc_queue(dev, i, dev->q_depth)) {
+			if (dev->queue_count == 1)
+				return -ENODEV;
 			break;
+		}
 
 	for (i = dev->online_queues; i <= dev->queue_count - 1; i++)
-		if (nvme_create_queue(dev->queues[i], i))
+		if (nvme_create_queue(dev->queues[i], i)) {
+			if (dev->online_queues == 1)
+				return -ENODEV;
 			break;
+		}
+
+	return 0;
 }
 
 static int set_queue_count(struct nvme_dev *dev, int count)
@@ -2350,7 +2358,11 @@ static int nvme_setup_io_queues(struct nvme_dev *dev)
 
 	/* Free previously allocated queues that are no longer usable */
 	nvme_free_queues(dev, nr_io_queues + 1);
-	nvme_create_io_queues(dev);
+	result = nvme_create_io_queues(dev);
+	if (result) {
+		dev_warn(dev->dev, "Failed to create io queues\n");
+		goto free_queues;
+	}
 
 	return 0;
 
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-09-28 14:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-24 18:20 [PATCH] nvme: Add error checking in nvme_create_io_queues Jon Derrick
2015-09-24 19:23 ` Keith Busch
2015-09-24 19:41   ` Jon Derrick
2015-09-27  6:39   ` Christoph Hellwig
2015-09-28 13:50     ` Keith Busch
2015-09-28 14:23       ` Christoph Hellwig
2015-09-28 14:35         ` Keith Busch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox