From: jonathan.derrick@intel.com (Jon Derrick)
Subject: [PATCH] nvme: Add error checking in nvme_create_io_queues
Date: Thu, 24 Sep 2015 12:20:11 -0600 [thread overview]
Message-ID: <1443118811-2153-1-git-send-email-jonathan.derrick@intel.com> (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
next reply other threads:[~2015-09-24 18:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-24 18:20 Jon Derrick [this message]
2015-09-24 19:23 ` [PATCH] nvme: Add error checking in nvme_create_io_queues 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1443118811-2153-1-git-send-email-jonathan.derrick@intel.com \
--to=jonathan.derrick@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox