[PATCH 2/2] nvme: reduce a repeated ZNS check
Kanchan Joshi
joshi.k at samsung.com
Wed May 1 23:34:38 PDT 2024
Modify nvme_update_ns_info_block() to eliminate the repeated check for
ZNS.
Signed-off-by: Kanchan Joshi <joshi.k at samsung.com>
---
drivers/nvme/host/core.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 8ae0a2dc5eda..7f4df3932ca4 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2081,6 +2081,7 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
sector_t capacity;
unsigned lbaf;
int ret;
+ bool is_zns;
ret = nvme_identify_ns(ns->ctrl, info->nsid, &id);
if (ret)
@@ -2100,8 +2101,9 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
goto out;
}
- if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) &&
- ns->head->ids.csi == NVME_CSI_ZNS) {
+ is_zns = IS_ENABLED(CONFIG_BLK_DEV_ZONED) &&
+ ns->head->ids.csi == NVME_CSI_ZNS;
+ if (is_zns) {
ret = nvme_query_zone_info(ns, lbaf, &zi);
if (ret < 0)
goto out;
@@ -2119,8 +2121,7 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
if (!nvme_update_disk_info(ns, id, &lim))
capacity = 0;
nvme_config_discard(ns, &lim);
- if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) &&
- ns->head->ids.csi == NVME_CSI_ZNS)
+ if (is_zns)
nvme_update_zone_info(ns, &lim, &zi);
ret = queue_limits_commit_update(ns->disk->queue, &lim);
if (ret) {
--
2.25.1
More information about the Linux-nvme
mailing list