From: Duncan <1i5t5.duncan@cox.net>
To: linux-btrfs@vger.kernel.org
Subject: Re: ENOSPC errors during balance
Date: Tue, 22 Jul 2014 03:26:39 +0000 (UTC) [thread overview]
Message-ID: <pan$1a441$ab255f41$47b5d104$887b5db7@cox.net> (raw)
In-Reply-To: 20140722013022.52b189ee@marcec
Marc Joliet posted on Tue, 22 Jul 2014 01:30:22 +0200 as excerpted:
> And now that the background deletion of the old snapshots is done, the file
> system ended up at:
>
> # btrfs filesystem df /run/media/marcec/MARCEC_BACKUP
> Data, single: total=219.00GiB, used=140.13GiB
> System, DUP: total=32.00MiB, used=36.00KiB
> Metadata, DUP: total=4.50GiB, used=2.40GiB
> unknown, single: total=512.00MiB, used=0.00
>
> I don't know how reliable du is for this, but I used it to estimate how much
> used data I should expect, and I get 138 GiB. That means that the snapshots
> yield about 2 GiB "overhead", which is very reasonable, I think. Obviously
> I'll be starting a full balance now.
FWIW, the balance should reduce the data total quite a bit, to 141-ish GiB
(might be 142 or 145, but it should definitely come down from 219 GiB),
because the spread between total and used is relatively high, now, and balance
is what's used to bring that back down.
Metadata total will probably come down a bit as well, to 3.00 GiB or so.
What's going on there is this: Btrfs allocates and deallocates data and
metadata in two stages. First it allocates chunks, 1 GiB in size for
data, 256 MiB in size for metadata, but because metadata is dup by default
it allocates two chunks so half a GiB at a time, there. Then the actual
file data and metadata can be written into the pre-allocated chunks, filling
them up. As they near full, more chunks will be allocated from the
unallocated pool as necessary.
But on file deletion, btrfs only automatically handles the file
data/metadata level; it doesn't (yet) automatically deallocate the chunks,
nor can it change the allocation from say a data chunk to a metadata chunk.
So when a chunk is allocated, it stays allocated.
That's the spread you see in btrfs filesystem df, between total and used,
for each chunk type.
The way to recover those allocated but unused chunks to the unallocated
pool, so they can be reallocated between data and metadata as necessary,
is with a balance. That balance, therefore, should reduce the spread
seen in the above between total and used.
Meanwhile, btrfs filesystem df shows the spread between allocated and
used for each type, but what about unallocated? Simple. Btrfs
filesystem show lists total filesystem size as well as allocated
usage for each device. (The total line is something else, I recommend
ignoring it as it's simply confusing. Only pay attention to the
individual device lines.)
Thus, to get a proper picture of the space usage status on a btrfs
filesystem, you must have both the btrfs filesystem show and
btrfs filesystem df output for that filesystem, show to tell
you how much of the total space is chunk-allocated for each device,
df to tell you what those allocations are, and how much of the
chunk-allocated space is actually used, for each allocation type.
It's wise to keep track of the show output in particular, and
when the spread between used (allocated) and total for each
device gets low, under a few GiB, check btrfs fi df and see
what's using that space unnecessarily and then do a balance
to recover it, if possible.
--
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
next prev parent reply other threads:[~2014-07-22 3:26 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-19 15:26 ENOSPC errors during balance Marc Joliet
2014-07-19 17:38 ` Chris Murphy
2014-07-19 21:06 ` Piotr Szymaniak
2014-07-20 2:39 ` Duncan
2014-07-20 10:22 ` Marc Joliet
2014-07-20 11:40 ` Marc Joliet
2014-07-20 19:44 ` Marc Joliet
2014-07-21 2:41 ` Duncan
2014-07-21 13:22 ` Marc Joliet
2014-07-21 22:30 ` Marc Joliet
2014-07-21 23:30 ` Marc Joliet
2014-07-22 3:26 ` Duncan [this message]
2014-07-22 7:37 ` Marc Joliet
2014-07-20 12:59 ` Duncan
2014-07-21 11:01 ` Brendan Hide
-- strict thread matches above, loose matches on Subject: below --
2014-07-19 20:10 Fw: " Marc Joliet
2014-07-19 20:58 ` Marc Joliet
2014-07-20 0:53 ` Chris Murphy
2014-07-20 9:50 ` Marc Joliet
2014-07-20 1:11 ` Chris Murphy
2014-07-20 9:48 ` Marc Joliet
2014-07-20 19:46 ` Marc Joliet
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$1a441$ab255f41$47b5d104$887b5db7@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).