mirror of
https://github.com/kdave/btrfs-progs
synced 2024-12-29 01:22:13 +00:00
btrfs-progs: device usage: print number of stripes in relevant profiles
Print number of stripes for striped 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 Data,RAID0/3: 912.62MiB Metadata,RAID1: 102.38MiB System,RAID1: 8.00MiB Unallocated: 1.00MiB Multiple lines can appear in case a balance conversion process was interrupted or if there's been a new device added and new data written to the full stripe. Issue: #372 Signed-off-by: Sidong Yang <realwakka@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
c3acaee63a
commit
4693e82261
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user