btrfs-progs: fi-usage: fix RAID10 raw disk usage

In case of RAID10, fi usage is reporting half the amount of allocated
space and twice the amount of unallocated disk space. Let's fix this.

For example, a RAID10 chunk of 3GiB with num_stripes 6, half of the
stripes (dev extents) are a mirror of the other half, so the 3GiB of
actual data has to be divided by 3, and not 6 to get the size of each of
those device extents.

Signed-off-by: Hans van Kranenburg <hans@knorrie.org>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Hans van Kranenburg 2018-06-02 23:26:41 +02:00 committed by David Sterba
parent 9ff39d48aa
commit 96af160a01

View file

@ -660,7 +660,7 @@ static u64 calc_chunk_size(struct chunk_info *ci)
else if (ci->type & BTRFS_BLOCK_GROUP_RAID6)
return ci->size / (ci->num_stripes -2);
else if (ci->type & BTRFS_BLOCK_GROUP_RAID10)
return ci->size / ci->num_stripes;
return ci->size / (ci->num_stripes / 2);
return ci->size;
}