Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions nvme-print-json.c
Original file line number Diff line number Diff line change
Expand Up @@ -2558,6 +2558,14 @@ static void json_print_nvme_subsystem_list(nvme_root_t r, bool show_ana)
obj_add_str(host_attrs, "HostID", hostid);
subsystems = json_create_array();
nvme_for_each_subsystem(h, s) {
nvme_ctrl_t c;
bool no_ctrl = true;

nvme_subsystem_for_each_ctrl(s, c)
no_ctrl = false;
if (no_ctrl)
continue;

subsystem_attrs = json_create_object();
obj_add_str(subsystem_attrs, "Name", nvme_subsystem_get_name(s));
obj_add_str(subsystem_attrs, "NQN", nvme_subsystem_get_nqn(s));
Expand Down
8 changes: 8 additions & 0 deletions nvme-print-stdout.c
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,14 @@ static void stdout_subsystem(nvme_root_t r, bool show_ana)
nvme_subsystem_t s;

nvme_for_each_subsystem(h, s) {
bool no_ctrl = true;
nvme_ctrl_t c;

nvme_subsystem_for_each_ctrl(s, c)
no_ctrl = false;
if (no_ctrl)
continue;

if (!first)
printf("\n");
first = false;
Expand Down
31 changes: 11 additions & 20 deletions nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -3388,33 +3388,24 @@ static int create_ns(int argc, char **argv, struct command *cmd, struct plugin *
static bool nvme_match_device_filter(nvme_subsystem_t s,
nvme_ctrl_t c, nvme_ns_t ns, void *f_args)
{
int ret, instance, nsid, s_num;
char *devname = f_args;
nvme_ns_t n;

if (!devname || !strlen(devname))
if (ns && !strcmp(devname, nvme_ns_get_name(ns)))
return true;

ret = sscanf(devname, "nvme%dn%d", &instance, &nsid);
if (ret != 2)
return true;

if (s) {
ret = sscanf(nvme_subsystem_get_name(s), "nvme-subsys%d",
&s_num);
if (ret == 1 && s_num == instance)
return true;
}
if (c) {
s = nvme_ctrl_get_subsystem(c);

ret = sscanf(nvme_subsystem_get_name(s), "nvme-subsys%d",
&s_num);
if (ret == 1 && s_num == instance)
return true;
nvme_ctrl_for_each_ns(c, n) {
if (!strcmp(devname, nvme_ns_get_name(n)))
return true;
}
}
if (ns) {
if (!strcmp(devname, nvme_ns_get_name(ns)))
return true;
if (s) {
nvme_subsystem_for_each_ns(s, n) {
if (!strcmp(devname, nvme_ns_get_name(n)))
return true;
}
}

return false;
Expand Down