From: Hannes Reinecke <hare@suse.de>
To: Christoph Hellwig <hch@lst.de>
Cc: Keith Busch <kbusch@kernel.org>, Sagi Grimberg <sagi@grimberg.me>,
linux-nvme@lists.infradead.org, Hannes Reinecke <hare@suse.de>
Subject: [PATCH 3/3] nvmet: include all configured ports in the discovery log page
Date: Fri, 8 Apr 2022 08:59:30 +0200 [thread overview]
Message-ID: <20220408065930.123015-4-hare@suse.de> (raw)
In-Reply-To: <20220408065930.123015-1-hare@suse.de>
When a per-port discovery subsystem is used we should include
all configured ports in the discovery log page, not just that one
through which the controller was connected.
- /
o- ports
| o- 1 .. [trtype=tcp, traddr=127.0.0.1, trsvcid=8009]
| | o- subsystems
| | o- nqn.discovery
| o- 2 .. [trtype=tcp, traddr=127.0.0.1, trsvcid=4420]
| | o- subsystems
| | o- nqn.discovery
| | o- nqn.io-1
| o- 3 .. [trtype=tcp, traddr=127.0.0.1, trsvcid=4421]
| o- subsystems
| o- nqn.io-2
o- subsystems
o- nqn.discovery
o- nqn.io-1
| o- namespaces
o- nqn.io-2
o- namespaces
A discovery on port 8009 will return information about
- nqn.discovery at port 8009
- nqn.discovery at port 4420
- nqn.io-1 at port 4420
A discovery on port 4420 will return the same information.
A discovery on port 4421 will return information about
- standard discovery subsystem on port 4421
- nqn.io-2 on port 4421
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
drivers/nvme/target/discovery.c | 53 +++++++++++++++++++++++++++------
1 file changed, 44 insertions(+), 9 deletions(-)
diff --git a/drivers/nvme/target/discovery.c b/drivers/nvme/target/discovery.c
index 6b8aa6c4e752..ea8fce538342 100644
--- a/drivers/nvme/target/discovery.c
+++ b/drivers/nvme/target/discovery.c
@@ -149,6 +149,30 @@ static void nvmet_set_disc_traddr(struct nvmet_req *req, struct nvmet_port *port
memcpy(traddr, port->disc_addr.traddr, NVMF_TRADDR_SIZE);
}
+/*
+ * discovery_port_match - filter eligible ports for discovery log page
+ *
+ * If the port through which the controller is connected has no discovery
+ * subsystem linked, use the original behaviour of just including information
+ * about that port in the discovery log page.
+ * Otherwise include information about all ports into which the specified
+ * discovery subsystem is linked.
+ */
+
+static bool discovery_port_match(struct nvmet_req *req, struct nvmet_port *r)
+{
+ struct nvmet_ctrl *ctrl = req->sq->ctrl;
+
+ if (!req->port->disc_subsys) {
+ if (r != req->port)
+ return false;
+ } else {
+ if (ctrl->subsys != r->disc_subsys)
+ return false;
+ }
+ return true;
+}
+
static size_t discovery_log_entries(struct nvmet_req *req)
{
struct nvmet_ctrl *ctrl = req->sq->ctrl;
@@ -159,10 +183,14 @@ static size_t discovery_log_entries(struct nvmet_req *req)
if (!req->port->disc_subsys)
entries++;
- list_for_each_entry(p, &req->port->subsystems, entry) {
- if (!nvmet_host_allowed(p->subsys, ctrl->hostnqn))
+ list_for_each_entry(r, nvmet_ports, global_entry) {
+ if (!discovery_port_match(req, r))
continue;
- entries++;
+ list_for_each_entry(p, &r->subsystems, entry) {
+ if (!nvmet_host_allowed(p->subsys, ctrl->hostnqn))
+ continue;
+ entries++;
+ }
}
list_for_each_entry(r, &req->port->referrals, entry)
entries++;
@@ -226,14 +254,21 @@ static void nvmet_execute_disc_get_log_page(struct nvmet_req *req)
numrec++;
}
- list_for_each_entry(p, &req->port->subsystems, entry) {
- if (!nvmet_host_allowed(p->subsys, ctrl->hostnqn))
+ list_for_each_entry(r, nvmet_ports, global_entry) {
+ nvmet_set_disc_traddr(req, r, traddr);
+
+ if (!discovery_port_match(req, r))
continue;
- nvmet_format_discovery_entry(hdr, req->port,
- p->subsys->subsysnqn, traddr,
- p->subsys->type, numrec);
- numrec++;
+ list_for_each_entry(p, &r->subsystems, entry) {
+ if (!nvmet_host_allowed(p->subsys, ctrl->hostnqn))
+ continue;
+
+ nvmet_format_discovery_entry(hdr, r,
+ p->subsys->subsysnqn, traddr,
+ p->subsys->type, numrec);
+ numrec++;
+ }
}
list_for_each_entry(r, &req->port->referrals, entry) {
--
2.29.2
next prev parent reply other threads:[~2022-04-08 6:59 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-08 6:59 [PATCHv5 0/3] nvmet: unique discovery subsystems Hannes Reinecke
2022-04-08 6:59 ` [PATCH 1/3] nvmet: make the subsystem type configurable Hannes Reinecke
2022-04-11 10:32 ` Sagi Grimberg
2022-04-11 10:52 ` Hannes Reinecke
2022-04-11 10:36 ` Sagi Grimberg
2022-04-08 6:59 ` [PATCH 2/3] nvmet: per-port discovery subsystem Hannes Reinecke
2022-04-11 10:45 ` Sagi Grimberg
2022-04-11 12:07 ` Hannes Reinecke
2022-04-12 10:40 ` Sagi Grimberg
2022-04-12 11:51 ` Hannes Reinecke
2022-04-12 12:21 ` Sagi Grimberg
2022-04-08 6:59 ` Hannes Reinecke [this message]
2022-04-11 10:54 ` [PATCH 3/3] nvmet: include all configured ports in the discovery log page Sagi Grimberg
2022-04-11 12:27 ` Hannes Reinecke
2022-04-12 10:49 ` Sagi Grimberg
2022-04-12 12:08 ` Hannes Reinecke
2022-04-12 12:29 ` Sagi Grimberg
-- strict thread matches above, loose matches on Subject: below --
2022-04-07 10:48 [PATCHv4 0/3] nvmet: unique discovery subsystems Hannes Reinecke
2022-04-07 10:48 ` [PATCH 3/3] nvmet: include all configured ports in the discovery log page Hannes Reinecke
2022-04-07 13:29 ` Sagi Grimberg
2022-04-07 13:31 ` Hannes Reinecke
2022-04-07 13:34 ` Christoph Hellwig
2022-04-07 13:38 ` Sagi Grimberg
2022-04-07 14:51 ` Hannes Reinecke
2022-04-07 15:38 ` Christoph Hellwig
2022-04-07 15:41 ` Christoph Hellwig
2022-04-07 17:25 ` 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=20220408065930.123015-4-hare@suse.de \
--to=hare@suse.de \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.