All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagi@grimberg.me>, Keith Busch <kbusch@kernel.org>,
	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: Thu,  7 Apr 2022 12:48:08 +0200	[thread overview]
Message-ID: <20220407104808.29007-4-hare@suse.de> (raw)
In-Reply-To: <20220407104808.29007-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.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/nvme/target/discovery.c | 52 ++++++++++++++++++++++++++-------
 1 file changed, 41 insertions(+), 11 deletions(-)

diff --git a/drivers/nvme/target/discovery.c b/drivers/nvme/target/discovery.c
index e3d8cc407a94..6d414096d09a 100644
--- a/drivers/nvme/target/discovery.c
+++ b/drivers/nvme/target/discovery.c
@@ -152,10 +152,19 @@ static size_t discovery_log_entries(struct nvmet_req *req)
 	if (req->port->disc_subsys == nvmet_disc_subsys)
 		entries++;
 
-	list_for_each_entry(p, &req->port->subsystems, entry) {
-		if (!nvmet_host_allowed(p->subsys, ctrl->hostnqn))
-			continue;
-		entries++;
+	list_for_each_entry(r, nvmet_ports, global_entry) {
+		if (req->port->disc_subsys == nvmet_disc_subsys) {
+			if (r != req->port)
+				continue;
+		} else {
+			if (ctrl->subsys != r->disc_subsys)
+				continue;
+		}
+		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++;
@@ -219,14 +228,35 @@ 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))
-			continue;
+	list_for_each_entry(r, nvmet_ports, global_entry) {
+		nvmet_set_disc_traddr(req, r, traddr);
 
-		nvmet_format_discovery_entry(hdr, req->port,
-				p->subsys->subsysnqn, traddr,
-				p->subsys->type, numrec);
-		numrec++;
+		if (req->port->disc_subsys == nvmet_disc_subsys) {
+			/*
+			 * Present information about the port to which
+			 * the controller is connected.
+			 */
+			if (r != req->port)
+				continue;
+		} else {
+			/*
+			 * If a per-port discovery subsystem is used present
+			 * information about all ports into which the
+			 * same discovery subsystem is linked.
+			 */
+			if (ctrl->subsys != r->disc_subsys)
+				continue;
+		}
+
+		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



  parent reply	other threads:[~2022-04-07 10:55 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-07 10:48 [PATCHv4 0/3] nvmet: unique discovery subsystems Hannes Reinecke
2022-04-07 10:48 ` [PATCH 1/3] nvmet: make the subsystem type configurable Hannes Reinecke
2022-04-07 15:44   ` Christoph Hellwig
2022-04-07 16:55     ` Hannes Reinecke
2022-04-08  5:46       ` Christoph Hellwig
2022-04-07 10:48 ` [PATCH 2/3] nvmet: per-port discovery subsystem Hannes Reinecke
2022-04-07 15:49   ` Christoph Hellwig
2022-04-07 17:21     ` Hannes Reinecke
2022-04-08  5:48       ` Christoph Hellwig
2022-04-07 10:48 ` Hannes Reinecke [this message]
2022-04-07 13:29   ` [PATCH 3/3] nvmet: include all configured ports in the discovery log page 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
  -- strict thread matches above, loose matches on Subject: below --
2022-04-08  6:59 [PATCHv5 0/3] nvmet: unique discovery subsystems Hannes Reinecke
2022-04-08  6:59 ` [PATCH 3/3] nvmet: include all configured ports in the discovery log page Hannes Reinecke
2022-04-11 10:54   ` 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

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=20220407104808.29007-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.