Skip to content

Commit

Permalink
fabrics: Consider also all hosts settings for context match
Browse files Browse the repository at this point in the history
It's not enough to iterate over all subsystem of one host. We need to
iterate over all hosts as well to find a match.

Signed-off-by: Daniel Wagner <[email protected]>
  • Loading branch information
igaw committed Jul 20, 2023
1 parent fbd45f1 commit 1b042eb
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions src/nvme/fabrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,27 @@ static int __nvmf_add_ctrl(nvme_root_t r, const char *argstr)
return ret;
}

static const char *lookup_context(nvme_root_t r, nvme_ctrl_t c)
{

nvme_host_t h;
nvme_subsystem_t s;

nvme_for_each_host(r, h) {
nvme_for_each_subsystem(h, s) {
if (__nvme_lookup_ctrl(s, nvme_ctrl_get_transport(c),
nvme_ctrl_get_traddr(c),
NULL,
NULL,
nvme_ctrl_get_trsvcid(c),
NULL))
return nvme_subsystem_get_application(s);
}
}

return NULL;
}

int nvmf_add_ctrl(nvme_host_t h, nvme_ctrl_t c,
const struct nvme_fabrics_config *cfg)
{
Expand Down Expand Up @@ -862,24 +883,9 @@ int nvmf_add_ctrl(nvme_host_t h, nvme_ctrl_t c,
root_app = nvme_root_get_application(h->r);
if (root_app) {
app = nvme_subsystem_get_application(s);
if (!app && nvme_ctrl_is_discovery_ctrl(c)) {
nvme_subsystem_t s;
nvme_ctrl_t fc;

nvme_for_each_subsystem(h, s) {
fc = __nvme_lookup_ctrl(s, nvme_ctrl_get_transport(c),
nvme_ctrl_get_traddr(c),
NULL,
NULL,
nvme_ctrl_get_trsvcid(c),
NULL);

if (fc) {
app = nvme_subsystem_get_application(s);
break;
}
}
}
if (!app && nvme_ctrl_is_discovery_ctrl(c))
app = lookup_context(h->r, c);

/*
* configuration is managed by an application,
* refuse to act on subsystems which either have
Expand Down

0 comments on commit 1b042eb

Please sign in to comment.