Skip to content
Merged
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
73 changes: 55 additions & 18 deletions plugins/netapp/netapp-nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,31 @@
version[i] = '\0';
}

static void ontap_get_subsysname(char *subnqn, char *subsysname,
struct nvme_id_ctrl *ctrl)
{
char *subname;
int i, len = sizeof(ctrl->subnqn);

/* get the target NQN */
memcpy(subnqn, ctrl->subnqn, len);
subnqn[len] = '\0';

/* strip trailing whitespaces */
for (i = len - 1; i >= 0 && subnqn[i] == ' '; i--)
subnqn[i] = '\0';

/* get the subsysname from the target NQN */
subname = strrchr(subnqn, '.');
if (subname) {
subname++;
len = strlen(subname);
memcpy(subsysname, subname, len);
subsysname[len] = '\0';
} else
fprintf(stderr, "Unable to fetch ONTAP subsystem name\n");
}

static void ontap_labels_to_str(char *dst, char *src, int count)
{
int i;
Expand Down Expand Up @@ -272,8 +297,8 @@
}

static void netapp_ontapdevice_json(struct json_object *devices, char *devname,
char *vsname, char *nspath, int nsid, char *uuid,
unsigned long long lba, char *version,
char *vsname, char *subsysname, char *nspath, int nsid,
char *uuid, unsigned long long lba, char *version,
unsigned long long nsze, unsigned long long nuse)
{
struct json_object *device_attrs;
Expand All @@ -283,6 +308,7 @@
device_attrs = json_create_object();
json_object_add_value_string(device_attrs, "Device", devname);
json_object_add_value_string(device_attrs, "Vserver", vsname);
json_object_add_value_string(device_attrs, "Subsystem", subsysname);
json_object_add_value_string(device_attrs, "Namespace_Path", nspath);
json_object_add_value_int(device_attrs, "NSID", nsid);
json_object_add_value_string(device_attrs, "UUID", uuid);
Expand Down Expand Up @@ -519,23 +545,25 @@
char size[128], used[128];
char blk_size[128], version[9];
char uuid_str[37] = " ";
char subnqn[257], subsysname[65];
int i;

char *formatstr = NULL;
char basestr[] =
"%s, Vserver %s, Namespace Path %s, NSID %d, UUID %s, "
"Size %s, Used %s, Format %s, Version %s\n";
char columnstr[] = "%-16s %-25s %-50s %-4d %-38s %-9s %-9s %-9s %-9s\n";
"%s, Vserver %s, Subsystem %s, Namespace Path %s, NSID %d, "
"UUID %s, Size %s, Used %s, Format %s, Version %s\n";

Check failure on line 554 in plugins/netapp/netapp-nvme.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: quoted string split across lines
char columnstr[] = "%-16s %-25s %-25s %-50s %-4d %-38s %-9s %-9s %-9s %-9s\n";

if (format == NNORMAL)
formatstr = basestr;
else if (format == NCOLUMN) {
printf("%-16s %-25s %-50s %-4s %-38s %-9s %-9s %-9s %-9s\n",
"Device", "Vserver", "Namespace Path",
printf("%-16s %-25s %-25s %-50s %-4s %-38s %-9s %-9s %-9s %-9s\n",
"Device", "Vserver", "Subsystem", "Namespace Path",
"NSID", "UUID", "Size", "Used",
"Format", "Version");
printf("%-16s %-25s %-50s %-4s %-38s %-9s %-9s %-9s %-9s\n",
printf("%-16s %-25s %-25s %-50s %-4s %-38s %-9s %-9s %-9s %-9s\n",
"----------------", "-------------------------",
"-------------------------",
"--------------------------------------------------",
"----", "--------------------------------------",
"---------", "---------", "---------", "---------");
Expand All @@ -547,13 +575,15 @@
/* found the device, fetch and print for that alone */
netapp_get_ns_attrs(size, used, blk_size, version,
&lba, &devices[i].ctrl, &devices[i].ns);
ontap_get_subsysname(subnqn, subsysname,
&devices[i].ctrl);
nvme_uuid_to_string(devices[i].uuid, uuid_str);
netapp_get_ontap_labels(vsname, nspath,
devices[i].log_data);

printf(formatstr, devices[i].dev, vsname, nspath,
devices[i].nsid, uuid_str, size, used,
blk_size, version);
printf(formatstr, devices[i].dev, vsname, subsysname,
nspath, devices[i].nsid, uuid_str,
size, used, blk_size, version);
return;
}
}
Expand All @@ -562,12 +592,14 @@
/* fetch info and print for all devices */
netapp_get_ns_attrs(size, used, blk_size, version,
&lba, &devices[i].ctrl, &devices[i].ns);
ontap_get_subsysname(subnqn, subsysname,
&devices[i].ctrl);
nvme_uuid_to_string(devices[i].uuid, uuid_str);
netapp_get_ontap_labels(vsname, nspath, devices[i].log_data);

printf(formatstr, devices[i].dev, vsname, nspath,
devices[i].nsid, uuid_str, size, used,
blk_size, version);
printf(formatstr, devices[i].dev, vsname, subsysname,
nspath, devices[i].nsid, uuid_str,
size, used, blk_size, version);
}
}

Expand Down Expand Up @@ -636,6 +668,7 @@
char size[128], used[128];
char blk_size[128], version[9];
char uuid_str[37] = " ";
char subnqn[257], subsysname[65];
int i;

/* prepare for the json output */
Expand All @@ -647,13 +680,15 @@
/* found the device, fetch info for that alone */
netapp_get_ns_attrs(size, used, blk_size, version,
&lba, &devices[i].ctrl, &devices[i].ns);
ontap_get_subsysname(subnqn, subsysname,
&devices[i].ctrl);
nvme_uuid_to_string(devices[i].uuid, uuid_str);
netapp_get_ontap_labels(vsname, nspath,
devices[i].log_data);

netapp_ontapdevice_json(json_devices, devices[i].dev,
vsname, nspath, devices[i].nsid,
uuid_str, lba, version,
vsname, subsysname, nspath,
devices[i].nsid, uuid_str, lba, version,
le64_to_cpu(devices[i].ns.nsze),
le64_to_cpu(devices[i].ns.nuse));
goto out;
Expand All @@ -664,12 +699,14 @@
/* fetch info for all devices */
netapp_get_ns_attrs(size, used, blk_size, version,
&lba, &devices[i].ctrl, &devices[i].ns);
ontap_get_subsysname(subnqn, subsysname,
&devices[i].ctrl);
nvme_uuid_to_string(devices[i].uuid, uuid_str);
netapp_get_ontap_labels(vsname, nspath, devices[i].log_data);

netapp_ontapdevice_json(json_devices, devices[i].dev,
vsname, nspath, devices[i].nsid,
uuid_str, lba, version,
vsname, subsysname, nspath,
devices[i].nsid, uuid_str, lba, version,
le64_to_cpu(devices[i].ns.nsze),
le64_to_cpu(devices[i].ns.nuse));
}
Expand Down