From: Roman Mamedov <rm@romanrm.net>
To: Roman Mamedov <rm@romanrm.net>
Cc: Chris Murphy <lists@colorremedies.com>,
kreijack@inwind.it, kreijack@libero.it,
Brendan Hide <brendan@swiftspirit.co.za>,
linux-btrfs@vger.kernel.org
Subject: Re: Provide a better free space estimate on RAID1
Date: Sat, 8 Feb 2014 17:21:42 +0600 [thread overview]
Message-ID: <20140208172142.44243c67@natsu> (raw)
In-Reply-To: <20140207120812.43dc7982@natsu>
[-- Attachment #1: Type: text/plain, Size: 2016 bytes --]
On Fri, 7 Feb 2014 12:08:12 +0600
Roman Mamedov <rm@romanrm.net> wrote:
> > Earlier conventions would have stated Size ~900GB, and Avail ~900GB. But that's not exactly true either, is it?
>
> Much better, and matching the user expectations of how RAID1 should behave,
> without a major "gotcha" blowing up into their face the first minute they are
> trying it out. In fact next step that I planned would be finding how to adjust
> also Size and Used on all my machines to show what you just mentioned.
OK done; again, this is just what I will personally use from now on (and for
anyone who finds this helpful).
----
--- fs/btrfs/super.c.orig 2014-02-06 01:28:36.636164982 +0600
+++ fs/btrfs/super.c 2014-02-08 17:16:50.361931959 +0600
@@ -1481,6 +1481,11 @@
}
kfree(devices_info);
+
+ if (type & BTRFS_BLOCK_GROUP_RAID1) {
+ do_div(avail_space, min_stripes);
+ }
+
*free_bytes = avail_space;
return 0;
}
@@ -1491,8 +1496,10 @@
struct btrfs_super_block *disk_super = fs_info->super_copy;
struct list_head *head = &fs_info->space_info;
struct btrfs_space_info *found;
+ u64 total_size;
u64 total_used = 0;
u64 total_free_data = 0;
+ u64 type;
int bits = dentry->d_sb->s_blocksize_bits;
__be32 *fsid = (__be32 *)fs_info->fsid;
int ret;
@@ -1512,7 +1519,13 @@
rcu_read_unlock();
buf->f_namelen = BTRFS_NAME_LEN;
- buf->f_blocks = btrfs_super_total_bytes(disk_super) >> bits;
+ total_size = btrfs_super_total_bytes(disk_super);
+ type = btrfs_get_alloc_profile(fs_info->tree_root, 1);
+ if (type & BTRFS_BLOCK_GROUP_RAID1) {
+ do_div(total_size, 2);
+ do_div(total_used, 2);
+ }
+ buf->f_blocks = total_size >> bits;
buf->f_bfree = buf->f_blocks - (total_used >> bits);
buf->f_bsize = dentry->d_sb->s_blocksize;
buf->f_type = BTRFS_SUPER_MAGIC;
----
2x1TB RAID1 with a 1GB file:
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 912G 1.1G 911G 1% /mnt/p2
--
With respect,
Roman
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
next prev parent reply other threads:[~2014-02-08 11:21 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-05 20:15 Provide a better free space estimate on RAID1 Roman Mamedov
2014-02-06 7:38 ` Brendan Hide
2014-02-06 12:45 ` Roman Mamedov
2014-02-06 19:54 ` Goffredo Baroncelli
2014-02-07 4:40 ` Roman Mamedov
2014-02-07 5:30 ` Chris Murphy
2014-02-07 6:08 ` Roman Mamedov
2014-02-07 18:44 ` Chris Murphy
2014-02-08 21:46 ` Kai Krakow
2014-02-08 11:21 ` Roman Mamedov [this message]
2014-02-07 10:02 ` Martin Steigerwald
2014-02-08 21:50 ` Kai Krakow
2014-02-08 15:46 ` Goffredo Baroncelli
2014-02-08 16:36 ` [PATCH][V2] " Goffredo Baroncelli
2014-02-09 17:20 ` [PATCH][V3] Provide a better free space estimate [was]Re: " Goffredo Baroncelli
2014-02-07 14:05 ` Frank Kingswood
2014-02-06 20:21 ` Josef Bacik
2014-02-07 20:32 ` Kai Krakow
2014-02-08 11:33 ` Roman Mamedov
2014-02-08 11:46 ` Hugo Mills
2014-02-08 21:35 ` Kai Krakow
2014-02-08 22:10 ` Roman Mamedov
2014-02-08 22:45 ` cwillu
2014-02-08 23:27 ` Kai Krakow
2014-02-08 23:32 ` Kai Krakow
2014-02-09 1:08 ` Roman Mamedov
2014-02-09 9:39 ` Kai Krakow
2014-02-09 6:38 ` Duncan
2014-02-09 9:20 ` Roman Mamedov
2014-02-10 0:02 ` Duncan
2014-02-10 9:14 ` Roman Mamedov
2014-02-09 9:37 ` Kai Krakow
2014-02-08 23:17 ` Kai Krakow
2014-02-09 1:55 ` Roman Mamedov
2014-02-09 2:21 ` Chris Murphy
2014-02-09 2:29 ` Chris Murphy
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=20140208172142.44243c67@natsu \
--to=rm@romanrm.net \
--cc=brendan@swiftspirit.co.za \
--cc=kreijack@inwind.it \
--cc=kreijack@libero.it \
--cc=linux-btrfs@vger.kernel.org \
--cc=lists@colorremedies.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.