Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: keith.busch@intel.com (Keith Busch)
Subject: [PATCH-4.7 1/3] NVMe: Return ENODEV error on invalid namespace
Date: Mon,  2 May 2016 11:12:06 -0600	[thread overview]
Message-ID: <1462209128-12376-2-git-send-email-keith.busch@intel.com> (raw)
In-Reply-To: <1462209128-12376-1-git-send-email-keith.busch@intel.com>

If there is no namespace associated with the request, return an error
code that notifies the application the device isn't there.

Signed-off-by: Keith Busch <keith.busch at intel.com>
---
 drivers/nvme/host/nvme.h | 2 ++
 drivers/nvme/host/pci.c  | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 114b928..48c7f3c 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -193,6 +193,8 @@ static inline int nvme_error_status(u16 status)
 	switch (status & 0x7ff) {
 	case NVME_SC_SUCCESS:
 		return 0;
+	case NVME_SC_INVALID_NS:
+		return -ENODEV;
 	case NVME_SC_CAP_EXCEEDED:
 		return -ENOSPC;
 	default:
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 783845c..f99833b 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -600,7 +600,7 @@ static int nvme_queue_rq(struct blk_mq_hw_ctx *hctx,
 		if (ns && !test_bit(NVME_NS_DEAD, &ns->flags))
 			ret = BLK_MQ_RQ_QUEUE_BUSY;
 		else
-			ret = BLK_MQ_RQ_QUEUE_ERROR;
+			blk_mq_end_request(req, -ENODEV);
 		spin_unlock_irq(&nvmeq->q_lock);
 		goto out;
 	}
@@ -931,7 +931,7 @@ static void nvme_cancel_io(struct request *req, void *data, bool reserved)
 
 	status = NVME_SC_ABORT_REQ;
 	if (blk_queue_dying(req->q))
-		status |= NVME_SC_DNR;
+		status = NVME_SC_INVALID_NS | NVME_SC_DNR;
 	blk_mq_complete_request(req, status);
 }
 
-- 
2.7.2

  reply	other threads:[~2016-05-02 17:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-02 17:12 Patches for 4.7 Keith Busch
2016-05-02 17:12 ` Keith Busch [this message]
2016-05-03  7:58   ` [PATCH-4.7 1/3] NVMe: Return ENODEV error on invalid namespace Christoph Hellwig
2016-05-03 14:19     ` Busch, Keith
2016-05-03 14:25       ` Christoph Hellwig
2016-05-02 17:12 ` [PATCH-4.7 2/3] NVMe: Short-cut removal on surprise hot-unplug Keith Busch
2016-05-03  8:01   ` Christoph Hellwig
2016-05-10 19:16     ` Keith Busch
2016-05-12  7:06       ` Christoph Hellwig
2016-05-02 17:12 ` [PATCH-4.7 3/3] NVMe: Set capacity to 0 on all unusable namespaces Keith Busch
2016-05-03  8:03   ` Christoph Hellwig

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=1462209128-12376-2-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