[PATCH 2/3] nvmet: prevent creating ctrl with no namespace
Chaitanya Kulkarni
chaitanya.kulkarni at wdc.com
Sun Jun 13 13:02:51 PDT 2021
>From Spec :-
If the controller supports Asymmetric Namespace Access Reporting, then
MNAN shall be set to a non-zero value that is less than or equal
to the NN value.
In current implementation if subsys has 0 namespaces then we report
wrong MNAN value for the controller if we allow controller creation.
Prevent new controller creation if the subsys associated with the new
controller has no namespaces.
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
---
drivers/nvme/target/core.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index 146909486b8f..26d93ac9bd2e 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -1325,6 +1325,15 @@ u16 nvmet_alloc_ctrl(const char *subsysnqn, const char *hostnqn,
goto out;
}
+ mutex_lock(&subsys->lock);
+ if (!subsys->max_nsid) {
+ mutex_unlock(&subsys->lock);
+ pr_err("invalid mnan value for the ana enabled controller\n");
+ status = NVME_SC_INTERNAL;
+ goto out_put_subsystem;
+ }
+ mutex_unlock(&subsys->lock);
+
down_read(&nvmet_config_sem);
if (!nvmet_host_allowed(subsys, hostnqn)) {
pr_info("connect by host %s for subsystem %s not allowed\n",
--
2.22.1
More information about the Linux-nvme
mailing list