btrfs-progs: Don't reset ratio to 1 if we don't have RAID56 profile
PATCH 1/1 btrfs-progs: Don't reset ratio to 1 if we don't have RAID56 profile
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.
--- cmds/filesystem-usage.c | 3 --- 1 file changed, 3 deletions(-)
cmds/filesystem-usage.c +0 -3
@@ -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;
--
2.17.1
Quoted 7 lines · Nikolay Borisov
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.
Quoted 5 lines
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 <[email protected]>
Added to devel, thanks.