mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git
synced 2024-12-02 16:44:16 +08:00
btrfs-progs: fi usage: print zone unusable in the overview
Print the total zone_unusable size in the summary for 'fi usage' for a filesystem in zoned mode. It's a sum of all the zone_unusable values from 'fi df'. Per-device stats are not implemented and would need more complicated calculations from raw data, kernel does not export that (but it could). As of 5.12, the zone_unusable is stored only in memory so we'd have to map raw block device zones to the block groups and the live extents in the associated block groups to get the exact numbers. Example: # btrfs fi usage /mnt Overall: Device size: 2.00GiB Device allocated: 768.00MiB Device unallocated: 1.25GiB Device missing: 0.00B Device zone unusable: 320.00KiB Used: 128.00KiB Free (estimated): 1.50GiB (min: 1.50GiB) Free (statfs, df): 1.50GiB Data ratio: 1.00 Metadata ratio: 1.00 Global reserve: 3.25MiB (used: 32.00KiB) Multiple profiles: no Data,single: Size:256.00MiB, Used:0.00B (0.00%) /dev/nullb0 256.00MiB Metadata,single: Size:256.00MiB, Used:112.00KiB (0.04%) /dev/nullb0 256.00MiB System,single: Size:256.00MiB, Used:16.00KiB (0.01%) /dev/nullb0 256.00MiB Unallocated: /dev/nullb0 1.25GiB # btrfs fi df Data, single: total=256.00MiB, used=0.00B, zone_unusable=0.00B System, single: total=256.00MiB, used=16.00KiB, zone_unusable=160.00KiB Metadata, single: total=256.00MiB, used=112.00KiB, zone_unusable=160.00KiB GlobalReserve, single: total=3.25MiB, used=32.00KiB Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
a2495d1e6e
commit
780355d225
@ -431,9 +431,11 @@ static int print_filesystem_usage_overall(int fd, struct chunk_info *chunkinfo,
|
||||
u64 l_global_reserve_used = 0;
|
||||
u64 free_estimated = 0;
|
||||
u64 free_min = 0;
|
||||
u64 zone_unusable = 0;
|
||||
double max_data_ratio = 1.0;
|
||||
int mixed = 0;
|
||||
struct statfs statfs_buf;
|
||||
struct btrfs_ioctl_feature_flags feature_flags;
|
||||
|
||||
sargs = load_space_info(fd, path);
|
||||
if (!sargs) {
|
||||
@ -498,6 +500,16 @@ static int print_filesystem_usage_overall(int fd, struct chunk_info *chunkinfo,
|
||||
if ((flags & (BTRFS_BLOCK_GROUP_DATA | BTRFS_BLOCK_GROUP_METADATA))
|
||||
== (BTRFS_BLOCK_GROUP_DATA | BTRFS_BLOCK_GROUP_METADATA)) {
|
||||
mixed = 1;
|
||||
} else {
|
||||
/*
|
||||
* As mixed mode is not supported in zoned mode, this
|
||||
* will account for all profile types
|
||||
*/
|
||||
u64 tmp;
|
||||
|
||||
tmp = device_get_zone_unusable(fd, flags);
|
||||
if (tmp != DEVICE_ZONE_UNUSABLE_UNKNOWN)
|
||||
zone_unusable += tmp;
|
||||
}
|
||||
if (flags & BTRFS_BLOCK_GROUP_DATA) {
|
||||
r_data_used += sargs->spaces[i].used_bytes * ratio;
|
||||
@ -579,6 +591,11 @@ static int print_filesystem_usage_overall(int fd, struct chunk_info *chunkinfo,
|
||||
pretty_size_mode(r_total_missing, unit_mode));
|
||||
printf(" Used:\t\t\t%*s\n", width,
|
||||
pretty_size_mode(r_total_used, unit_mode));
|
||||
ret = ioctl(fd, BTRFS_IOC_GET_FEATURES, &feature_flags);
|
||||
if (ret == 0 && (feature_flags.incompat_flags & BTRFS_FEATURE_INCOMPAT_ZONED)) {
|
||||
printf(" Device zone unusable:\t%*s\n", width,
|
||||
pretty_size_mode(zone_unusable, unit_mode));
|
||||
}
|
||||
printf(" Free (estimated):\t\t%*s\t(",
|
||||
width,
|
||||
pretty_size_mode(free_estimated, unit_mode));
|
||||
|
Loading…
Reference in New Issue
Block a user