nvme-print: list also hostnqn and hostid for verbose
Sagi Grimberg
maintainerPATCH 1/2 nvme-print: list also hostnqn and hostid for verbose
Add it to the json output as the normal display is crowded enough as it is. Note that we print them only if they exist in sysfs which gives us backward compatibility (as hostnqn and hostid are still new).
--- nvme-print.c | 4 ++++ nvme-topology.c | 4 ++++ nvme.h | 2 ++ 3 files changed, 10 insertions(+)
nvme-print.c +4 -0
@@ -4497,6 +4497,10 @@ static void json_detail_list(struct nvme_topology *t)json_object_add_value_string (ctrl_attrs,"Transport" , c->transport);json_object_add_value_string (ctrl_attrs,"Address" , c->address);json_object_add_value_string (ctrl_attrs,"State" , c->state); +if (c->hostnqn) +json_object_add_value_string (ctrl_attrs,"HostNQN" , c->hostnqn); +if (c->hostid) +json_object_add_value_string (ctrl_attrs,"HostID" , c->hostid);format (formatter,sizeof (formatter), c->id.fr,sizeof (c->id.fr));json_object_add_value_string (ctrl_attrs,"Firmware" , formatter);
nvme-topology.c +4 -0
@@ -195,6 +195,8 @@ static int scan_ctrl(struct nvme_ctrl *c, char *p, __u32 ns_instance) c->address =nvme_get_ctrl_attr (path,"address" ); c->transport =nvme_get_ctrl_attr (path,"transport" ); c->state =nvme_get_ctrl_attr (path,"state" ); + c->hostnqn =nvme_get_ctrl_attr (path,"hostnqn" ); + c->hostid =nvme_get_ctrl_attr (path,"hostid" );if (ns_instance) c->ana_state =get_nvme_ctrl_path_ana_state (path, ns_instance);
@@ -406,6 +408,8 @@ static void free_ctrl(struct nvme_ctrl *c)free (c->transport);free (c->address);free (c->state); +free (c->hostnqn); +free (c->hostid);free (c->ana_state);free (c->namespaces); }
nvme.h +2 -0
@@ -55,6 +55,8 @@ struct nvme_ctrl {char *traddr;char *trsvcid;char *host_traddr; +char *hostnqn; +char *hostid;struct nvme_id_ctrl id;
Signature · 7 lines
2.20.1 _______________________________________________ linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Sagi Grimberg
maintainerPATCH 2/2 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).
--- fabrics.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
fabrics.c +14 -2
@@ -1079,6 +1079,16 @@ static int connect_ctrls(struct nvmf_disc_rsp_page_hdr *log, int numrec)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 ;
@@ -1117,10 +1127,12 @@ static int do_discover(char *argstr, bool connect)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;
Signature · 7 lines
2.20.1 _______________________________________________ linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Keith Busch
maintainerThanks for the patches, applied both to nvme-cli
_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme