diff mbox

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

Message ID 20180602212641.928-1-hans@knorrie.org (mailing list archive)
State New, archived
Headers show

Commit Message

Hans van Kranenburg June 2, 2018, 9:26 p.m. UTC
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>
---
 cmds-fi-usage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Sterba June 6, 2018, 2:56 p.m. UTC | #1
On Sat, Jun 02, 2018 at 11:26:41PM +0200, Hans van Kranenburg wrote:
> 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>

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/cmds-fi-usage.c b/cmds-fi-usage.c
index b9a2b1c8..3bd2ccdf 100644
--- a/cmds-fi-usage.c
+++ b/cmds-fi-usage.c
@@ -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;
 }