[PATCH 3/3] nvmet: don't report subsys with 0 namespaces
Chaitanya Kulkarni
chaitanya.kulkarni at wdc.com
Sun Jun 13 13:02:52 PDT 2021
Skip reporting the subsys from the discovery log page which has no
namespaces.
This is needed because we don't allow creating a controller from such
subsystem from previous patch.
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
---
drivers/nvme/target/discovery.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/nvme/target/discovery.c b/drivers/nvme/target/discovery.c
index 7aa62bc6ae84..03a34ad3d59b 100644
--- a/drivers/nvme/target/discovery.c
+++ b/drivers/nvme/target/discovery.c
@@ -158,6 +158,17 @@ static size_t discovery_log_entries(struct nvmet_req *req)
return entries;
}
+static bool nvmet_disc_get_log_report_subsys(struct nvmet_subsys *s)
+{
+ bool skip;
+
+ mutex_lock(&s->lock);
+ /* skip reporting the subsys with 0 MNAN */
+ skip = s->max_nsid ? true : false;
+ mutex_unlock(&s->lock);
+ return skip;
+}
+
static void nvmet_execute_disc_get_log_page(struct nvmet_req *req)
{
const int entry_size = sizeof(struct nvmf_disc_rsp_page_entry);
@@ -210,6 +221,8 @@ static void nvmet_execute_disc_get_log_page(struct nvmet_req *req)
if (!nvmet_host_allowed(p->subsys, ctrl->hostnqn))
continue;
+ if (!nvmet_disc_get_log_report_subsys(p->subsys))
+ continue;
nvmet_set_disc_traddr(req, req->port, traddr);
nvmet_format_discovery_entry(hdr, req->port,
--
2.22.1
More information about the Linux-nvme
mailing list