diff options
author | Keith Busch <keith.busch@intel.com> | 2014-08-29 11:06:12 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2014-11-04 15:17:09 -0500 |
commit | b4ff9c8ddb6f0cec99a53ab26a5aa2ed0162c472 (patch) | |
tree | f5852bde4a98c4acb718ec9ddab8f56e51343c94 /drivers/block | |
parent | 695a4fe79ffa70023238b6b2d4c20fe1a05288fb (diff) |
NVMe: Translate NVMe status to errno
This returns a more appropriate error for the "capacity exceeded"
status. In case other NVMe statuses have a better errno, this patch adds
a convience function to translate an NVMe status code to an errno for
IO commands, defaulting to the current -EIO.
Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/nvme-core.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c index 37f22b6bb009..3153692da288 100644 --- a/drivers/block/nvme-core.c +++ b/drivers/block/nvme-core.c | |||
@@ -450,6 +450,18 @@ static void nvme_end_io_acct(struct bio *bio, unsigned long start_time) | |||
450 | } | 450 | } |
451 | } | 451 | } |
452 | 452 | ||
453 | static int nvme_error_status(u16 status) | ||
454 | { | ||
455 | switch (status & 0x7ff) { | ||
456 | case NVME_SC_SUCCESS: | ||
457 | return 0; | ||
458 | case NVME_SC_CAP_EXCEEDED: | ||
459 | return -ENOSPC; | ||
460 | default: | ||
461 | return -EIO; | ||
462 | } | ||
463 | } | ||
464 | |||
453 | static void bio_completion(struct nvme_queue *nvmeq, void *ctx, | 465 | static void bio_completion(struct nvme_queue *nvmeq, void *ctx, |
454 | struct nvme_completion *cqe) | 466 | struct nvme_completion *cqe) |
455 | { | 467 | { |
@@ -469,7 +481,7 @@ static void bio_completion(struct nvme_queue *nvmeq, void *ctx, | |||
469 | wake_up(&nvmeq->sq_full); | 481 | wake_up(&nvmeq->sq_full); |
470 | return; | 482 | return; |
471 | } | 483 | } |
472 | error = -EIO; | 484 | error = nvme_error_status(status); |
473 | } | 485 | } |
474 | if (iod->nents) { | 486 | if (iod->nents) { |
475 | dma_unmap_sg(nvmeq->q_dmadev, iod->sg, iod->nents, | 487 | dma_unmap_sg(nvmeq->q_dmadev, iod->sg, iod->nents, |