From: Hugo Mills <hugo@carfax.org.uk>
To: Martin Steigerwald <Martin@lichtvoll.de>
Cc: Sergei Trofimovich <slyich@gmail.com>, linux-btrfs@vger.kernel.org
Subject: Re: speeding up slow btrfs filesystem
Date: Sat, 17 Dec 2011 11:26:19 +0000 [thread overview]
Message-ID: <20111217112619.GD17573@carfax.org.uk> (raw)
In-Reply-To: <201112171209.56877.Martin@lichtvoll.de>
[-- Attachment #1: Type: text/plain, Size: 2765 bytes --]
On Sat, Dec 17, 2011 at 12:09:56PM +0100, Martin Steigerwald wrote:
> I think I will scrub / balance / defragment the filesystem after a backup.
> But I am not sure in what order.
>
> I understand that defragment defragments files. But then what does balance
> do? For RAID setup I have seen it distributing data evenly across drives
> when I echo > /sys/block/sda/[…]/delete a drive before and BTRFS had to
> distribute unevenly cause of that. But what does it do on a filesystem on a
> single drive? I bet it would balance out trees? Will it resize trees with
> lots of unused space as well?
The metadata trees are automatically balanced, simply by the nature
of the B-tree algorithms used. Balance won't, in general, affect them.
The only thing that a balance will achieve on a single-disk filesystem
is to reclaim unused space from allocated block groups -- so the
"total" value in your Data and Metadata entries below will go down.
> According to
>
> deepdance:~> btrfs filesystem df /
> Data: total=11.23GB, used=6.98GB
> System, DUP: total=8.00MB, used=4.00KB
> System: total=4.00MB, used=0.00
> Metadata, DUP: total=1.86GB, used=511.35MB
> deepdance:~> btrfs filesystem show
> […]
> Label: 'debian' uuid: 2bf5b1dc-1d89-4f0d-a561-1a5551a27275
> Total devices 1 FS bytes used 7.48GB
> devid 1 size 15.00GB used 14.97GB path /dev/dm-0
>
> Btrfs Btrfs v0.19
>
> the filesystem might have had some chances to fragment heavily, cause the
> tree sizes add up almost to the 15 GB of space available.
>
> I also remember that for some time the filesystem was nearly full which
> would explain the tree sizes.
For metadata, the lower bound on size is 0.1% of the data size
(because checksums are computed at 4 bytes for every 4096 bytes of
data). However, data usage can be very much greater than this with
inline extents, where small files can get embedded directly in the
metadata section. This is probably more likely what explains the tree
sizes.
I understand (although I've not done the analysis myself) that the
maximum "wasted" space in btrfs's B-tree implementation is 50%. To the
best of my knowledge, there's no compaction process for btrfs's trees
available -- nor, in general, should you need one, as a fully-
compacted tree would only have to be rearranged when more data is
added to it, thus slowing the system down after compaction.
Hugo.
--
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
--- I'll take your bet, but make it ten thousand francs. I'm only ---
a _poor_ corrupt official.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 190 bytes --]
next prev parent reply other threads:[~2011-12-17 11:26 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-16 17:51 speeding up slow btrfs filesystem Martin Steigerwald
2011-12-16 17:54 ` Martin Steigerwald
2011-12-16 18:38 ` Goffredo Baroncelli
2011-12-16 19:53 ` Martin Steigerwald
2011-12-16 20:58 ` Martin Steigerwald
2011-12-17 7:03 ` Sergei Trofimovich
2011-12-17 11:09 ` Martin Steigerwald
2011-12-17 11:26 ` Hugo Mills [this message]
2011-12-17 11:38 ` Martin Steigerwald
2011-12-17 11:45 ` Hugo Mills
2011-12-17 11:57 ` Martin Steigerwald
2011-12-17 16:35 ` Martin Steigerwald
2011-12-17 17:27 ` Hugo Mills
2011-12-17 11:39 ` Goffredo Baroncelli
2011-12-18 18:41 ` Andrea Gelmini
2011-12-20 19:46 ` Goffredo Baroncelli
2011-12-17 11:11 ` Chris Samuel
2011-12-17 12:00 ` Martin Steigerwald
2011-12-17 12:42 ` David McBride
2011-12-17 16:14 ` Martin Steigerwald
-- strict thread matches above, loose matches on Subject: below --
2011-12-17 11:54 Martin Steigerwald
2011-12-17 12:02 ` Martin Steigerwald
2011-12-17 12:50 ` Goffredo Baroncelli
2011-12-17 16:10 ` Martin Steigerwald
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=20111217112619.GD17573@carfax.org.uk \
--to=hugo@carfax.org.uk \
--cc=Martin@lichtvoll.de \
--cc=linux-btrfs@vger.kernel.org \
--cc=slyich@gmail.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 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).