* [PATCH] hw/block/nvme: refactor zone state check for read
@ 2021-01-29 6:17 Klaus Jensen
0 siblings, 0 replies; only message in thread
From: Klaus Jensen @ 2021-01-29 6:17 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, qemu-block, Klaus Jensen, Gollu Appalanaidu,
Max Reitz, Keith Busch, Klaus Jensen
From: Gollu Appalanaidu <anaidu.gollu@samsung.com>
Align with nvme_check_zone_write.
Remove unnecessary storing status value and return at the end of the
function, if error occurs return immediately if applicable.
Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
Reviewed-by: Klaus Jensen <k.jensen@samsung.com>
---
hw/block/nvme.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index 8ac997735041..1dbd6ec129ae 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -1210,7 +1210,7 @@ static uint16_t nvme_check_zone_write(NvmeCtrl *n, NvmeNamespace *ns,
static uint16_t nvme_check_zone_state_for_read(NvmeZone *zone)
{
- uint16_t status;
+ uint64_t zslba = zone->d.zslba;
switch (nvme_get_zone_state(zone)) {
case NVME_ZONE_STATE_EMPTY:
@@ -1219,16 +1219,13 @@ static uint16_t nvme_check_zone_state_for_read(NvmeZone *zone)
case NVME_ZONE_STATE_FULL:
case NVME_ZONE_STATE_CLOSED:
case NVME_ZONE_STATE_READ_ONLY:
- status = NVME_SUCCESS;
- break;
+ return NVME_SUCCESS;
case NVME_ZONE_STATE_OFFLINE:
- status = NVME_ZONE_OFFLINE;
- break;
+ trace_pci_nvme_err_zone_is_offline(zslba);
+ return NVME_ZONE_OFFLINE;
default:
assert(false);
}
-
- return status;
}
static uint16_t nvme_check_zone_read(NvmeNamespace *ns, uint64_t slba,
@@ -1241,10 +1238,10 @@ static uint16_t nvme_check_zone_read(NvmeNamespace *ns, uint64_t slba,
status = nvme_check_zone_state_for_read(zone);
if (status) {
- ;
+ return status;
} else if (unlikely(end > bndry)) {
if (!ns->params.cross_zone_read) {
- status = NVME_ZONE_BOUNDARY_ERROR;
+ return NVME_ZONE_BOUNDARY_ERROR;
} else {
/*
* Read across zone boundary - check that all subsequent
@@ -1254,7 +1251,7 @@ static uint16_t nvme_check_zone_read(NvmeNamespace *ns, uint64_t slba,
zone++;
status = nvme_check_zone_state_for_read(zone);
if (status) {
- break;
+ return status;
}
} while (end > nvme_zone_rd_boundary(ns, zone));
}
--
2.30.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-01-29 6:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-29 6:17 [PATCH] hw/block/nvme: refactor zone state check for read Klaus Jensen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).