Message ID | 20211115091542.200657-1-nborisov@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs-progs: Don't reset ratio to 1 if we don't have RAID56 profile | expand |
On Mon, Nov 15, 2021 at 11:15:42AM +0200, Nikolay Borisov wrote: > Commit 80714610f36e ("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 reseting ratio 0 in case of RAID56. > > Signed-off-by: Nikolay Borisov <nborisov@suse.com> Added to devel, thanks.
diff --git a/cmds/filesystem-usage.c b/cmds/filesystem-usage.c index e22efe3a441d..6195f633da44 100644 --- a/cmds/filesystem-usage.c +++ b/cmds/filesystem-usage.c @@ -500,7 +500,6 @@ static int print_filesystem_usage_overall(int fd, struct chunk_info *chunkinfo, u64 flags = sargs->spaces[i].flags; ratio = btrfs_bg_type_to_ncopies(flags); - /* * The RAID5/6 ratio depends on the number of stripes and is * computed separately. Setting ratio to 0 will not account @@ -508,8 +507,6 @@ static int print_filesystem_usage_overall(int fd, struct chunk_info *chunkinfo, */ if (flags & BTRFS_BLOCK_GROUP_RAID56_MASK) ratio = 0; - else - ratio = 1; if (ratio > max_data_ratio) max_data_ratio = ratio;
Commit 80714610f36e ("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 reseting ratio 0 in case of RAID56. Signed-off-by: Nikolay Borisov <nborisov@suse.com> --- cmds/filesystem-usage.c | 3 --- 1 file changed, 3 deletions(-) -- 2.17.1