Skip to content

Commit 81c04b9

Browse files
Christoph Hellwigaxboe
authored andcommitted
nvme: use an integer value to Linux errno values
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 <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent f42d79a commit 81c04b9

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

drivers/block/nvme-core.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -603,8 +603,8 @@ static void req_completion(struct nvme_queue *nvmeq, void *ctx,
603603
struct nvme_iod *iod = ctx;
604604
struct request *req = iod_get_private(iod);
605605
struct nvme_cmd_info *cmd_rq = blk_mq_rq_to_pdu(req);
606-
607606
u16 status = le16_to_cpup(&cqe->status) >> 1;
607+
int error = 0;
608608

609609
if (unlikely(status)) {
610610
if (!(status & NVME_SC_DNR || blk_noretry_request(req))
@@ -621,9 +621,11 @@ static void req_completion(struct nvme_queue *nvmeq, void *ctx,
621621

622622
if (req->cmd_type == REQ_TYPE_DRV_PRIV) {
623623
if (cmd_rq->ctx == CMD_CTX_CANCELLED)
624-
status = -EINTR;
624+
error = -EINTR;
625+
else
626+
error = status;
625627
} else {
626-
status = nvme_error_status(status);
628+
error = nvme_error_status(status);
627629
}
628630
}
629631

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

640642
if (iod->nents) {
641643
dma_unmap_sg(nvmeq->dev->dev, iod->sg, iod->nents,
@@ -649,7 +651,7 @@ static void req_completion(struct nvme_queue *nvmeq, void *ctx,
649651
}
650652
nvme_free_iod(nvmeq->dev, iod);
651653

652-
blk_mq_complete_request(req, status);
654+
blk_mq_complete_request(req, error);
653655
}
654656

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

0 commit comments

Comments
 (0)