linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] btrfs-progs: fix wrong data ratio for raid56 in btrfs-file-usage
@ 2014-07-24  3:21 Gui Hecheng
  2014-07-24  3:21 ` [PATCH 2/3] btrfs-progs: output the correct path when fi-usage failed Gui Hecheng
  2014-07-24  3:21 ` [PATCH 3/3] btrfs-progs: fix improper output msg for btrfs-fi-usage Gui Hecheng
  0 siblings, 2 replies; 4+ messages in thread
From: Gui Hecheng @ 2014-07-24  3:21 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Gui Hecheng

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>
---
 cmds-fi-disk_usage.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
index 453410f..78dc414 100644
--- a/cmds-fi-disk_usage.c
+++ b/cmds-fi-disk_usage.c
@@ -293,14 +293,16 @@ static struct btrfs_ioctl_space_args *load_space_info(int fd, char *path)
 static void get_raid56_used(int fd, struct chunk_info *chunks, int chunkcount,
 		u64 *raid5_used, u64 *raid6_used)
 {
+	struct chunk_info *info_ptr = chunks;
 	*raid5_used = 0;
 	*raid6_used = 0;
 
 	while (chunkcount-- > 0) {
-		if (chunks->type & BTRFS_BLOCK_GROUP_RAID5)
-			(*raid5_used) += chunks->size / (chunks->num_stripes - 1);
-		if (chunks->type & BTRFS_BLOCK_GROUP_RAID6)
-			(*raid6_used) += chunks->size / (chunks->num_stripes - 2);
+		if (info_ptr->type & BTRFS_BLOCK_GROUP_RAID5)
+			(*raid5_used) += info_ptr->size / (info_ptr->num_stripes - 1);
+		if (info_ptr->type & BTRFS_BLOCK_GROUP_RAID6)
+			(*raid6_used) += info_ptr->size / (info_ptr->num_stripes - 2);
+		info_ptr++;
 	}
 }
 
-- 
1.8.1.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-07-24  3:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-24  3:21 [PATCH 1/3] btrfs-progs: fix wrong data ratio for raid56 in btrfs-file-usage Gui Hecheng
2014-07-24  3:21 ` [PATCH 2/3] btrfs-progs: output the correct path when fi-usage failed Gui Hecheng
2014-07-24  3:27   ` [PATCH v2 " Gui Hecheng
2014-07-24  3:21 ` [PATCH 3/3] btrfs-progs: fix improper output msg for btrfs-fi-usage Gui Hecheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).