@@ -156,6 +156,31 @@ static void netapp_get_ns_attrs(char *size, char *used, char *blk_size,
156156 version [i ] = '\0' ;
157157}
158158
159+ static void ontap_get_subsysname (char * subnqn , char * subsysname ,
160+ struct nvme_id_ctrl * ctrl )
161+ {
162+ char * subname ;
163+ int i , len = sizeof (ctrl -> subnqn );
164+
165+ /* get the target NQN */
166+ memcpy (subnqn , ctrl -> subnqn , len );
167+ subnqn [len ] = '\0' ;
168+
169+ /* strip trailing whitespaces */
170+ for (i = len - 1 ; i >= 0 && subnqn [i ] == ' ' ; i -- )
171+ subnqn [i ] = '\0' ;
172+
173+ /* get the subsysname from the target NQN */
174+ subname = strrchr (subnqn , '.' );
175+ if (subname ) {
176+ subname ++ ;
177+ len = strlen (subname );
178+ memcpy (subsysname , subname , len );
179+ subsysname [len ] = '\0' ;
180+ } else
181+ fprintf (stderr , "Unable to fetch ONTAP subsystem name\n" );
182+ }
183+
159184static void ontap_labels_to_str (char * dst , char * src , int count )
160185{
161186 int i ;
@@ -272,8 +297,8 @@ static void netapp_smdevice_json(struct json_object *devices, char *devname,
272297}
273298
274299static void netapp_ontapdevice_json (struct json_object * devices , char * devname ,
275- char * vsname , char * nspath , int nsid , char * uuid ,
276- unsigned long long lba , char * version ,
300+ char * vsname , char * subsysname , char * nspath , int nsid ,
301+ char * uuid , unsigned long long lba , char * version ,
277302 unsigned long long nsze , unsigned long long nuse )
278303{
279304 struct json_object * device_attrs ;
@@ -283,6 +308,7 @@ static void netapp_ontapdevice_json(struct json_object *devices, char *devname,
283308 device_attrs = json_create_object ();
284309 json_object_add_value_string (device_attrs , "Device" , devname );
285310 json_object_add_value_string (device_attrs , "Vserver" , vsname );
311+ json_object_add_value_string (device_attrs , "Subsystem" , subsysname );
286312 json_object_add_value_string (device_attrs , "Namespace_Path" , nspath );
287313 json_object_add_value_int (device_attrs , "NSID" , nsid );
288314 json_object_add_value_string (device_attrs , "UUID" , uuid );
@@ -519,23 +545,25 @@ static void netapp_ontapdevices_print_verbose(struct ontapdevice_info *devices,
519545 char size [128 ], used [128 ];
520546 char blk_size [128 ], version [9 ];
521547 char uuid_str [37 ] = " " ;
548+ char subnqn [257 ], subsysname [65 ];
522549 int i ;
523550
524551 char * formatstr = NULL ;
525552 char basestr [] =
526- "%s, Vserver %s, Namespace Path %s, NSID %d, UUID %s , "
527- "Size %s, Used %s, Format %s, Version %s\n" ;
528- char columnstr [] = "%-16s %-25s %-50s %-4d %-38s %-9s %-9s %-9s %-9s\n" ;
553+ "%s, Vserver %s, Subsystem %s, Namespace Path %s, NSID %d, "
554+ "UUID %s, Size %s, Used %s, Format %s, Version %s\n" ;
555+ char columnstr [] = "%-16s %-25s %-25s %- 50s %-4d %-38s %-9s %-9s %-9s %-9s\n" ;
529556
530557 if (format == NNORMAL )
531558 formatstr = basestr ;
532559 else if (format == NCOLUMN ) {
533- printf ("%-16s %-25s %-50s %-4s %-38s %-9s %-9s %-9s %-9s\n" ,
534- "Device" , "Vserver" , "Namespace Path" ,
560+ printf ("%-16s %-25s %-25s %- 50s %-4s %-38s %-9s %-9s %-9s %-9s\n" ,
561+ "Device" , "Vserver" , "Subsystem" , " Namespace Path" ,
535562 "NSID" , "UUID" , "Size" , "Used" ,
536563 "Format" , "Version" );
537- printf ("%-16s %-25s %-50s %-4s %-38s %-9s %-9s %-9s %-9s\n" ,
564+ printf ("%-16s %-25s %-25s %- 50s %-4s %-38s %-9s %-9s %-9s %-9s\n" ,
538565 "----------------" , "-------------------------" ,
566+ "-------------------------" ,
539567 "--------------------------------------------------" ,
540568 "----" , "--------------------------------------" ,
541569 "---------" , "---------" , "---------" , "---------" );
@@ -547,13 +575,15 @@ static void netapp_ontapdevices_print_verbose(struct ontapdevice_info *devices,
547575 /* found the device, fetch and print for that alone */
548576 netapp_get_ns_attrs (size , used , blk_size , version ,
549577 & lba , & devices [i ].ctrl , & devices [i ].ns );
578+ ontap_get_subsysname (subnqn , subsysname ,
579+ & devices [i ].ctrl );
550580 nvme_uuid_to_string (devices [i ].uuid , uuid_str );
551581 netapp_get_ontap_labels (vsname , nspath ,
552582 devices [i ].log_data );
553583
554- printf (formatstr , devices [i ].dev , vsname , nspath ,
555- devices [i ].nsid , uuid_str , size , used ,
556- blk_size , version );
584+ printf (formatstr , devices [i ].dev , vsname , subsysname ,
585+ nspath , devices [i ].nsid , uuid_str ,
586+ size , used , blk_size , version );
557587 return ;
558588 }
559589 }
@@ -562,12 +592,14 @@ static void netapp_ontapdevices_print_verbose(struct ontapdevice_info *devices,
562592 /* fetch info and print for all devices */
563593 netapp_get_ns_attrs (size , used , blk_size , version ,
564594 & lba , & devices [i ].ctrl , & devices [i ].ns );
595+ ontap_get_subsysname (subnqn , subsysname ,
596+ & devices [i ].ctrl );
565597 nvme_uuid_to_string (devices [i ].uuid , uuid_str );
566598 netapp_get_ontap_labels (vsname , nspath , devices [i ].log_data );
567599
568- printf (formatstr , devices [i ].dev , vsname , nspath ,
569- devices [i ].nsid , uuid_str , size , used ,
570- blk_size , version );
600+ printf (formatstr , devices [i ].dev , vsname , subsysname ,
601+ nspath , devices [i ].nsid , uuid_str ,
602+ size , used , blk_size , version );
571603 }
572604}
573605
@@ -636,6 +668,7 @@ static void netapp_ontapdevices_print_json(struct ontapdevice_info *devices,
636668 char size [128 ], used [128 ];
637669 char blk_size [128 ], version [9 ];
638670 char uuid_str [37 ] = " " ;
671+ char subnqn [257 ], subsysname [65 ];
639672 int i ;
640673
641674 /* prepare for the json output */
@@ -647,13 +680,15 @@ static void netapp_ontapdevices_print_json(struct ontapdevice_info *devices,
647680 /* found the device, fetch info for that alone */
648681 netapp_get_ns_attrs (size , used , blk_size , version ,
649682 & lba , & devices [i ].ctrl , & devices [i ].ns );
683+ ontap_get_subsysname (subnqn , subsysname ,
684+ & devices [i ].ctrl );
650685 nvme_uuid_to_string (devices [i ].uuid , uuid_str );
651686 netapp_get_ontap_labels (vsname , nspath ,
652687 devices [i ].log_data );
653688
654689 netapp_ontapdevice_json (json_devices , devices [i ].dev ,
655- vsname , nspath , devices [ i ]. nsid ,
656- uuid_str , lba , version ,
690+ vsname , subsysname , nspath ,
691+ devices [ i ]. nsid , uuid_str , lba , version ,
657692 le64_to_cpu (devices [i ].ns .nsze ),
658693 le64_to_cpu (devices [i ].ns .nuse ));
659694 goto out ;
@@ -664,12 +699,14 @@ static void netapp_ontapdevices_print_json(struct ontapdevice_info *devices,
664699 /* fetch info for all devices */
665700 netapp_get_ns_attrs (size , used , blk_size , version ,
666701 & lba , & devices [i ].ctrl , & devices [i ].ns );
702+ ontap_get_subsysname (subnqn , subsysname ,
703+ & devices [i ].ctrl );
667704 nvme_uuid_to_string (devices [i ].uuid , uuid_str );
668705 netapp_get_ontap_labels (vsname , nspath , devices [i ].log_data );
669706
670707 netapp_ontapdevice_json (json_devices , devices [i ].dev ,
671- vsname , nspath , devices [ i ]. nsid ,
672- uuid_str , lba , version ,
708+ vsname , subsysname , nspath ,
709+ devices [ i ]. nsid , uuid_str , lba , version ,
673710 le64_to_cpu (devices [i ].ns .nsze ),
674711 le64_to_cpu (devices [i ].ns .nuse ));
675712 }
0 commit comments