[PATCH 3/3] nvmet: include all configured ports in discovery log page for unique discover controller
Hannes Reinecke
hare at suse.de
Thu Mar 17 06:18:33 PDT 2022
When an unique discovery controller is configured we should be reporting
all configured ports, and not just those which are reachable from the
current port.
Signed-off-by: Hannes Reinecke <hare at suse.de>
---
drivers/nvme/target/discovery.c | 69 ++++++++++++++++++++++++---------
1 file changed, 51 insertions(+), 18 deletions(-)
diff --git a/drivers/nvme/target/discovery.c b/drivers/nvme/target/discovery.c
index bceeec00099a..6cefd4f60f9f 100644
--- a/drivers/nvme/target/discovery.c
+++ b/drivers/nvme/target/discovery.c
@@ -160,12 +160,24 @@ static size_t discovery_log_entries(struct nvmet_req *req)
struct nvmet_ctrl *ctrl = req->sq->ctrl;
struct nvmet_subsys_link *p;
struct nvmet_port *r;
- size_t entries = 1;
-
- list_for_each_entry(p, &req->port->subsystems, entry) {
- if (!nvmet_host_allowed(p->subsys, ctrl->hostnqn))
- continue;
+ size_t entries = 0;
+
+ if (nvmet_has_unique_disc_subsys()) {
+ list_for_each_entry(r, nvmet_ports, global_entry) {
+ list_for_each_entry(p, &r->subsystems, entry) {
+ if (!nvmet_host_allowed(p->subsys,
+ ctrl->hostnqn))
+ continue;
+ entries++;
+ }
+ }
+ } else {
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, &req->port->referrals, entry)
entries++;
@@ -220,23 +232,44 @@ static void nvmet_execute_disc_get_log_page(struct nvmet_req *req)
}
hdr = buffer;
- 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;
+ if (!nvmet_has_unique_disc_subsys()) {
+ nvmet_set_disc_traddr(req, req->port, traddr);
nvmet_format_discovery_entry(hdr, req->port,
- p->subsys->subsysnqn, traddr,
- NVME_NQN_NVME, numrec);
+ 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);
+ numrec++;
+ }
+ } else {
+ list_for_each_entry(p, &req->port->subsystems, entry) {
+ list_for_each_entry(r, nvmet_ports, global_entry) {
+ struct nvmet_subsys_link *l;
+
+ nvmet_set_disc_traddr(req, r, traddr);
+
+ list_for_each_entry(l, &r->subsystems, entry) {
+ if (p->subsys != l->subsys)
+ continue;
+ if (!nvmet_host_allowed(l->subsys,
+ ctrl->hostnqn))
+ continue;
+ nvmet_format_discovery_entry(hdr, r,
+ l->subsys->subsysnqn, traddr,
+ l->subsys->type, numrec);
+ numrec++;
+ }
+ }
+ }
+ }
list_for_each_entry(r, &req->port->referrals, entry) {
nvmet_format_discovery_entry(hdr, r,
NVME_DISC_SUBSYS_NAME,
--
2.29.2
More information about the Linux-nvme
mailing list