From: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
To: <zblaxell@furryterror.org>, <rwhite@pobox.com>, <clm@fb.com>
Cc: <linux-btrfs@vger.kernel.org>,
Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Subject: [PATCH v2 3/3] Btrfs: adapt df command to RAID5/6.
Date: Mon, 5 Jan 2015 18:07:05 +0800 [thread overview]
Message-ID: <1420452425-7874-3-git-send-email-yangds.fnst@cn.fujitsu.com> (raw)
In-Reply-To: <1420452425-7874-1-git-send-email-yangds.fnst@cn.fujitsu.com>
When we use btrfs with raid5/6, the output of df is unexpected as below.
Example:
# mkfs.btrfs -f /dev/vdf1 /dev/vdf2 -d raid5
# mount /dev/vdf1 /mnt
# dd if=/dev/zero of=/mnt/zero bs=1M count=1000
# df -h /mnt
Filesystem Size Used Avail Use% Mounted on
/dev/vdf1 4.2G 1.3G 2.9G 32% /mnt
[root@atest-guest linux_btrfs]# btrfs fi show /mnt
Label: none uuid: f7fac7f2-3898-482e-9cf2-fbcd7fdd7084
Total devices 2 FS bytes used 1001.53MiB
devid 1 size 2.00GiB used 1.85GiB path /dev/vdf1
devid 2 size 4.00GiB used 1.83GiB path /dev/vdf2
The @size should be 2G rather than 4.2G.
This patch makes the btrfs_calc_avail_data_space() consider raid5/6,
then we can get the correct result of it.
Example:
# mkfs.btrfs -f /dev/vdf1 /dev/vdf2 -d raid5
# mount /dev/vdf1 /mnt
# dd if=/dev/zero of=/mnt/zero bs=1M count=1000
# df -h /mnt
Filesystem Size Used Avail Use% Mounted on
/dev/vdf1 2.0G 1.3G 713M 66% /mnt
[root@atest-guest linux_btrfs]# btrfs fi show /mnt
Label: none uuid: ea3a6e6e-fbe1-47aa-b4b5-bc37b98565d9
Total devices 2 FS bytes used 1001.53MiB
devid 1 size 2.00GiB used 1.85GiB path /dev/vdf1
devid 2 size 4.00GiB used 1.83GiB path /dev/vdf2
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
---
fs/btrfs/super.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 1f0f080..4a190de 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -52,6 +52,7 @@
#include "props.h"
#include "xattr.h"
#include "volumes.h"
+#include "raid56.h"
#include "export.h"
#include "compression.h"
#include "rcu-string.h"
@@ -1688,6 +1689,14 @@ static int btrfs_calc_avail_data_space(struct btrfs_root *root, u64 *free_bytes)
min_stripes = 4;
num_stripes = 4;
data_stripes = 2;
+ } else if (type & BTRFS_BLOCK_GROUP_RAID5) {
+ min_stripes = 2;
+ num_stripes = nr_devices;
+ data_stripes = num_stripes - nr_parity_stripes(type);
+ } else if (type & BTRFS_BLOCK_GROUP_RAID6) {
+ min_stripes = 3;
+ num_stripes = nr_devices;
+ data_stripes = num_stripes - nr_parity_stripes(type);
}
if (type & BTRFS_BLOCK_GROUP_DUP)
@@ -1777,8 +1786,11 @@ static int btrfs_calc_avail_data_space(struct btrfs_root *root, u64 *free_bytes)
while (nr_devices >= min_stripes) {
if (num_stripes > nr_devices) {
num_stripes = nr_devices;
- if (type & BTRFS_BLOCK_GROUP_RAID0)
- data_stripes = num_stripes;
+ /* Only RAID0, RAID5 and RAID6 will get here.
+ * And we can use the following calculation
+ * for all the three cases.
+ **/
+ data_stripes = num_stripes - nr_parity_stripes(type);
}
if (devices_info[i].max_avail >= min_stripe_size) {
--
1.8.4.2
next prev parent reply other threads:[~2015-01-05 10:10 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-11 8:31 [PATCH v2 1/3] Btrfs: get more accurate output in df command Dongsheng Yang
2014-12-11 8:31 ` [PATCH v2 2/3] Btrfs: raid56: simplify the parameter of nr_parity_stripes() Dongsheng Yang
2014-12-16 6:21 ` Satoru Takeuchi
2014-12-11 8:31 ` [PATCH v2 3/3] Btrfs: adapt df command to RAID5/6 Dongsheng Yang
2014-12-12 18:00 ` [PATCH v2 1/3] Btrfs: get more accurate output in df command Goffredo Baroncelli
2014-12-13 0:50 ` Duncan
2014-12-13 10:21 ` Dongsheng Yang
2014-12-13 9:57 ` Dongsheng Yang
2014-12-12 19:25 ` Goffredo Baroncelli
2014-12-14 11:29 ` Dongsheng Yang
[not found] ` <CABmMA7tw9BDsBXGHLO4vjcO4gaYmZPb_BQV8w22griqFvCJpPA@mail.gmail.com>
2014-12-14 14:32 ` Grzegorz Kowal
2014-12-15 1:21 ` Dongsheng Yang
2014-12-15 6:06 ` Robert White
2014-12-15 7:49 ` Robert White
2014-12-15 8:26 ` Dongsheng Yang
2014-12-15 9:36 ` Robert White
2014-12-16 3:30 ` Standards Problems [Was: [PATCH v2 1/3] Btrfs: get more accurate output in df command.] Robert White
2014-12-16 3:52 ` Robert White
2014-12-16 11:30 ` Dongsheng Yang
2014-12-16 13:24 ` Dongsheng Yang
2014-12-16 19:52 ` Robert White
2014-12-17 11:38 ` Dongsheng Yang
2014-12-18 4:07 ` Robert White
2014-12-18 8:02 ` Duncan
2014-12-23 12:31 ` Dongsheng Yang
2014-12-27 1:10 ` Robert White
2015-01-05 9:59 ` Dongsheng Yang
2014-12-31 0:15 ` Zygo Blaxell
2015-01-05 9:56 ` Dongsheng Yang
2015-01-05 10:07 ` [PATCH v2 1/3] Btrfs: get more accurate output in df command Dongsheng Yang
2015-01-05 10:07 ` [PATCH v2 2/3] Btrfs: raid56: simplify the parameter of nr_parity_stripes() Dongsheng Yang
2015-01-05 10:07 ` Dongsheng Yang [this message]
2014-12-19 3:32 ` [PATCH v2 1/3] Btrfs: get more accurate output in df command Zygo Blaxell
[not found] ` <548F1EA7.9050505@inwind.it>
2014-12-16 13:47 ` Dongsheng Yang
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=1420452425-7874-3-git-send-email-yangds.fnst@cn.fujitsu.com \
--to=yangds.fnst@cn.fujitsu.com \
--cc=clm@fb.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=rwhite@pobox.com \
--cc=zblaxell@furryterror.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).