hw/block/nvme: pull aio error handling
Add a new function, nvme_aio_err, to handle errors resulting from AIOs and use this from the callbacks. Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
This commit is contained in:
parent
c519d9d55e
commit
54eea8d947
|
@ -878,26 +878,11 @@ static inline uint16_t nvme_check_bounds(NvmeNamespace *ns, uint64_t slba,
|
||||||
return NVME_SUCCESS;
|
return NVME_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nvme_rw_cb(void *opaque, int ret)
|
static void nvme_aio_err(NvmeRequest *req, int ret)
|
||||||
{
|
{
|
||||||
NvmeRequest *req = opaque;
|
uint16_t status = NVME_SUCCESS;
|
||||||
NvmeNamespace *ns = req->ns;
|
|
||||||
|
|
||||||
BlockBackend *blk = ns->blkconf.blk;
|
|
||||||
BlockAcctCookie *acct = &req->acct;
|
|
||||||
BlockAcctStats *stats = blk_get_stats(blk);
|
|
||||||
|
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
|
|
||||||
trace_pci_nvme_rw_cb(nvme_cid(req), blk_name(blk));
|
|
||||||
|
|
||||||
if (!ret) {
|
|
||||||
block_acct_done(stats, acct);
|
|
||||||
} else {
|
|
||||||
uint16_t status;
|
|
||||||
|
|
||||||
block_acct_failed(stats, acct);
|
|
||||||
|
|
||||||
switch (req->cmd.opcode) {
|
switch (req->cmd.opcode) {
|
||||||
case NVME_CMD_READ:
|
case NVME_CMD_READ:
|
||||||
status = NVME_UNRECOVERED_READ;
|
status = NVME_UNRECOVERED_READ;
|
||||||
|
@ -917,7 +902,33 @@ static void nvme_rw_cb(void *opaque, int ret)
|
||||||
error_setg_errno(&local_err, -ret, "aio failed");
|
error_setg_errno(&local_err, -ret, "aio failed");
|
||||||
error_report_err(local_err);
|
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;
|
req->status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void nvme_rw_cb(void *opaque, int ret)
|
||||||
|
{
|
||||||
|
NvmeRequest *req = opaque;
|
||||||
|
NvmeNamespace *ns = req->ns;
|
||||||
|
|
||||||
|
BlockBackend *blk = ns->blkconf.blk;
|
||||||
|
BlockAcctCookie *acct = &req->acct;
|
||||||
|
BlockAcctStats *stats = blk_get_stats(blk);
|
||||||
|
|
||||||
|
trace_pci_nvme_rw_cb(nvme_cid(req), blk_name(blk));
|
||||||
|
|
||||||
|
if (!ret) {
|
||||||
|
block_acct_done(stats, acct);
|
||||||
|
} else {
|
||||||
|
block_acct_failed(stats, acct);
|
||||||
|
nvme_aio_err(req, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
nvme_enqueue_req_completion(nvme_cq(req), req);
|
nvme_enqueue_req_completion(nvme_cq(req), req);
|
||||||
|
|
Loading…
Reference in New Issue