From: Hannes Reinecke <hare@suse.de>
To: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagi@grimberg.me>,
Keith Busch <keith.busch@wdc.com>,
linux-nvme@lists.infradead.org, Hannes Reinecke <hare@suse.de>
Subject: [PATCH 1/3] nvmet: expose discovery subsystem in sysfs
Date: Mon, 14 Mar 2022 11:53:31 +0100 [thread overview]
Message-ID: <20220314105333.56714-2-hare@suse.de> (raw)
In-Reply-To: <20220314105333.56714-1-hare@suse.de>
Expose the discovery subsystem in sysfs instead of having it as
an internal structure. This requires the admin to manually
enable the discovery subsystem by linking it to a port, but
this can be seen as a feature as it will allows us to expose
subsystems without discovery subsystems and discovery subsystems
with no I/O subsystems.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
drivers/nvme/target/configfs.c | 11 +++++++++++
drivers/nvme/target/core.c | 1 +
drivers/nvme/target/discovery.c | 7 +------
3 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
index a54cbddd764e..9b94af2444b2 100644
--- a/drivers/nvme/target/configfs.c
+++ b/drivers/nvme/target/configfs.c
@@ -1041,6 +1041,11 @@ static ssize_t nvmet_subsys_attr_allow_any_host_store(struct config_item *item,
if (strtobool(page, &allow_any_host))
return -EINVAL;
+ if (subsys == nvmet_disc_subsys) {
+ pr_err("Can't change allow_any_host on discovery subsystem!\n");
+ return -EPERM;
+ }
+
down_write(&nvmet_config_sem);
if (allow_any_host && !list_empty(&subsys->hosts)) {
pr_err("Can't set allow_any_host when explicit hosts are set!\n");
@@ -1965,6 +1970,12 @@ int __init nvmet_init_configfs(void)
configfs_add_default_group(&nvmet_subsystems_group,
&nvmet_configfs_subsystem.su_group);
+ config_group_init_type_name(&nvmet_disc_subsys->group,
+ NVME_DISC_SUBSYS_NAME,
+ &nvmet_subsys_type);
+ configfs_add_default_group(&nvmet_disc_subsys->group,
+ &nvmet_subsystems_group);
+
config_group_init_type_name(&nvmet_ports_group,
"ports", &nvmet_ports_type);
configfs_add_default_group(&nvmet_ports_group,
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index 44f544356081..fab92c008c53 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -1557,6 +1557,7 @@ struct nvmet_subsys *nvmet_subsys_alloc(const char *subsysnqn,
break;
case NVME_NQN_DISC:
case NVME_NQN_CURR:
+ subsys->allow_any_host = 1;
subsys->max_qid = 0;
break;
default:
diff --git a/drivers/nvme/target/discovery.c b/drivers/nvme/target/discovery.c
index c2162eef8ce1..90bcc829c12a 100644
--- a/drivers/nvme/target/discovery.c
+++ b/drivers/nvme/target/discovery.c
@@ -208,18 +208,13 @@ static void nvmet_execute_disc_get_log_page(struct nvmet_req *req)
nvmet_set_disc_traddr(req, req->port, traddr);
- nvmet_format_discovery_entry(hdr, req->port,
- nvmet_disc_subsys->subsysnqn,
- traddr, NVME_NQN_CURR, numrec);
- numrec++;
-
list_for_each_entry(p, &req->port->subsystems, entry) {
if (!nvmet_host_allowed(p->subsys, ctrl->hostnqn))
continue;
nvmet_format_discovery_entry(hdr, req->port,
p->subsys->subsysnqn, traddr,
- NVME_NQN_NVME, numrec);
+ p->subsys->type, numrec);
numrec++;
}
--
2.29.2
next prev parent reply other threads:[~2022-03-14 10:54 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-14 10:53 [RFC PATCH 0/3] nvmet: export discovery subsystem Hannes Reinecke
2022-03-14 10:53 ` Hannes Reinecke [this message]
2022-03-15 8:06 ` [PATCH 1/3] nvmet: expose discovery subsystem in sysfs Christoph Hellwig
2022-03-15 8:40 ` Sagi Grimberg
2022-03-15 9:06 ` Hannes Reinecke
2022-03-15 9:49 ` Christoph Hellwig
2022-03-15 10:23 ` Sagi Grimberg
2022-03-15 10:38 ` Hannes Reinecke
2022-03-15 10:49 ` Sagi Grimberg
2022-03-15 11:09 ` Hannes Reinecke
2022-03-15 11:15 ` Sagi Grimberg
2022-03-15 12:51 ` Hannes Reinecke
2022-03-15 13:48 ` Sagi Grimberg
2022-03-23 17:17 ` John Meneghini
2022-03-23 17:23 ` Christoph Hellwig
2022-03-23 17:52 ` John Meneghini
2022-03-23 17:34 ` Knight, Frederick
2022-03-23 18:03 ` John Meneghini
2022-03-23 18:07 ` Knight, Frederick
2022-03-14 10:53 ` [PATCH 2/3] nvmet: restrict setting of discovery_nqn to discovery subsystem Hannes Reinecke
2022-03-15 8:09 ` Christoph Hellwig
2022-03-15 8:57 ` Sagi Grimberg
2022-03-15 9:00 ` Christoph Hellwig
2022-03-24 0:52 ` John Meneghini
2022-03-24 1:46 ` John Meneghini
2022-03-14 10:53 ` [PATCH 3/3] nvmet: do not allow to create a subsystem with the discovery NQN Hannes Reinecke
2022-03-15 8:10 ` Christoph Hellwig
2022-03-15 8:45 ` Hannes Reinecke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220314105333.56714-2-hare@suse.de \
--to=hare@suse.de \
--cc=hch@lst.de \
--cc=keith.busch@wdc.com \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox