All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] btrfs-progs: device: print num_stripes in usage command
@ 2021-06-08 15:35 Sidong Yang
  2021-06-17 20:23 ` David Sterba
  0 siblings, 1 reply; 2+ messages in thread
From: Sidong Yang @ 2021-06-08 15:35 UTC (permalink / raw)
  To: dsterba, linux-btrfs; +Cc: Sidong Yang

This patch prints num_stripes for striping profiles in device usage commands.
It helps to see profiles easily. The output is like below.

/dev/vdc, ID: 1
   Device size:             1.00GiB
   Device slack:              0.00B
   Data,RAID0/2:          912.62MiB
   Metadata,RAID1:        102.38MiB
   System,RAID1:            8.00MiB
   Unallocated:             1.00MiB

Signed-off-by: Sidong Yang <realwakka@gmail.com>
---
v2:
 - print stripes if striping raid
 - use separator "/"
---
 cmds/filesystem-usage.c | 31 ++++++++++++++++++++++++++-----
 1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/cmds/filesystem-usage.c b/cmds/filesystem-usage.c
index 107453d4..b92a4860 100644
--- a/cmds/filesystem-usage.c
+++ b/cmds/filesystem-usage.c
@@ -1192,20 +1192,41 @@ void print_device_chunks(struct device_info *devinfo,
 		const char *r_mode;
 		u64 flags;
 		u64 size;
+		u64 num_stripes;
+		u64 profile;
 
 		if (chunks_info_ptr[i].devid != devinfo->devid)
 			continue;
 
 		flags = chunks_info_ptr[i].type;
+		profile = flags & BTRFS_BLOCK_GROUP_PROFILE_MASK;
 
 		description = btrfs_group_type_str(flags);
 		r_mode = btrfs_group_profile_str(flags);
 		size = calc_chunk_size(chunks_info_ptr+i);
-		printf("   %s,%s:%*s%10s\n",
-			description,
-			r_mode,
-			(int)(20 - strlen(description) - strlen(r_mode)), "",
-			pretty_size_mode(size, unit_mode));
+		num_stripes = chunks_info_ptr[i].num_stripes;
+
+		switch (profile) {
+		case BTRFS_BLOCK_GROUP_RAID0:
+		case BTRFS_BLOCK_GROUP_RAID5:
+		case BTRFS_BLOCK_GROUP_RAID6:
+		case BTRFS_BLOCK_GROUP_RAID10:			
+			printf("   %s,%s/%llu:%*s%10s\n",
+				   description,
+				   r_mode,
+				   num_stripes,
+				   (int)(20 - strlen(description) - strlen(r_mode)
+						 - count_digits(num_stripes) - 1), "",
+				   pretty_size_mode(size, unit_mode));
+			break;
+		default:
+			printf("   %s,%s:%*s%10s\n",
+				   description,
+				   r_mode,
+				   (int)(20 - strlen(description) - strlen(r_mode)), "",
+				   pretty_size_mode(size, unit_mode));
+			break;
+		}
 
 		allocated += size;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] btrfs-progs: device: print num_stripes in usage command
  2021-06-08 15:35 [PATCH v2] btrfs-progs: device: print num_stripes in usage command Sidong Yang
@ 2021-06-17 20:23 ` David Sterba
  0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2021-06-17 20:23 UTC (permalink / raw)
  To: Sidong Yang; +Cc: dsterba, linux-btrfs

On Tue, Jun 08, 2021 at 03:35:20PM +0000, Sidong Yang wrote:
> This patch prints num_stripes for striping profiles in device usage commands.
> It helps to see profiles easily. The output is like below.
> 
> /dev/vdc, ID: 1
>    Device size:             1.00GiB
>    Device slack:              0.00B
>    Data,RAID0/2:          912.62MiB
>    Metadata,RAID1:        102.38MiB
>    System,RAID1:            8.00MiB
>    Unallocated:             1.00MiB
> 
> Signed-off-by: Sidong Yang <realwakka@gmail.com>

Added to devel with minor fixups, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-17 20:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-08 15:35 [PATCH v2] btrfs-progs: device: print num_stripes in usage command Sidong Yang
2021-06-17 20:23 ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.