It is possible that the user will create a persistent discovery controller
with a specific host identifiers (hostnqn and/or hostid). If we get a discovery
change log event on this discovery controller we need to use the same host
identifiers that otherwise we will may not see what the discovery change log
event intended us to see (as we connect with a different hostnqn for example).
Note that we take these identifiers only if they exist in sysfs which gives us
backward compatibility (as hostnqn and hostid are still new).
Reported-by: Yogev Cohen <yogev@lightbitslabs.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Keith Busch <kbusch@kernel.org>
return ret;
}
+static void nvmf_get_host_identifiers(int ctrl_instance)
+{
+ char *path;
+
+ if (asprintf(&path, "%s/nvme%d", SYS_NVME, ctrl_instance) < 0)
+ return;
+ cfg.hostnqn = nvme_get_ctrl_attr(path, "hostnqn");
+ cfg.hostid = nvme_get_ctrl_attr(path, "hostid");
+}
+
static int do_discover(char *argstr, bool connect)
{
struct nvmf_disc_rsp_page_hdr *log = NULL;
free(cargs.host_traddr);
}
- if (!cfg.device)
+ if (!cfg.device) {
instance = add_ctrl(argstr);
- else
+ } else {
instance = ctrl_instance(cfg.device);
+ nvmf_get_host_identifiers(instance);
+ }
if (instance < 0)
return instance;