From: Austin S Hemmelgarn <ahferroin7@gmail.com>
To: Bob Williams <linux@barrowhillfarm.org.uk>, linux-btrfs@vger.kernel.org
Subject: Re: Is it necessary to balance a btrfs raid1 array?
Date: Wed, 10 Sep 2014 09:06:30 -0400 [thread overview]
Message-ID: <54104CD6.3030604@gmail.com> (raw)
In-Reply-To: <541043B8.7010601@barrowhillfarm.org.uk>
[-- Attachment #1: Type: text/plain, Size: 3196 bytes --]
On 2014-09-10 08:27, Bob Williams wrote:
> I have two 2TB disks formatted as a btrfs raid1 array, mirroring both
> data and metadata. Last night I started
>
> # btrfs filesystem balance <path>
>
In general, unless things are really bad, you don't ever want to use
balance on such a big filesystem without some filters to control what
gets balanced (especially if the filesystem is more than about 50% full
most of the time).
My suggestion in this case would be to use:
# btrfs balance start -dusage=25 -musage=25 <path>
on a roughly weekly basis. This will only balance chunks that are less
than 25% full, and therefore run much faster. If you are particular
about high storage efficiency, then try 50 instead of 25.
> and it is still running 18 hours later. This suggests that most stuff
> only gets written to one physical device, which in turn suggests that
> there is a risk of lost data if one physical device fails. Or is there
> something clever about btrfs raid that I've missed? I've used linux
> software raid (mdraid) before, and it appeared to write to both
> devices simultaneously.
The reason that a full balance takes so long on a big (and I'm assuming
based on the 18 hours it's taken, very full) filesystem is that it reads
all of the data, and writes it out to both disks, but it doesn't do very
good load-balancing like mdraid or LVM do. I've got a 4x 500Gib BTRFS
RAID10 filesystem that I use for my home directory on my desktop system,
and a full balance on that takes about 6 hours.
>
> Is it safe to interrupt [^Z] the btrfs balancing process?
^Z sends a SIGSTOP, which is a really bad idea with something that is
doing low-level stuff to a filesystem. If you need to stop the balance
process (and are using a recent enough kernel and btrfs-progs), the
preferred way to do so is to use the following from another terminal:
# btrfs balance stop <path>
Depending on what the balance operation is working when you do this, it
may take a few minutes before it actually stops (the longest that I've
seen it take is ~200 seconds).
>
> As a rough guide, how often should one perform
>
> a) balance
> b) defragment
> c) scrub
>
> on a btrfs raid setup?
In general, you should be running scrub regularly, and balance and
defragment as needed. On the BTRFS RAID filesystems that I have, I use
the following policy:
1) Run a 25% balance (the command I mentioned above) on a weekly basis.
2) If the filesystem has less than 50% of either the data or metadata
chunks full at the end of the month, run a full balance on it.
3) Run a scrub on a daily basis.
4) Defragment files only as needed (which isn't often for me because I
use the autodefrag mount option).
5) Make sure than only one of balance, scrub or defrag is running at a
given time.
Normally, you shouldn't need to run balance at all on most BTRFS
filesystems, unless your usage patterns vary widely over time (I'm
actually a good example of this, most of the files in my home directory
are relatively small, except for when I am building a system with
buildroot or compiling a kernel, and on occasion I have VM images that
I'm working with).
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 2455 bytes --]
next prev parent reply other threads:[~2014-09-10 13:06 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-10 12:27 Is it necessary to balance a btrfs raid1 array? Bob Williams
2014-09-10 13:06 ` Austin S Hemmelgarn [this message]
2014-09-10 13:48 ` Rich Freeman
2014-09-10 14:41 ` Austin S Hemmelgarn
2014-09-10 17:44 ` Bob Williams
2014-09-10 18:43 ` Goffredo Baroncelli
2014-09-10 19:32 ` Sean Greenslade
2014-09-10 22:28 ` Goffredo Baroncelli
2014-09-11 1:25 ` Sean Greenslade
2014-09-11 3:51 ` Zygo Blaxell
2014-09-11 4:23 ` Sean Greenslade
2014-09-11 6:55 ` Duncan
2014-09-11 9:56 ` Bob Williams
2014-09-11 11:10 ` Duncan
2014-09-11 4:30 ` Zygo Blaxell
2014-09-11 9:08 ` Bob Williams
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=54104CD6.3030604@gmail.com \
--to=ahferroin7@gmail.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux@barrowhillfarm.org.uk \
/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).