1
0
Fork 0

Merging upstream version 2.13.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-04-13 11:50:38 +02:00
parent adb2e5e05d
commit 8599c7290c
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
579 changed files with 6165 additions and 1687 deletions

View file

@ -156,6 +156,31 @@ static void netapp_get_ns_attrs(char *size, char *used, char *blk_size,
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;
@ -272,8 +297,8 @@ static void netapp_smdevice_json(struct json_object *devices, char *devname,
}
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;
@ -283,6 +308,7 @@ static void netapp_ontapdevice_json(struct json_object *devices, char *devname,
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);
@ -519,23 +545,25 @@ static void netapp_ontapdevices_print_verbose(struct ontapdevice_info *devices,
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";
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",
"----------------", "-------------------------",
"-------------------------",
"--------------------------------------------------",
"----", "--------------------------------------",
"---------", "---------", "---------", "---------");
@ -547,13 +575,15 @@ static void netapp_ontapdevices_print_verbose(struct ontapdevice_info *devices,
/* 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;
}
}
@ -562,12 +592,14 @@ static void netapp_ontapdevices_print_verbose(struct ontapdevice_info *devices,
/* 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);
}
}
@ -579,21 +611,23 @@ static void netapp_ontapdevices_print_regular(struct ontapdevice_info *devices,
unsigned long long lba;
char size[128];
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, %s\n";
char columnstr[] = "%-16s %-25s %-50s %-4d %-38s %-9s\n";
"%s, Vserver %s, Subsystem %s, Namespace Path %s, NSID %d, UUID %s, %s\n";
char columnstr[] = "%-16s %-25s %-25s %-50s %-4d %-38s %-9s\n";
if (format == NNORMAL)
formatstr = basestr;
else if (format == NCOLUMN) {
printf("%-16s %-25s %-50s %-4s %-38s %-9s\n",
"Device", "Vserver", "Namespace Path",
printf("%-16s %-25s %-25s %-50s %-4s %-38s %-9s\n",
"Device", "Vserver", "Subsystem", "Namespace Path",
"NSID", "UUID", "Size");
printf("%-16s %-25s %-50s %-4s %-38s %-9s\n",
printf("%-16s %-25s %-25s %-50s %-4s %-38s %-9s\n",
"----------------", "-------------------------",
"-------------------------",
"--------------------------------------------------",
"----", "--------------------------------------",
"---------");
@ -607,9 +641,11 @@ static void netapp_ontapdevices_print_regular(struct ontapdevice_info *devices,
nvme_uuid_to_string(devices[i].uuid, uuid_str);
netapp_get_ontap_labels(vsname, nspath,
devices[i].log_data);
ontap_get_subsysname(subnqn, subsysname,
&devices[i].ctrl);
printf(formatstr, devices[i].dev, vsname, nspath,
devices[i].nsid, uuid_str, size);
printf(formatstr, devices[i].dev, vsname, subsysname,
nspath, devices[i].nsid, uuid_str, size);
return;
}
}
@ -619,9 +655,10 @@ static void netapp_ontapdevices_print_regular(struct ontapdevice_info *devices,
netapp_get_ns_size(size, &lba, &devices[i].ns);
nvme_uuid_to_string(devices[i].uuid, uuid_str);
netapp_get_ontap_labels(vsname, nspath, devices[i].log_data);
ontap_get_subsysname(subnqn, subsysname, &devices[i].ctrl);
printf(formatstr, devices[i].dev, vsname, nspath,
devices[i].nsid, uuid_str, size);
printf(formatstr, devices[i].dev, vsname, subsysname,
nspath, devices[i].nsid, uuid_str, size);
}
}
@ -636,6 +673,7 @@ static void netapp_ontapdevices_print_json(struct ontapdevice_info *devices,
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 */
@ -647,13 +685,15 @@ static void netapp_ontapdevices_print_json(struct ontapdevice_info *devices,
/* 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;
@ -664,12 +704,14 @@ static void netapp_ontapdevices_print_json(struct ontapdevice_info *devices,
/* 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));
}