* [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
* Re: [PATCH] btrfs-progs: device: print num_stripes in usage command
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
0 siblings, 1 reply; 3+ messages in thread
From: David Sterba @ 2021-06-07 19:20 UTC (permalink / raw)
To: Sidong Yang; +Cc: linux-btrfs
On Sun, May 30, 2021 at 12:56:36PM +0000, Sidong Yang wrote:
> 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
This is example of single and dup, but the whole point was to print that
for the striped profiles, like is shown in the issue
https://github.com/kdave/btrfs-progs/issues/372 , so it needs to be
conditional.
As the mirrored profiles have a fixed number of copies, there's no doubt
on how many devices are printed, same for single and dup.
I'm more inclined to use the "/" as separator: 'RAID6/3' it's more like
"raid6 on three devices", the "[]" looks like indexing. "," is used as
separator of the type so it won't be as simple to parse that.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs-progs: device: print num_stripes in usage command
2021-06-07 19:20 ` David Sterba
@ 2021-06-08 14:46 ` Sidong Yang
0 siblings, 0 replies; 3+ messages in thread
From: Sidong Yang @ 2021-06-08 14:46 UTC (permalink / raw)
To: dsterba, linux-btrfs
On Mon, Jun 07, 2021 at 09:20:49PM +0200, David Sterba wrote:
> On Sun, May 30, 2021 at 12:56:36PM +0000, Sidong Yang wrote:
> > 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
>
Hi David. Thanks for review!
> This is example of single and dup, but the whole point was to print that
> for the striped profiles, like is shown in the issue
> https://github.com/kdave/btrfs-progs/issues/372 , so it needs to be
> conditional.
Okay, striped profiles need to be printed. I read some page from
wikipedia about raid. and I got that RAID 0,5,6,10 supports striping.
Those need to be printed and no printing for RAID 1, single, dup.
>
> As the mirrored profiles have a fixed number of copies, there's no doubt
> on how many devices are printed, same for single and dup.
>
> I'm more inclined to use the "/" as separator: 'RAID6/3' it's more like
> "raid6 on three devices", the "[]" looks like indexing. "," is used as
> separator of the type so it won't be as simple to parse that.
I agree. I'll use "/" for next version.
^ permalink raw reply [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;
as well as URLs for NNTP newsgroup(s).