Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH] btrfs-progs: device: print num_stripes in usage command
@ 2021-05-30 12:56 Sidong Yang
  2021-06-07 19:20 ` David Sterba
  0 siblings, 1 reply; 3+ messages in thread
From: Sidong Yang @ 2021-05-30 12:56 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Sidong Yang

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

/dev/vdb, ID: 1
   Device size:             1.00GiB
   Device slack:              0.00B
   Data,single[1]:        120.00MiB
   Metadata,DUP[2]:       102.38MiB
   System,DUP[2]:          16.00MiB
   Unallocated:           785.62MiB

Signed-off-by: Sidong Yang <realwakka@gmail.com>
---
 cmds/filesystem-usage.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/cmds/filesystem-usage.c b/cmds/filesystem-usage.c
index 107453d4..4d8c0c2d 100644
--- a/cmds/filesystem-usage.c
+++ b/cmds/filesystem-usage.c
@@ -1192,6 +1192,7 @@ void print_device_chunks(struct device_info *devinfo,
 		const char *r_mode;
 		u64 flags;
 		u64 size;
+		u64 num_stripes;
 
 		if (chunks_info_ptr[i].devid != devinfo->devid)
 			continue;
@@ -1201,10 +1202,13 @@ void print_device_chunks(struct device_info *devinfo,
 		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",
+		num_stripes = chunks_info_ptr[i].num_stripes;
+		printf("   %s,%s[%llu]:%*s%10s\n",
 			description,
 			r_mode,
-			(int)(20 - strlen(description) - strlen(r_mode)), "",
+			num_stripes,
+			(int)(20 - strlen(description) - strlen(r_mode)
+				  - count_digits(num_stripes) - 2), "",
 			pretty_size_mode(size, unit_mode));
 
 		allocated += size;
-- 
2.25.1


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

end of thread, other threads:[~2021-06-08 14:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-30 12:56 [PATCH] btrfs-progs: device: print num_stripes in usage command Sidong Yang
2021-06-07 19:20 ` David Sterba
2021-06-08 14:46   ` Sidong Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox