public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: "Swâmi Petaramesh" <swami@petaramesh.org>,
	"'linux-btrfs@vger.kernel.org'" <linux-btrfs@vger.kernel.org>
Subject: Re: Kernel 5.4 - BTRFS FS shows full with about 600 GB Free ?
Date: Sun, 22 Dec 2019 16:12:02 +0800	[thread overview]
Message-ID: <dd37e99c-e087-2b6d-830a-96811b337ba2@gmx.com> (raw)
In-Reply-To: <e743df15-4830-8d83-bc36-6ddd33c1e720@petaramesh.org>



On 2019/12/22 下午3:55, Swâmi Petaramesh wrote:
> Hi again,
>
> Le 21/12/2019 à 13:00, Qu Wenruo a écrit :
>> A known regression introduced in v5.4.
>>
>> The new metadata over-commit behavior conflicts with an existing check
>> in btrfs_statfs().
>> It is completely a runtime false behavior, and had*no*  other bad effect.
>
> I'm painfully unable to understand how the same said « metadata
> over-commit » would allow, on my system, “df” to work properly on some
> filesystems and fail miserably on others.

Here comes the full explanation if you like tech details:

For v5.4, btrfs allows reserved metadata space to go beyond current
metadata free space, as long as the fs can allocate enough metadata.

E.g you have a 1T fs, with 2G metadata (SINGLE) chunks allocated.
And among all these 2G metadata chunks, you have 1G unused space.

In v5.4, btrfs is allowed to reserve extra metadata space, near (1T -
1G). Since btrfs knows we can allocate new metadata chunks for (1T -
2G). And we also have 1G free metadata space.

However, in btrfs_statfs(), there is a check to ensure we have at least
4M free space in allocated metadata chunks.
If that condition can't be met, then btrfs_statfs() return f_bavail = 0,
indicating no available space.

That check is from 2015, which is kinda OK at that time, but definitely
not works with the new over-commit behavior.

So if you have enough uncommitted metadata, that check will be triggered
and suddenly returns 0 available space, even 1 sec early you still get
tons of available space.


>
> AND show “100% full” filesystems with still more than 600 GB free...
> That would make quite much of an overcommit isn't it ?
>
> So I wonder if there isn't something else or if the “overcommit”
> calculation is not really completely broke in the first place...

It's the old check from 2015 completely broken with 2019 new behavior.

If you really want to dig into the code, please check btrfs_statfs() of
fs/btrfs/super.c.

        if (!mixed && total_free_meta - thresh < block_rsv->size)
                buf->f_bavail = 0;

Which is explained in my patch mentioned in previous reply.

Thanks,
Qu

>
> ॐ
>

  reply	other threads:[~2019-12-22  8:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-21 10:59 Kernel 5.4 - BTRFS FS shows full with about 600 GB Free ? Swâmi Petaramesh
2019-12-21 12:00 ` Qu Wenruo
2019-12-21 12:07   ` Swâmi Petaramesh
2019-12-21 12:16     ` Qu Wenruo
     [not found]       ` <cbbfe8a4-ff7b-4bea-313c-e1acbf9ee61a@petaramesh.org>
2019-12-21 12:53         ` Qu Wenruo
2019-12-21 12:19   ` Swâmi Petaramesh
2019-12-22  7:55   ` Swâmi Petaramesh
2019-12-22  8:12     ` Qu Wenruo [this message]
2019-12-22  9:00       ` Swâmi Petaramesh
2019-12-22  9:22         ` Swâmi Petaramesh
2019-12-22  9:37         ` Qu Wenruo
2019-12-22 10:15           ` Swâmi Petaramesh

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=dd37e99c-e087-2b6d-830a-96811b337ba2@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=swami@petaramesh.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