From: Hannes Reinecke Date: Thu, 12 Aug 2021 09:29:25 +0000 (+0200) Subject: fabrics: add nvme_host_t as argument to build_options() X-Git-Tag: v1.0-rc0~113^2~3 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=d23c2e027643c292a8794a470643ab1660e4b07d;p=users%2Fsagi%2Flibnvme.git fabrics: add nvme_host_t as argument to build_options() build_options() can be called when the controller hasn't been instantiated; in that case the 'subsystem' link in the controller is empty, and there is no host associated with it. Rather than selecting the default nvme host (and thereby losing any different hostnqn settings which might have passed in from the commandline) we should be passing in the nvme host directly as argument to build_options(). Signed-off-by: Hannes Reinecke --- diff --git a/src/nvme/fabrics.c b/src/nvme/fabrics.c index 16a99c2c..8295c45f 100644 --- a/src/nvme/fabrics.c +++ b/src/nvme/fabrics.c @@ -213,7 +213,7 @@ static int add_argument(char **argstr, const char *tok, const char *arg) return 0; } -static int build_options(nvme_ctrl_t c, char **argstr) +static int build_options(nvme_host_t h, nvme_ctrl_t c, char **argstr) { struct nvme_fabrics_config *cfg = nvme_ctrl_get_config(c); const char *transport = nvme_ctrl_get_transport(c); @@ -245,8 +245,8 @@ static int build_options(nvme_ctrl_t c, char **argstr) } if (!strcmp(nvme_ctrl_get_subsysnqn(c), NVME_DISC_SUBSYS_NAME)) discover = true; - hostnqn = nvme_ctrl_get_hostnqn(c); - hostid = nvme_ctrl_get_hostid(c); + hostnqn = nvme_host_get_hostnqn(h); + hostid = nvme_host_get_hostid(h); if (add_argument(argstr, "transport", transport) || add_argument(argstr, "traddr", nvme_ctrl_get_traddr(c)) || @@ -347,12 +347,14 @@ out_close: int nvmf_add_ctrl_opts(nvme_ctrl_t c, struct nvme_fabrics_config *cfg) { + nvme_subsystem_t s = nvme_ctrl_get_subsystem(c); + nvme_host_t h = nvme_subsystem_get_host(s); char *argstr; int ret; cfg = merge_config(c, cfg); - ret = build_options(c, &argstr); + ret = build_options(h, c, &argstr); if (ret) return ret; @@ -374,7 +376,7 @@ int nvmf_add_ctrl(nvme_host_t h, nvme_ctrl_t c, nvme_ctrl_disable_sqflow(c, disable_sqflow); nvme_ctrl_set_discovered(c, true); - ret = build_options(c, &argstr); + ret = build_options(h, c, &argstr); if (ret) return ret;