Skip to content

Commit

Permalink
nvme: use an integer value to Linux errno values
Browse files Browse the repository at this point in the history
Use a separate integer variable to hold the signed Linux errno
values we pass back to the block layer.  Note that for pass through
commands those might still be NVMe values, but those fit into the
int as well.

Fixes: f4829a9: ("blk-mq: fix racy updates of rq->errors")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
  • Loading branch information
Christoph Hellwig authored and Jens Axboe committed Oct 15, 2015
1 parent 3d42e67 commit 1951fea
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions drivers/nvme/host/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,8 @@ static void req_completion(struct nvme_queue *nvmeq, void *ctx,
struct nvme_iod *iod = ctx;
struct request *req = iod_get_private(iod);
struct nvme_cmd_info *cmd_rq = blk_mq_rq_to_pdu(req);

u16 status = le16_to_cpup(&cqe->status) >> 1;
int error;

if (unlikely(status)) {
if (!(status & NVME_SC_DNR || blk_noretry_request(req))
Expand All @@ -624,9 +624,11 @@ static void req_completion(struct nvme_queue *nvmeq, void *ctx,

if (req->cmd_type == REQ_TYPE_DRV_PRIV) {
if (cmd_rq->ctx == CMD_CTX_CANCELLED)
status = -EINTR;
error = -EINTR;
else
error = status;
} else {
status = nvme_error_status(status);
error = nvme_error_status(status);
}
}

Expand All @@ -638,7 +640,7 @@ static void req_completion(struct nvme_queue *nvmeq, void *ctx,
if (cmd_rq->aborted)
dev_warn(nvmeq->dev->dev,
"completing aborted command with status:%04x\n",
status);
error);

if (iod->nents) {
dma_unmap_sg(nvmeq->dev->dev, iod->sg, iod->nents,
Expand All @@ -652,7 +654,7 @@ static void req_completion(struct nvme_queue *nvmeq, void *ctx,
}
nvme_free_iod(nvmeq->dev, iod);

blk_mq_complete_request(req, status);
blk_mq_complete_request(req, error);
}

/* length is in bytes. gfp flags indicates whether we may sleep. */
Expand Down

0 comments on commit 1951fea

Please sign in to comment.