e9a429e9ba
Includes: fabrics: only look for matching ctrl on same host Resolves: #2223436 Signed-off-by: John Meneghini <jmeneghi@redhat.com>
157 lines
4.7 KiB
Diff
157 lines
4.7 KiB
Diff
From 9cf31d24f8b3911b870cb217c6715637459a376a Mon Sep 17 00:00:00 2001
|
|
From: Caleb Sander <csander@purestorage.com>
|
|
Date: Wed, 28 Jun 2023 14:35:24 -0600
|
|
Subject: [PATCH] fabrics: only look for matching ctrl on same host
|
|
Content-type: text/plain
|
|
|
|
With the lookup_ctrl() check to prevent duplicate connections,
|
|
identical connections from different hosts are no longer possible.
|
|
Fix lookup_ctrl() to only look for matching controllers
|
|
on the same host that is being connected.
|
|
This restores the ability for multiple hosts on the same machine
|
|
to connect to the same transport addresses on the same subsystem.
|
|
|
|
Fixes: 07d6b91 ("fabrics: Do not attempt to reconnect to already
|
|
connected ctrls")
|
|
Signed-off-by: Caleb Sander <csander@purestorage.com>
|
|
---
|
|
fabrics.c | 40 ++++++++++++++++++++++++++--------------
|
|
fabrics.h | 2 +-
|
|
nbft.c | 4 ++--
|
|
3 files changed, 29 insertions(+), 17 deletions(-)
|
|
|
|
diff --git a/fabrics.c b/fabrics.c
|
|
index ac240cad..14a91cc6 100644
|
|
--- a/fabrics.c
|
|
+++ b/fabrics.c
|
|
@@ -149,6 +149,8 @@ static bool is_persistent_discovery_ctrl(nvme_host_t h, nvme_ctrl_t c)
|
|
return false;
|
|
}
|
|
|
|
+typedef bool (*ctrl_match_fn_t)(nvme_ctrl_t, struct tr_config *);
|
|
+
|
|
static bool disc_ctrl_config_match(nvme_ctrl_t c, struct tr_config *trcfg)
|
|
{
|
|
if (nvme_ctrl_is_discovery_ctrl(c) &&
|
|
@@ -175,34 +177,45 @@ static bool ctrl_config_match(nvme_ctrl_t c, struct tr_config *trcfg)
|
|
return false;
|
|
}
|
|
|
|
-static nvme_ctrl_t __lookup_ctrl(nvme_root_t r, struct tr_config *trcfg,
|
|
- bool (*filter)(nvme_ctrl_t, struct tr_config *))
|
|
+static nvme_ctrl_t __lookup_host_ctrl(nvme_host_t h, struct tr_config *trcfg,
|
|
+ ctrl_match_fn_t filter)
|
|
{
|
|
- nvme_host_t h;
|
|
nvme_subsystem_t s;
|
|
nvme_ctrl_t c;
|
|
|
|
- nvme_for_each_host(r, h) {
|
|
- nvme_for_each_subsystem(h, s) {
|
|
- nvme_subsystem_for_each_ctrl(s, c) {
|
|
- if (!(filter(c, trcfg)))
|
|
- continue;
|
|
+ nvme_for_each_subsystem(h, s) {
|
|
+ nvme_subsystem_for_each_ctrl(s, c) {
|
|
+ if (filter(c, trcfg))
|
|
return c;
|
|
- }
|
|
}
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
+static nvme_ctrl_t __lookup_ctrl(nvme_root_t r, struct tr_config *trcfg,
|
|
+ ctrl_match_fn_t filter)
|
|
+{
|
|
+ nvme_host_t h;
|
|
+ nvme_ctrl_t c;
|
|
+
|
|
+ nvme_for_each_host(r, h) {
|
|
+ c = __lookup_host_ctrl(h, trcfg, filter);
|
|
+ if (c)
|
|
+ return c;
|
|
+ }
|
|
+
|
|
+ return NULL;
|
|
+}
|
|
+
|
|
static nvme_ctrl_t lookup_discovery_ctrl(nvme_root_t r, struct tr_config *trcfg)
|
|
{
|
|
return __lookup_ctrl(r, trcfg, disc_ctrl_config_match);
|
|
}
|
|
|
|
-nvme_ctrl_t lookup_ctrl(nvme_root_t r, struct tr_config *trcfg)
|
|
+nvme_ctrl_t lookup_ctrl(nvme_host_t h, struct tr_config *trcfg)
|
|
{
|
|
- return __lookup_ctrl(r, trcfg, ctrl_config_match);
|
|
+ return __lookup_host_ctrl(h, trcfg, ctrl_config_match);
|
|
}
|
|
|
|
static int set_discovery_kato(struct nvme_fabrics_config *cfg)
|
|
@@ -317,7 +330,6 @@ static int __discover(nvme_ctrl_t c, struct nvme_fabrics_config *defcfg,
|
|
struct nvmf_discovery_log *log = NULL;
|
|
nvme_subsystem_t s = nvme_ctrl_get_subsystem(c);
|
|
nvme_host_t h = nvme_subsystem_get_host(s);
|
|
- nvme_root_t r = nvme_host_get_root(h);
|
|
uint64_t numrec;
|
|
|
|
struct nvme_get_discovery_args args = {
|
|
@@ -362,7 +374,7 @@ static int __discover(nvme_ctrl_t c, struct nvme_fabrics_config *defcfg,
|
|
};
|
|
|
|
/* Already connected ? */
|
|
- cl = lookup_ctrl(r, &trcfg);
|
|
+ cl = lookup_ctrl(h, &trcfg);
|
|
if (cl && nvme_ctrl_get_name(cl))
|
|
continue;
|
|
|
|
@@ -989,7 +1001,7 @@ int nvmf_connect(const char *desc, int argc, char **argv)
|
|
.trsvcid = trsvcid,
|
|
};
|
|
|
|
- c = lookup_ctrl(r, &trcfg);
|
|
+ c = lookup_ctrl(h, &trcfg);
|
|
if (c && nvme_ctrl_get_name(c)) {
|
|
fprintf(stderr, "already connected\n");
|
|
errno = EALREADY;
|
|
diff --git a/fabrics.h b/fabrics.h
|
|
index 02cebf5d..c16df604 100644
|
|
--- a/fabrics.h
|
|
+++ b/fabrics.h
|
|
@@ -11,7 +11,7 @@ struct tr_config {
|
|
const char *trsvcid;
|
|
};
|
|
|
|
-extern nvme_ctrl_t lookup_ctrl(nvme_root_t r, struct tr_config *trcfg);
|
|
+extern nvme_ctrl_t lookup_ctrl(nvme_host_t h, struct tr_config *trcfg);
|
|
extern int nvmf_discover(const char *desc, int argc, char **argv, bool connect);
|
|
extern int nvmf_connect(const char *desc, int argc, char **argv);
|
|
extern int nvmf_disconnect(const char *desc, int argc, char **argv);
|
|
diff --git a/nbft.c b/nbft.c
|
|
index c73413f5..e46e9d3d 100644
|
|
--- a/nbft.c
|
|
+++ b/nbft.c
|
|
@@ -144,7 +144,7 @@ int discover_from_nbft(nvme_root_t r, char *hostnqn_arg, char *hostid_arg,
|
|
};
|
|
|
|
/* Already connected ? */
|
|
- cl = lookup_ctrl(r, &trcfg);
|
|
+ cl = lookup_ctrl(h, &trcfg);
|
|
if (cl && nvme_ctrl_get_name(cl))
|
|
continue;
|
|
|
|
@@ -170,7 +170,7 @@ int discover_from_nbft(nvme_root_t r, char *hostnqn_arg, char *hostid_arg,
|
|
nvme_free_ctrl(c);
|
|
|
|
trcfg.host_traddr = NULL;
|
|
- cl = lookup_ctrl(r, &trcfg);
|
|
+ cl = lookup_ctrl(h, &trcfg);
|
|
if (cl && nvme_ctrl_get_name(cl))
|
|
continue;
|
|
|
|
--
|
|
2.39.3
|
|
|