@@ -272,6 +272,34 @@ static void splice_device_list(struct list_head *seed_devices,
272272 list_splice (seed_devices , all_devices );
273273}
274274
275+ static void print_filesystem_info (char * label , char uuidbuf [BTRFS_UUID_UNPARSED_SIZE ],
276+ u64 bytes_used , u64 num_devices ,
277+ unsigned unit_mode )
278+ {
279+ if (label )
280+ pr_verbose (LOG_DEFAULT , "Label: '%s' " , label );
281+ else
282+ pr_verbose (LOG_DEFAULT , "Label: none " );
283+
284+ pr_verbose (LOG_DEFAULT , " uuid: %s\n\tTotal devices %llu FS bytes used %s\n" , uuidbuf ,
285+ num_devices ,
286+ pretty_size_mode (bytes_used ,
287+ unit_mode ));
288+ }
289+
290+ static void print_filesystem_device (u64 devid , u64 total_bytes , u64 bytes_used ,
291+ char * path ,
292+ bool missing ,
293+ unsigned unit_mode )
294+ {
295+ pr_verbose (LOG_DEFAULT , "\tdevid %4llu size %s used %s path %s%s\n" ,
296+ devid ,
297+ pretty_size_mode (total_bytes , unit_mode ),
298+ pretty_size_mode (bytes_used , unit_mode ),
299+ path ,
300+ missing ? " MISSING" : "" );
301+ }
302+
275303static void print_devices (struct btrfs_fs_devices * fs_devices ,
276304 u64 * devs_found , unsigned unit_mode )
277305{
@@ -289,12 +317,11 @@ static void print_devices(struct btrfs_fs_devices *fs_devices,
289317
290318 list_sort (NULL , all_devices , cmp_device_id );
291319 list_for_each_entry (device , all_devices , dev_list ) {
292- pr_verbose (LOG_DEFAULT , "\tdevid %4llu size %s used %s path %s\n" ,
293- device -> devid ,
294- pretty_size_mode (device -> total_bytes , unit_mode ),
295- pretty_size_mode (device -> bytes_used , unit_mode ),
296- device -> name );
297-
320+ print_filesystem_device (device -> devid ,
321+ device -> total_bytes , device -> bytes_used ,
322+ device -> name ,
323+ false,
324+ unit_mode );
298325 (* devs_found )++ ;
299326 }
300327}
@@ -313,14 +340,11 @@ static void print_one_uuid(struct btrfs_fs_devices *fs_devices,
313340 uuid_unparse (fs_devices -> fsid , uuidbuf );
314341 device = list_entry (fs_devices -> devices .next , struct btrfs_device ,
315342 dev_list );
316- if (device -> label && device -> label [0 ])
317- pr_verbose (LOG_DEFAULT , "Label: '%s' " , device -> label );
318- else
319- pr_verbose (LOG_DEFAULT , "Label: none " );
320-
321343 total = device -> total_devs ;
322- pr_verbose (LOG_DEFAULT , " uuid: %s\n\tTotal devices %llu FS bytes used %s\n" , uuidbuf ,
323- total , pretty_size_mode (device -> super_bytes_used , unit_mode ));
344+
345+ print_filesystem_info (device -> label && device -> label [0 ] ? device -> label : NULL , uuidbuf ,
346+ device -> super_bytes_used , total ,
347+ unit_mode );
324348
325349 print_devices (fs_devices , & devs_found , unit_mode );
326350
@@ -359,15 +383,9 @@ static int print_one_fs(struct btrfs_ioctl_fs_info_args *fs_info,
359383 return ret ;
360384
361385 uuid_unparse (fs_info -> fsid , uuidbuf );
362- if (label && * label )
363- pr_verbose (LOG_DEFAULT , "Label: '%s' " , label );
364- else
365- pr_verbose (LOG_DEFAULT , "Label: none " );
366-
367- pr_verbose (LOG_DEFAULT , " uuid: %s\n\tTotal devices %llu FS bytes used %s\n" , uuidbuf ,
368- fs_info -> num_devices ,
369- pretty_size_mode (calc_used_bytes (space_info ),
370- unit_mode ));
386+ print_filesystem_info (label && * label ? label : NULL , uuidbuf ,
387+ calc_used_bytes (space_info ), fs_info -> num_devices ,
388+ unit_mode );
371389
372390 for (i = 0 ; i < fs_info -> num_devices ; i ++ ) {
373391 char * canonical_path ;
@@ -377,18 +395,20 @@ static int print_one_fs(struct btrfs_ioctl_fs_info_args *fs_info,
377395 /* Add check for missing devices even mounted */
378396 fd = open ((char * )tmp_dev_info -> path , O_RDONLY );
379397 if (fd < 0 ) {
380- pr_verbose (LOG_DEFAULT , "\tdevid %4llu size 0 used 0 path %s MISSING\n" ,
381- tmp_dev_info -> devid , tmp_dev_info -> path );
398+ print_filesystem_device (tmp_dev_info -> devid ,
399+ 0 , 0 ,
400+ (char * )tmp_dev_info -> path ,
401+ true,
402+ unit_mode );
382403 continue ;
383-
384404 }
385405 close (fd );
386406 canonical_path = path_canonicalize ((char * )tmp_dev_info -> path );
387- pr_verbose ( LOG_DEFAULT , "\tdevid %4llu size %s used %s path %s\n" ,
388- tmp_dev_info -> devid ,
389- pretty_size_mode ( tmp_dev_info -> total_bytes , unit_mode ) ,
390- pretty_size_mode ( tmp_dev_info -> bytes_used , unit_mode ) ,
391- canonical_path );
407+ print_filesystem_device ( tmp_dev_info -> devid ,
408+ tmp_dev_info -> total_bytes , tmp_dev_info -> bytes_used ,
409+ canonical_path ,
410+ false ,
411+ unit_mode );
392412
393413 free (canonical_path );
394414 }
0 commit comments