[PATCH] nvmet: remove max_nsid calculation
hare at kernel.org
hare at kernel.org
Thu Jan 23 23:14:14 PST 2025
From: Hannes Reinecke <hare at kernel.org>
We never look at the 'max_nsid' value, and it's questionable
whether it is even calculated correctly. So remove it.
Signed-off-by: Hannes Reinecke <hare at kernel.org>
---
drivers/nvme/target/core.c | 18 ------------------
drivers/nvme/target/nvmet.h | 1 -
2 files changed, 19 deletions(-)
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index a058f473652c..78ba6162361a 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -121,18 +121,6 @@ u16 nvmet_zero_sgl(struct nvmet_req *req, off_t off, size_t len)
return 0;
}
-static u32 nvmet_max_nsid(struct nvmet_subsys *subsys)
-{
- struct nvmet_ns *cur;
- unsigned long idx;
- u32 nsid = 0;
-
- nvmet_for_each_enabled_ns(&subsys->namespaces, idx, cur)
- nsid = cur->nsid;
-
- return nsid;
-}
-
static u32 nvmet_async_event_result(struct nvmet_async_event *aen)
{
return aen->event_type | (aen->event_info << 8) | (aen->log_page << 16);
@@ -657,8 +645,6 @@ void nvmet_ns_free(struct nvmet_ns *ns)
mutex_lock(&subsys->lock);
xa_erase(&subsys->namespaces, ns->nsid);
- if (ns->nsid == subsys->max_nsid)
- subsys->max_nsid = nvmet_max_nsid(subsys);
mutex_unlock(&subsys->lock);
@@ -708,9 +694,6 @@ struct nvmet_ns *nvmet_ns_alloc(struct nvmet_subsys *subsys, u32 nsid)
if (percpu_ref_init(&ns->ref, nvmet_destroy_namespace, 0, GFP_KERNEL))
goto out_free;
- if (ns->nsid > subsys->max_nsid)
- subsys->max_nsid = nsid;
-
if (xa_insert(&subsys->namespaces, ns->nsid, ns, GFP_KERNEL))
goto out_exit;
@@ -729,7 +712,6 @@ struct nvmet_ns *nvmet_ns_alloc(struct nvmet_subsys *subsys, u32 nsid)
return ns;
out_exit:
- subsys->max_nsid = nvmet_max_nsid(subsys);
percpu_ref_exit(&ns->ref);
out_free:
kfree(ns);
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index 62a554b00951..4dc7ba5d02a7 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -316,7 +316,6 @@ struct nvmet_subsys {
struct xarray namespaces;
unsigned int nr_namespaces;
- u32 max_nsid;
u16 cntlid_min;
u16 cntlid_max;
--
2.35.3
More information about the Linux-nvme
mailing list