From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: adambahe@gmail.com, dsterba@suse.cz
Subject: [PATCH 1/2] btrfs-progs: fi-usage: Fix wrong RAID10 used and unallocated space
Date: Tue, 2 Jan 2018 14:33:14 +0800 [thread overview]
Message-ID: <20180102063315.32382-1-wqu@suse.com> (raw)
[BUG]
For a very basic RAID10 with 4 disks, "fi usage" and "fi show" are
outputting conflicting result:
------
# btrfs fi show /mnt/btrfs/
Label: none uuid: 6d0229db-28d1-4696-ac20-e828cc45dc40
Total devices 4 FS bytes used 1.12MiB
devid 1 size 5.00GiB used 2.01GiB path /dev/mapper/data-disk1
devid 2 size 5.00GiB used 2.01GiB path /dev/mapper/data-disk2
devid 3 size 5.00GiB used 2.01GiB path /dev/mapper/data-disk3
devid 4 size 5.00GiB used 2.01GiB path /dev/mapper/data-disk4
Here the unallocated space for disk4 should be a little less than 3G.
(5.00 Gib - 2.01GiB)
# btrfs fi usage /mnt/btrfs/
Overall:
Device size: 20.00GiB
Device allocated: 8.03GiB
Device unallocated: 11.97GiB
Device missing: 0.00B
Used: 2.25MiB
Free (estimated): 7.98GiB (min: 7.98GiB)
Data ratio: 2.00
Metadata ratio: 2.00
Global reserve: 16.00MiB (used: 0.00B)
Data,RAID10: Size:2.00GiB, Used:1.00MiB
...
/dev/mapper/data-disk4 512.00MiB
Metadata,RAID10: Size:2.00GiB, Used:112.00KiB
...
/dev/mapper/data-disk4 512.00MiB
System,RAID10: Size:16.00MiB, Used:16.00KiB
...
/dev/mapper/data-disk4 4.00MiB
Unallocated:
...
/dev/mapper/data-disk4 4.00GiB
While fi usage shows we still have 4.00GiB unallocated space.
------
[CAUSE]
calc_chunk_size() is used to convert chunk size to device extent size,
which is used to get the per-device data/meta/sys used space.
However, for RAID10 we just divide the chunk size with num_stripes,
without taking sub stripes into account.
Resulting data/meta/sys usage in RAID10 halved.
[FIX]
Take the missing sub stripes into consideration.
Reported-by: Adam Bahe <adambahe@gmail.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
cmds-fi-usage.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cmds-fi-usage.c b/cmds-fi-usage.c
index 0b0e47fee194..0af4bdbc9370 100644
--- a/cmds-fi-usage.c
+++ b/cmds-fi-usage.c
@@ -664,7 +664,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;
}
--
2.15.1
next reply other threads:[~2018-01-02 6:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-02 6:33 Qu Wenruo [this message]
2018-01-02 6:33 ` [PATCH 2/2] btrfs-progs: misc-test: Add test case to check if fi usage and show report consistent unallocated space Qu Wenruo
2018-01-08 19:39 ` David Sterba
2018-01-09 0:21 ` Qu Wenruo
2018-01-23 18:07 ` David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180102063315.32382-1-wqu@suse.com \
--to=wqu@suse.com \
--cc=adambahe@gmail.com \
--cc=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).