btrfs-progs: fix wrong data ratio for raid56 in btrfs-file-usage
authorGui Hecheng <guihc.fnst@cn.fujitsu.com>
Thu, 24 Jul 2014 03:21:52 +0000 (11:21 +0800)
committerDavid Sterba <dsterba@suse.cz>
Thu, 4 Dec 2014 15:48:12 +0000 (16:48 +0100)
commitb2784b0fa15049608b128f42a3c56303e53dff84
tree336808abc52d1e420e0b31f77c26c634ae2f0744
parent373110d84f3a1c5bdd305d2e6dcaeb98b5e6dbe7
btrfs-progs: fix wrong data ratio for raid56 in btrfs-file-usage

When run btrfs-file-usage on a btrfs with data profile raid5/6,
the output message for "Free" & "Data to device ratio" seems wrong
as follows:
    ...
    Device size:  100.00GiB
    Device allocated:    2.04GiB
    Device unallocated:   97.96GiB
    Used:    1.12MiB
    Free (Estimated):  197.89GiB <== Free > Device size
    Data to device ratio:      198 % <== > 100%
    Global reserve:      0.00B
    ...

It is because the function get_raid56_used() is not iterating the
chunk_info array correctly, it is just repeating adding the first
chunk_info statistics.
Just add a ptr to iterate over the array.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
cmds-fi-disk_usage.c