Skip to content

Commit 4ec74f0

Browse files
sagigrimbergkeithbusch
authored andcommitted
nvmf: use discovery controller host identifiers for persistent controllers
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 <[email protected]> Signed-off-by: Sagi Grimberg <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 4527e14 commit 4ec74f0

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

fabrics.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,16 @@ static int connect_ctrls(struct nvmf_disc_rsp_page_hdr *log, int numrec)
10791079
return ret;
10801080
}
10811081

1082+
static void nvmf_get_host_identifiers(int ctrl_instance)
1083+
{
1084+
char *path;
1085+
1086+
if (asprintf(&path, "%s/nvme%d", SYS_NVME, ctrl_instance) < 0)
1087+
return;
1088+
cfg.hostnqn = nvme_get_ctrl_attr(path, "hostnqn");
1089+
cfg.hostid = nvme_get_ctrl_attr(path, "hostid");
1090+
}
1091+
10821092
static int do_discover(char *argstr, bool connect)
10831093
{
10841094
struct nvmf_disc_rsp_page_hdr *log = NULL;
@@ -1117,10 +1127,12 @@ static int do_discover(char *argstr, bool connect)
11171127
free(cargs.host_traddr);
11181128
}
11191129

1120-
if (!cfg.device)
1130+
if (!cfg.device) {
11211131
instance = add_ctrl(argstr);
1122-
else
1132+
} else {
11231133
instance = ctrl_instance(cfg.device);
1134+
nvmf_get_host_identifiers(instance);
1135+
}
11241136
if (instance < 0)
11251137
return instance;
11261138

0 commit comments

Comments
 (0)