linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Austin S. Hemmelgarn" <ahferroin7@gmail.com>
To: "Stéphane Lesimple" <stephane_btrfs@lesimple.fr>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: Rebalancing raid1 after adding a device
Date: Tue, 18 Jun 2019 15:42:09 -0400	[thread overview]
Message-ID: <958d79f1-ed9c-eca3-9d7a-03a846de8f2f@gmail.com> (raw)
In-Reply-To: <3cf139f51a2bc9324797a13831f99507@lesimple.fr>

On 2019-06-18 15:37, Stéphane Lesimple wrote:
> June 18, 2019 9:06 PM, "Austin S. Hemmelgarn" <ahferroin7@gmail.com> wrote:
> 
>> On 2019-06-18 14:26, Stéphane Lesimple wrote:
>>
>> [...]
>>
>>> I don't need to have a perfectly balanced FS, I just want all the space > to be allocatable.
>>> I tried using the -ddevid option but it only instructs btrfs to work on > the block groups
>>> allocated on said device, as it happens, it tends to > move data between the 4 preexisting devices
>>> and doesn't fix my problem. > A full balance with -dlimit=100 did no better.
>>> Is there a way to ask the block group allocator to prefer writing to a > specific device during a
>>> balance? Something like -ddestdevid=N? This > would just be a hint to the allocator and the usual
>>> constraints would > always apply (and prevail over the hint when needed).
>>> Or is there any obvious solution I'm completely missing?
>>
>> Based on what you've said, you may actually not have enough free space that can be allocated to
>> balance things properly.
>>
>> When a chunk gets balanced, you need to have enough space to create a new instance of that type of
>> chunk before the old one is removed. As such, if you can't allocate new chunks at all, you can't
>> balance those chunks either.
>>
>> So, that brings up the question of how to deal with your situation.
>>
>> The first thing I would do is multiple compaction passes using the `usage` filter. Start with:
>>
>> btrfs balance -dusage=0 -musage=0 /wherever
>>
>> That will clear out any empty chunks which haven't been removed (there shouldn't be any if you're
>> on a recent kernel, but it's good practice anyway). After that, repeat the same command, but with a
>> value of 10 instead of 0, and then keep repeating in increments of 10 up until 50. Doing this will
>> clean up chunks that are more than half empty (making multiple passes like this is a bit more
>> reliable, and in some cases also more efficient), which should free up enough space for balance to
>> work with (as well as probably moving most of the block groups it touches to use the new disk).
> 
> Fair point, I do run some balances with -dusage=20 from time to time, the current state of the FS
> is actually as follows:
> 
> btrfs d u /tank | grep Unallocated:
>     Unallocated:            57.45GiB
>     Unallocated:             4.58TiB <= new 10T
>     Unallocated:            16.03GiB
>     Unallocated:            63.49GiB
>     Unallocated:            69.52GiB
> 
> As you can see I was able to move some data to the new 10T drive in the last few days, mainly by
> trial/error with several -ddevid and -dlimit parameters. As of now I still have 4.38T that are
> unallocatable, out of the 4.58T that are unallocated on the new drive. I was looking for a better
> solution that just running a full balance (with or without -devid=old10T) by asking btrfs to
> balance data to the new drive, but it seems there's no way to instruct btrfs to do that.
> 
> I think I'll still run a -dusage pass before doing the full balance indeed, can't hurt.
> 
I would specifically make a point to go all the way up to `-dusage=50` 
on that pass though.  It will, of course, take longer than a run with 
`-dusage=20` would, but it will also do a much better job.

That said, it looks like you should have more than enough space for 
balance to be doing it's job correctly here, so I suspect you may have a 
lot of partially full chunks around and the balance is repacking into 
those instead of allocating new chunks.

Regardless though, I suspect that just doing a balance pass with the 
devid filter and only balancing chunks that are on the old 10TB disk as 
Hugo suggested is probably going to get you the best results 
proportionate to the time it takes.

  reply	other threads:[~2019-06-18 19:42 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-18 18:26 Rebalancing raid1 after adding a device Stéphane Lesimple
2019-06-18 18:45 ` Hugo Mills
2019-06-18 18:50   ` Austin S. Hemmelgarn
2019-06-18 18:57     ` Hugo Mills
2019-06-18 18:58       ` Austin S. Hemmelgarn
2019-06-18 19:03         ` Chris Murphy
2019-06-18 18:57     ` Chris Murphy
2019-06-19  3:27   ` Andrei Borzenkov
2019-06-19  8:58     ` Stéphane Lesimple
2019-06-19 11:59   ` Supercilious Dude
2019-06-18 19:06 ` Austin S. Hemmelgarn
2019-06-18 19:15 ` Stéphane Lesimple
2019-06-18 19:22   ` Hugo Mills
2019-06-18 19:37 ` Stéphane Lesimple
2019-06-18 19:42   ` Austin S. Hemmelgarn [this message]
2019-06-18 20:03   ` Stéphane Lesimple

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=958d79f1-ed9c-eca3-9d7a-03a846de8f2f@gmail.com \
    --to=ahferroin7@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=stephane_btrfs@lesimple.fr \
    /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).