From: Leszek Dubiel <leszek@dubiel.pl>
To: linux-btrfs@vger.kernel.org
Subject: Re: enospc errors during balance — how to prevent out of space
Date: Mon, 29 Apr 2024 23:05:34 +0200 [thread overview]
Message-ID: <df6e9442-2144-462a-b339-1b385a1324ba@dubiel.pl> (raw)
In-Reply-To: <909ed27.f7893fdf.18f020ff6fc@tnonline.net>
Final report for "no space" and balancing.
I write it for maybe it will help someone.
My problem was identical to this one:
https://superuser.com/questions/1573030/cannot-repair-btrfs-partition-because-there-is-too-little-space-left
While mounting it went "read only" because of errors:
errs: wr: 0, rd 0, flush 0, corrupt: 35967, gen 0
"No space left failed to recover relocation"
space_info: metadata ... is full
On "read only" you cannot add more devices, you canot finish balance.
Tried to repair system — no errors.
It was done on terminal, co I uploaded photos here:
https://postimg.cc/gallery/09dzGRG
Finally I have cleared disks and start to rebuild system from scratch.
Balancing script reworked to start balancing earlier and slower,
then go faster:
findmnt --types btrfs --output SOURCE --nofsroot --noheadings |
sort | uniq |
while read dev; do
# mount point
mnt=$(findmnt --source "$dev" --output TARGET --first-only
--noheadings)
test -d "$mnt" || continue
# lowest unallocated space from all disks in btrfs filesystem
una=$(
btrfs dev usage "$mnt" -g |
sed -nr 's/.*Unallocated: +([0-9]+)\.[0-9]{2}GiB.*/\1/; T; p' |
sort -n | head -n1
)
echo -n "$una" | tr -c "[[:print:]]" "#" | grep -Eq '^[0-9]+$'
|| continue
# if lots of unallocated space do nothing
if test "$una" -ge 32; then
: # do nothing
# if going low, then optimize "dusage" slowly
elif test "$una" -ge 16; then
seq --format "-dusage=%g,limit=2" 0 20 100
elif test "$una" -ge 8; then
seq --format "-dusage=%g,limit=3" 0 10 100
# if critically low, then balnace both "dusage" and "musage"
else
seq --format "-dusage=%g,limit=4" 0 10 100
seq --format "-musage=%g,limit=1" 0 10 100
fi |
# balance for options above until any extents rellocated
while read opt; do
btrfs balance start "$opt" "$mnt" 2>&1 |
grep -Eq "Done, had to relocate [1-9][0-9]* out of [0-9]+
chunks" &&
# if relocated, then get out of two loops for next "$dev"
break 2
done
done
prev parent reply other threads:[~2024-04-29 21:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-16 6:09 enospc errors during balance — how to prevent out of space Leszek Dubiel
2024-04-16 7:54 ` HAN Yuwei
2024-04-16 15:17 ` Leszek Dubiel
2024-04-16 17:00 ` Forza
2024-04-16 20:07 ` Leszek Dubiel
2024-04-21 19:09 ` Forza
2024-04-21 19:52 ` Leszek Dubiel
2024-04-27 12:03 ` Leszek Dubiel
2024-04-29 21:05 ` Leszek Dubiel [this message]
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=df6e9442-2144-462a-b339-1b385a1324ba@dubiel.pl \
--to=leszek@dubiel.pl \
--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).