linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Duncan <1i5t5.duncan@cox.net>
To: linux-btrfs@vger.kernel.org
Subject: Re: [btrfs-progs] Bug in mkfs.btrfs -r
Date: Tue, 5 Sep 2017 03:57:56 +0000 (UTC)	[thread overview]
Message-ID: <pan$8861e$4d63ba40$47e0003f$7600c860@cox.net> (raw)
In-Reply-To: pan$9833c$c04b7334$d8bed9c4$4b7b46fb@cox.net

Duncan posted on Sat, 02 Sep 2017 04:03:06 +0000 as excerpted:

> Austin S. Hemmelgarn posted on Fri, 01 Sep 2017 10:07:47 -0400 as
> excerpted:
> 
>>  On 2017-09-01 09:54, Qu Wenruo wrote:
>>> 
>>> On 2017年09月01日 20:47, Austin S. Hemmelgarn wrote:
> 
>>>> On 2017-09-01 08:19, Qu Wenruo wrote:
>>>>>
>>>>> Current kernel (and btrfs-progs also tries to follow kernel chunk
>>>>> allocator's behavior) will not make a chunk larger than 10% of RW
>>>>> space.
>>>>> So for small filesystem chunk won't be too maximally sized.
> 
>>>> Are you sure about this?  I've got a couple of sub 10GB BTRFS volumes
>>>> that definitely have more than one 1GB data chunk.
>>> 
>>> Yes, check the following code:
>>> 
>>>          /* we don't want a chunk larger than 10% of writeable
>>>          space */
>>>          max_chunk_size = min(div_factor(fs_devices->total_rw_bytes,
>>>          1),
>>>                               max_chunk_size);
>>>
>>> Which is in __btrfs_alloc_chunk() function in fs/btrfs/volumes.c
> 
>> Huh, I may have the remnants of an old bug present on those filesystems
>> then, I'll have to look further into this.
> 
> Please do.

> Meanwhile, I might have some free time to do my own checks tomorrow.
> It'd be worth it just to my own peace of mind to settle the issue,
> since it frustrated me for so long.

Just finished testing, and no, as of btrfs-progs 4.12, mkfs.btrfs does 
*NOT* always limit chunk sizes to 1/10 filesystem size, despite smaller 
chunk sizes being available.

Try this.

256 MiB partition.

mkfs.btrfs -d dup -m dup -O extref,skinny-metadata,no-holes --mixed 
<device>

mkfs.btrfs will create a 64 MiB mixed-mode chunk, a quarter the 256 MiB 
filesystem size, duped to 128 MiB, half the filesystem size.

That chunk cannot be balanced because there's no room for the write-into 
chunk and its dup on the filesystem, due to the system chunk of several 
MiB taking up part of the other half.

This despite further writes creating smaller chunks, so it's definitely 
possible to have 32 MiB and I believe 16 MiB chunks (at least, don't know 
if smaller is possible).

So as of -progs 4.12 at least, whatever code is there to try to keep 
mkfs.btrfs max chunk size under 10% of the filesystem size, is broken, at 
least for some configurations (check mixed-mode, sub-GiB).

So I'm glad I upsized /boot to half a GiB when I upgraded SSDs and redid 
my layout.  At least with half a gig, 64 MiB (still 12.5%, over the 10% 
limit) doubled to 128 MiB is still only a quarter the filesystem size, so 
rebalancing is actually possible.

(FWIW my /var/log is still 256 MiB per device, but it's raid1, so only a 
single copy of each chunk per device, and the 64 MiB chunk size is only a 
quarter of the device, so it can at least still be balanced, even with 
chunks more than double the broken 10% ceiling.)

-- 
Duncan - List replies preferred.   No HTML msgs.
"Every nonfree program has a lord, a master --
and if you use the program, he is your master."  Richard Stallman


  reply	other threads:[~2017-09-05  3:58 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-31 17:27 [btrfs-progs] Bug in mkfs.btrfs -r Goffredo Baroncelli
2017-08-31 18:49 ` Austin S. Hemmelgarn
2017-08-31 20:29   ` Goffredo Baroncelli
2017-09-01 11:49     ` Austin S. Hemmelgarn
2017-09-01  0:13 ` Qu Wenruo
2017-09-01 11:28   ` Austin S. Hemmelgarn
2017-09-01 11:49     ` Qu Wenruo
2017-09-01 12:05       ` Austin S. Hemmelgarn
2017-09-01 12:19         ` Qu Wenruo
2017-09-01 12:47           ` Austin S. Hemmelgarn
2017-09-01 13:54             ` Qu Wenruo
2017-09-01 14:07               ` Austin S. Hemmelgarn
2017-09-02  4:03                 ` Duncan
2017-09-05  3:57                   ` Duncan [this message]
2017-09-01 11:54     ` Qu Wenruo

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='pan$8861e$4d63ba40$47e0003f$7600c860@cox.net' \
    --to=1i5t5.duncan@cox.net \
    --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).