[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 9/9] hw/nvme: remove nvme_aio_err()
From: |
Klaus Jensen |
Subject: |
[PATCH 9/9] hw/nvme: remove nvme_aio_err() |
Date: |
Mon, 16 Dec 2024 13:53:10 +0100 |
From: Klaus Jensen <k.jensen@samsung.com>
nvme_rw_complete_cb() is the only remaining user of nvme_aio_err(), so
open code the status code setting instead.
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
---
hw/nvme/ctrl.c | 60 ++++++++++++++++++++++------------------------------------
1 file changed, 23 insertions(+), 37 deletions(-)
diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index
8192f92227d6509b8d15fde9d9197a59277eb86f..40f535b03316ed45f6cbb2894fd89f9ce258423e
100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -1756,42 +1756,6 @@ static uint16_t nvme_check_dulbe(NvmeNamespace *ns,
uint64_t slba,
return NVME_SUCCESS;
}
-static void nvme_aio_err(NvmeRequest *req, int ret)
-{
- uint16_t status = NVME_SUCCESS;
- Error *local_err = NULL;
-
- switch (req->cmd.opcode) {
- case NVME_CMD_READ:
- status = NVME_UNRECOVERED_READ;
- break;
- case NVME_CMD_WRITE:
- case NVME_CMD_WRITE_ZEROES:
- case NVME_CMD_ZONE_APPEND:
- case NVME_CMD_COPY:
- status = NVME_WRITE_FAULT;
- break;
- default:
- status = NVME_INTERNAL_DEV_ERROR;
- break;
- }
-
- trace_pci_nvme_err_aio(nvme_cid(req), strerror(-ret), status);
-
- error_setg_errno(&local_err, -ret, "aio failed");
- error_report_err(local_err);
-
- /*
- * Set the command status code to the first encountered error but allow a
- * subsequent Internal Device Error to trump it.
- */
- if (req->status && status != NVME_INTERNAL_DEV_ERROR) {
- return;
- }
-
- req->status = status;
-}
-
static inline uint32_t nvme_zone_idx(NvmeNamespace *ns, uint64_t slba)
{
return ns->zone_size_log2 > 0 ? slba >> ns->zone_size_log2 :
@@ -2176,8 +2140,30 @@ void nvme_rw_complete_cb(void *opaque, int ret)
trace_pci_nvme_rw_complete_cb(nvme_cid(req), blk_name(blk));
if (ret) {
+ Error *err = NULL;
+
block_acct_failed(stats, acct);
- nvme_aio_err(req, ret);
+
+ switch (req->cmd.opcode) {
+ case NVME_CMD_READ:
+ req->status = NVME_UNRECOVERED_READ;
+ break;
+
+ case NVME_CMD_WRITE:
+ case NVME_CMD_WRITE_ZEROES:
+ case NVME_CMD_ZONE_APPEND:
+ req->status = NVME_WRITE_FAULT;
+ break;
+
+ default:
+ req->status = NVME_INTERNAL_DEV_ERROR;
+ break;
+ }
+
+ trace_pci_nvme_err_aio(nvme_cid(req), strerror(-ret), req->status);
+
+ error_setg_errno(&err, -ret, "aio failed");
+ error_report_err(err);
} else {
block_acct_done(stats, acct);
}
--
2.45.2
- [PATCH 0/9] hw/nvme: refactor/cleanup, Klaus Jensen, 2024/12/16
- [PATCH 2/9] hw/nvme: make oacs dynamic, Klaus Jensen, 2024/12/16
- [PATCH 1/9] hw/nvme: always initialize a subsystem, Klaus Jensen, 2024/12/16
- [PATCH 5/9] hw/nvme: be compliant wrt. dsm processing limits, Klaus Jensen, 2024/12/16
- [PATCH 4/9] nvme: fix iocs status code values, Klaus Jensen, 2024/12/16
- [PATCH 3/9] hw/nvme: add knob for doorbell buffer config support, Klaus Jensen, 2024/12/16
- [PATCH 9/9] hw/nvme: remove nvme_aio_err(),
Klaus Jensen <=
- [PATCH 6/9] hw/nvme: rework csi handling, Klaus Jensen, 2024/12/16
- [PATCH 7/9] hw/nvme: only set command abort requested when cancelled due to Abort, Klaus Jensen, 2024/12/16
- [PATCH 8/9] hw/nvme: set error status code explicitly for misc commands, Klaus Jensen, 2024/12/16