Commit b4ff9c8d authored by Keith Busch's avatar Keith Busch Committed by Jens Axboe

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: default avatarKeith Busch <keith.busch@intel.com>
Signed-off-by: default avatarMatthew Wilcox <matthew.r.wilcox@intel.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent 695a4fe7
...@@ -450,6 +450,18 @@ static void nvme_end_io_acct(struct bio *bio, unsigned long start_time) ...@@ -450,6 +450,18 @@ static void nvme_end_io_acct(struct bio *bio, unsigned long start_time)
} }
} }
static int nvme_error_status(u16 status)
{
switch (status & 0x7ff) {
case NVME_SC_SUCCESS:
return 0;
case NVME_SC_CAP_EXCEEDED:
return -ENOSPC;
default:
return -EIO;
}
}
static void bio_completion(struct nvme_queue *nvmeq, void *ctx, static void bio_completion(struct nvme_queue *nvmeq, void *ctx,
struct nvme_completion *cqe) struct nvme_completion *cqe)
{ {
...@@ -469,7 +481,7 @@ static void bio_completion(struct nvme_queue *nvmeq, void *ctx, ...@@ -469,7 +481,7 @@ static void bio_completion(struct nvme_queue *nvmeq, void *ctx,
wake_up(&nvmeq->sq_full); wake_up(&nvmeq->sq_full);
return; return;
} }
error = -EIO; error = nvme_error_status(status);
} }
if (iod->nents) { if (iod->nents) {
dma_unmap_sg(nvmeq->q_dmadev, iod->sg, iod->nents, dma_unmap_sg(nvmeq->q_dmadev, iod->sg, iod->nents,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment