diff options
author | Klaus Jensen <k.jensen@samsung.com> | 2020-08-24 08:48:55 +0200 |
---|---|---|
committer | Klaus Jensen <k.jensen@samsung.com> | 2020-10-27 07:24:46 +0100 |
commit | c6056bd1ce63d6d4eac6c54126c32838624efdac (patch) | |
tree | 8f457d58ec614c6dfad9ad8bd6b32d6f1c549344 | |
parent | 94cbcf530f9d9789b75ef1ae227ba4a4f702bf7d (diff) | |
download | qemu-c6056bd1ce63d6d4eac6c54126c32838624efdac.zip qemu-c6056bd1ce63d6d4eac6c54126c32838624efdac.tar.gz qemu-c6056bd1ce63d6d4eac6c54126c32838624efdac.tar.bz2 |
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>
-rw-r--r-- | hw/block/nvme.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 7d328c0..0ac9d85 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) |