From: Christoph Hellwig <hch@lst.de>
To: Boris Burkov <boris@bur.io>
Cc: Christoph Hellwig <hch@lst.de>,
Johannes Thumshirn <johannes.thumshirn@wdc.com>,
linux-btrfs@vger.kernel.org, Filipe Manana <fdmanana@suse.com>,
David Sterba <dsterba@suse.com>,
Hans Holmberg <Hans.Holmberg@wdc.com>,
Damien Le Moal <dlemoal@kernel.org>,
Naohiro Aota <naohiro.aota@wdc.com>
Subject: Re: [PATCH 5/7] btrfs: zoned: subtract zone_unusable space in statfs
Date: Mon, 18 May 2026 07:52:31 +0200 [thread overview]
Message-ID: <20260518055231.GA10154@lst.de> (raw)
In-Reply-To: <20260515210511.GA2887949@zen.localdomain>
On Fri, May 15, 2026 at 02:05:11PM -0700, Boris Burkov wrote:
> > The only different between f_bavail and f_bfree is reservations for
> > the superuser, which IIRC only extN do on Linux.
> >
> > f_bavail is all the space you as a user could potentially use on
> > the file system (modulo quota restrictions).
>
> I think it would be great to discuss this in more detail. The whole
> "reservations for the superuser" thing never made a huge amount of sense
> to me, and feels sort of under-specified.
It is, and the fact that most file systems never implemented it probably
means it isn't very relevant. Buf if you're interested in you should
probably ping Ted or Al.
> I take it to spiritually mean "space allocated to other crap definitely
> needed to do your data allocation anyway". So in btrfs that would
> mean something like "an estimate of how much metadata you would need for
> the remaining space"?
I don't really unnderstand what you mean here, and how it would relate
to reservations for the root user. Remember that these definitions are
from a time where there was very little dynamic metadata, and the size
of it was trivial to estimate. Basically just directory entries with
a tiny overhead over the file name, and indirect blocks for file data.
> Returning to the actual implementation and this concrete question:
>
> AIUI, we calculate f_bavail as unaware of any stranded metadata space
> we could free up by running a 'btrfs balance start -m', for example.
> Furthermore, there is a discontinuity to zero in edge cases when
> potential space for metadata is exhausted even if there is still space
> allocated for data.
>
> So I think Johannes's change certainly fits with that (and the raid
> aware) nature of the bavail calculation.
>
> On the other hand, given that the zone reclaiming is guaranteed to
> happen automatically, I can see how it could be treated differently,
> though, unlike the metadata balancing. But if we made metadata
> balancing happen automatically in a flusher, we would need to change
> f_bavail to count stranded metadata space too?
the bfree/bavail needs to fit too criteria:
1) vaguely estimate the amount of space that can still be used
on the file system
2) don't over-promise
And this patch fails on 1). Once you've filled a zoned file system
entirely with a normal non-optimize write pattern, and then delete
a lot of this again, either at once or in small increments, with this
change statfs would permanently report a value close to 0, which is
very wrong.
IFF btrfs automatically reclaimed metadata (and I think it should),
it should be treasted the same zoned data and be reported as
free/available in statfs.
next prev parent reply other threads:[~2026-05-18 5:52 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-13 12:34 [PATCH 0/7] btrfs: fixes around generic/747 on zoned filesystems Johannes Thumshirn
2026-05-13 12:34 ` [PATCH 1/7] btrfs: zoned: document RECLAIM_ZONES flush state Johannes Thumshirn
2026-05-14 14:44 ` Boris Burkov
2026-05-13 12:34 ` [PATCH 2/7] btrfs: zoned: decode 'RECLAIM_ZONES' state in tracepoints Johannes Thumshirn
2026-05-13 12:34 ` [PATCH 3/7] btrfs: zoned: always set data_relocation_bg Johannes Thumshirn
2026-05-14 5:42 ` Damien Le Moal
2026-05-14 14:54 ` Boris Burkov
2026-05-18 14:20 ` Johannes Thumshirn
2026-05-13 12:34 ` [PATCH 4/7] btrfs: zoned: don't account data relocation space-info in statfs free space Johannes Thumshirn
2026-05-14 5:42 ` Damien Le Moal
2026-05-15 4:38 ` Christoph Hellwig
2026-05-13 12:34 ` [PATCH 5/7] btrfs: zoned: subtract zone_unusable space in statfs Johannes Thumshirn
2026-05-14 5:43 ` Damien Le Moal
2026-05-15 4:39 ` Christoph Hellwig
2026-05-15 9:26 ` Johannes Thumshirn
2026-05-15 11:34 ` Christoph Hellwig
2026-05-15 21:05 ` Boris Burkov
2026-05-18 5:52 ` Christoph Hellwig [this message]
2026-05-13 12:34 ` [PATCH 6/7] btrfs: zoned: fix deadlock waiting for ticket during data relocation Johannes Thumshirn
2026-05-15 17:26 ` Boris Burkov
2026-05-18 13:57 ` Johannes Thumshirn
2026-05-13 12:34 ` [RFC PATCH 7/7] btrfs: zoned: add RECLAIM_ZONES and RESET_ZONES to first async reclaim loop Johannes Thumshirn
2026-05-15 18:38 ` Boris Burkov
2026-05-18 6:58 ` Johannes Thumshirn
2026-05-14 14:43 ` [PATCH 0/7] btrfs: fixes around generic/747 on zoned filesystems Boris Burkov
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=20260518055231.GA10154@lst.de \
--to=hch@lst.de \
--cc=Hans.Holmberg@wdc.com \
--cc=boris@bur.io \
--cc=dlemoal@kernel.org \
--cc=dsterba@suse.com \
--cc=fdmanana@suse.com \
--cc=johannes.thumshirn@wdc.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=naohiro.aota@wdc.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