aboutsummaryrefslogtreecommitdiff
path: root/hw/block
diff options
context:
space:
mode:
authorKlaus Jensen <k.jensen@samsung.com>2020-08-24 08:48:55 +0200
committerKlaus Jensen <k.jensen@samsung.com>2020-10-27 07:24:46 +0100
commitc6056bd1ce63d6d4eac6c54126c32838624efdac (patch)
tree8f457d58ec614c6dfad9ad8bd6b32d6f1c549344 /hw/block
parent94cbcf530f9d9789b75ef1ae227ba4a4f702bf7d (diff)
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>
Diffstat (limited to 'hw/block')
-rw-r--r--hw/block/nvme.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index 7d328c08b8..0ac9d85663 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -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)