linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: keith.busch@intel.com (Keith Busch)
Subject: [PATCH 3/9] NVMe: Fail device if unresponsive during init
Date: Thu,  5 Sep 2013 14:45:09 -0600	[thread overview]
Message-ID: <1378413915-16667-4-git-send-email-keith.busch@intel.com> (raw)
In-Reply-To: <1378413915-16667-1-git-send-email-keith.busch@intel.com>

This handles identifying namespace errors differently depending on
the error. If the controller is unresponsive during this point of
initialization, the namespaces are freed and the pci probe is failed.

Signed-off-by: Keith Busch <keith.busch at intel.com>
---
Yes, part of this undoes a patch I submitted removing 'dead code',
but that code wasn't reachable before! :)

 drivers/block/nvme-core.c |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c
index 8b22068..db15c3d 100644
--- a/drivers/block/nvme-core.c
+++ b/drivers/block/nvme-core.c
@@ -1879,7 +1879,7 @@ static int nvme_dev_add(struct nvme_dev *dev)
 {
 	int res;
 	unsigned nn, i;
-	struct nvme_ns *ns;
+	struct nvme_ns *ns, *next;
 	struct nvme_id_ctrl *ctrl;
 	struct nvme_id_ns *id_ns;
 	void *mem;
@@ -1912,16 +1912,22 @@ static int nvme_dev_add(struct nvme_dev *dev)
 	id_ns = mem;
 	for (i = 1; i <= nn; i++) {
 		res = nvme_identify(dev, i, 0, dma_addr);
-		if (res)
+		if (res) {
+			if (res < 0)
+				goto out_free;
 			continue;
+		}
 
 		if (id_ns->ncap == 0)
 			continue;
 
 		res = nvme_get_features(dev, NVME_FEAT_LBA_RANGE, i,
 							dma_addr + 4096, NULL);
-		if (res)
+		if (res) {
+			if (res < 0)
+				goto out_free;
 			memset(mem + 4096, 0, 4096);
+		}
 
 		ns = nvme_alloc_ns(dev, i, mem, mem + 4096);
 		if (ns)
@@ -1930,7 +1936,13 @@ static int nvme_dev_add(struct nvme_dev *dev)
 	list_for_each_entry(ns, &dev->namespaces, list)
 		add_disk(ns->disk);
 	res = 0;
+	goto out;
 
+ out_free:
+	list_for_each_entry_safe(ns, next, &dev->namespaces, list) {
+		list_del(&ns->list);
+		nvme_ns_free(ns);
+	}
  out:
 	dma_free_coherent(&dev->pci_dev->dev, 8192, mem, dma_addr);
 	return res;
-- 
1.7.0.4

  parent reply	other threads:[~2013-09-05 20:45 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-05 20:45 [PATCH 0/9] NVMe: Error handling Keith Busch
2013-09-05 20:45 ` [PATCH 1/9] NVMe: Merge issue on character device bring-up Keith Busch
2013-09-05 21:23   ` John Utz
2013-09-05 22:21     ` Keith Busch
2013-09-05 22:47       ` John Utz
2013-09-05 23:23         ` Keith Busch
2013-09-05 20:45 ` [PATCH 2/9] NVMe: Differentiate commands not completed Keith Busch
2013-09-05 20:45 ` Keith Busch [this message]
2013-09-19 20:29   ` [PATCH 3/9] NVMe: Fail device if unresponsive during init Matthew Wilcox
2013-09-19 21:25     ` Keith Busch
2013-09-05 20:45 ` [PATCH 4/9] NVMe: Reset failed controller Keith Busch
2013-09-05 20:45 ` [PATCH 5/9] NVMe: Abort timed out commands Keith Busch
2013-09-05 20:45 ` [PATCH 6/9] NVMe: User initiated controller reset Keith Busch
2013-09-05 20:45 ` [PATCH 7/9] NVMe: Add shutdown pci callback Keith Busch
2013-09-05 20:45 ` [PATCH 8/9] NVMe: Set queue db only when queue is initialized Keith Busch
2013-09-05 20:45 ` [PATCH 9/9] NVMe: Don't wait for delete queues to complete 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=1378413915-16667-4-git-send-email-keith.busch@intel.com \
    --to=keith.busch@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;
as well as URLs for NNTP newsgroup(s).