[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] hw/block/nvme: refactor zone state check for read
From: |
Klaus Jensen |
Subject: |
[PATCH] hw/block/nvme: refactor zone state check for read |
Date: |
Fri, 29 Jan 2021 07:17:49 +0100 |
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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] hw/block/nvme: refactor zone state check for read,
Klaus Jensen <=