hw/block/nvme: refactor zone state check for read
PATCH 1/1 hw/block/nvme: refactor zone state check for read
From: Gollu Appalanaidu <[email protected]>
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 <[email protected]>
Reviewed-by Klaus Jensen <[email protected]>
--- hw/block/nvme.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
hw/block/nvme.c +7 -10
@@ -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)); }
Signature · 1 line
2.30.0