btrfs-progs: fi usage: don't reset ratio to 1 if we don't have RAID56 profile

Commit 80714610f3 ("btrfs-progs: use raid table for ncopies")
slightly broke how raid ratio are being calculated since the resulting
code would always reset ratio to be 1 in case we didn't have RAID56
profile. The correct behavior is to simply set it to 0 if we have RAID56
as the calculation is different in this case and leave it intact
otherwise.

This bug manifests by doing all size-related calculation for 'btrfs
filesystem usage' command as if all block groups are of type SINGLE. Fix
this by only resetting ratio 0 in case of RAID56.

Issue: #422
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Nikolay Borisov 2021-11-15 11:15:42 +02:00 committed by David Sterba
parent 683f41bfb0
commit 6df189771d

View File

@ -508,8 +508,6 @@ static int print_filesystem_usage_overall(int fd, struct chunk_info *chunkinfo,
*/ */
if (flags & BTRFS_BLOCK_GROUP_RAID56_MASK) if (flags & BTRFS_BLOCK_GROUP_RAID56_MASK)
ratio = 0; ratio = 0;
else
ratio = 1;
if (ratio > max_data_ratio) if (ratio > max_data_ratio)
max_data_ratio = ratio; max_data_ratio = ratio;