hw/block/nvme: commonize nvme_rw error handling

Move common error handling to a label.

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
This commit is contained in:
Klaus Jensen 2020-08-24 08:48:55 +02:00
parent 94cbcf530f
commit c6056bd1ce
1 changed files with 9 additions and 7 deletions

View File

@ -687,20 +687,18 @@ static uint16_t nvme_rw(NvmeCtrl *n, NvmeRequest *req)
status = nvme_check_mdts(n, data_size);
if (status) {
trace_pci_nvme_err_mdts(nvme_cid(req), data_size);
block_acct_invalid(blk_get_stats(n->conf.blk), acct);
return status;
goto invalid;
}
status = nvme_check_bounds(n, ns, slba, nlb);
if (status) {
trace_pci_nvme_err_invalid_lba_range(slba, nlb, ns->id_ns.nsze);
block_acct_invalid(blk_get_stats(n->conf.blk), acct);
return status;
goto invalid;
}
if (nvme_map_dptr(n, data_size, req)) {
block_acct_invalid(blk_get_stats(n->conf.blk), acct);
return NVME_INVALID_FIELD | NVME_DNR;
status = nvme_map_dptr(n, data_size, req);
if (status) {
goto invalid;
}
if (req->qsg.nsg > 0) {
@ -722,6 +720,10 @@ static uint16_t nvme_rw(NvmeCtrl *n, NvmeRequest *req)
}
return NVME_NO_COMPLETE;
invalid:
block_acct_invalid(blk_get_stats(n->conf.blk), acct);
return status;
}
static uint16_t nvme_io_cmd(NvmeCtrl *n, NvmeRequest *req)