From: robbieko <robbieko@synology.com>
To: Linux Btrfs <linux-btrfs@vger.kernel.org>
Subject: Btrfs reserve metadata problem
Date: Tue, 02 Jan 2018 15:51:39 +0800 [thread overview]
Message-ID: <d74d1cc471fb12f8ea55cba36e82582b@synology.com> (raw)
Hi All,
When testing Btrfs with fio 4k random write, I found that volume with
smaller free space available has lower performance.
It seems that the smaller the free space of volume is, the smaller
amount of dirty page filesystem could have.
There are only 6 MB dirty pages when free space of volume is only 10GB
with 16KB-nodesize and cow disabled.
btrfs will reserve metadata for every write.
The amount to reserve is calculated as follows: nodesize *
BTRFS_MAX_LEVEL(8) * 2, i.e., it reserves 256KB of metadata.
The maximum amount of metadata reservation depends on size of metadata
currently in used and free space within volume(free chunk size /16)
When metadata reaches the limit, btrfs will need to flush the data to
release the reservation.
1. Is there any logic behind the value (free chunk size /16)
/*
* If we have dup, raid1 or raid10 then only half of the free
* space is actually useable. For raid56, the space info used
* doesn't include the parity drive, so we don't have to
* change the math
*/
if (profile & (BTRFS_BLOCK_GROUP_DUP |
BTRFS_BLOCK_GROUP_RAID1 |
BTRFS_BLOCK_GROUP_RAID10))
avail >>= 1;
/*
* If we aren't flushing all things, let us overcommit up to
* 1/2th of the space. If we can flush, don't let us overcommit
* too much, let it overcommit up to 1/8 of the space.
*/
if (flush == BTRFS_RESERVE_FLUSH_ALL)
avail >>= 3;
else
avail >>= 1;
2. Is there any way to improve this problem?
Thanks.
Robbie Ko
next reply other threads:[~2018-01-02 7:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-02 7:51 robbieko [this message]
2018-01-02 8:15 ` Btrfs reserve metadata problem Qu Wenruo
2018-01-02 13:08 ` Peter Grandi
2018-01-03 1:55 ` robbieko
2018-01-03 2:01 ` 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=d74d1cc471fb12f8ea55cba36e82582b@synology.com \
--to=robbieko@synology.com \
--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