From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH v2 0/3] btrfs: unbalanced disks aware per-profile available space estimation
Date: Wed, 4 Feb 2026 13:24:05 +1030 [thread overview]
Message-ID: <cover.1770173615.git.wqu@suse.com> (raw)
[CHANGELOG]
v2:
- Various grammar fixes
- Fix a u64 division compiling error on ppc64
Which requires the dedicated div_u64() helper.
- Ignore unallocated space that's too small
If the unallocated space is not enough to even cover a single stripe
(64K), don't utilize it.
This makes the behavior more aligned to the chunk allocator, and
prevent over-estimation.
- Use U64_MAX to mark the per-profile estimation as unavailable
This reduce the memory usage by one unsigned long.
- Update the commit message of the 2nd patch
To include the overhead (runtime of btrfs_update_per_profile_avail())
in the commit message.
- Minor comment cleanup on the term "balloon"
The old term "balloon" is no longer utilized and there is a typo.
("ballon" -> "balloon").
- Update the estimation examples in the first patch
As we allows 2 disks raid5 and 3 disks raid6.
v1:
- Revive from the v5.9 era fix
- Make btrfs_update_per_profile_avail() to not return error
Instead just mark all profiles as unavailable, and
btrfs_get_per_profile_avail() will return false.
The caller will need to fallback to the existing factor based
estimation.
This greatly simplified the error handling, which is a pain point in
the original series.
- Remove a lot of refactor/cleanup
As that's already done in upstream.
- Only make calc_available_free_space() to use the new infrastructure
That's the main goal, fix can_over_commit().
Further enhancement can be done later.
There is a long known bug that if metadata is using RAID1 on two
unbalanced disks, btrfs have a very high chance to hit -ENOSPC during
critical paths and flips RO.
The bug dates back to v5.9 (where my last updates ends) and the most
recent bug report is from Christoph.
The idea to fix it is always here, by providing a chunk-allocator-like
available space estimation.
It doesn't need to be as heavy as chunk allocator, but at least it
should not over-estimate.
The demon is always in the details, the previous v5.9 era series
requires a lot of changes in error handling, because the
btrfs_update_per_profile_avail() can fail at critical paths in chunk
allocation/removal and device grow/shrink/add/removal.
But this time that function will no longer fail, but just mark
per-profile available estimation as unreliable, and let the caller to
fallback to the old factor based solution.
In the real world it should not be a big deal, as the only error is
-ENOMEM, but this greatly simplifies the error handling.
Qu Wenruo (3):
btrfs: introduce the device layout aware per-profile available space
btrfs: update per-profile available estimation
btrfs: use per-profile available space in calc_available_free_space()
fs/btrfs/space-info.c | 27 ++++---
fs/btrfs/volumes.c | 183 +++++++++++++++++++++++++++++++++++++++++-
fs/btrfs/volumes.h | 34 ++++++++
3 files changed, 231 insertions(+), 13 deletions(-)
--
2.52.0
next reply other threads:[~2026-02-04 2:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-04 2:54 Qu Wenruo [this message]
2026-02-04 2:54 ` [PATCH v2 1/3] btrfs: introduce the device layout aware per-profile available space Qu Wenruo
2026-02-04 15:41 ` Filipe Manana
2026-02-08 15:59 ` Chris Mason
2026-02-08 20:57 ` Qu Wenruo
2026-02-04 2:54 ` [PATCH v2 2/3] btrfs: update per-profile available estimation Qu Wenruo
2026-02-13 1:15 ` kernel test robot
2026-02-13 4:24 ` Qu Wenruo
2026-02-04 2:54 ` [PATCH v2 3/3] btrfs: use per-profile available space in calc_available_free_space() Qu Wenruo
2026-02-04 15:42 ` [PATCH v2 0/3] btrfs: unbalanced disks aware per-profile available space estimation Filipe Manana
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=cover.1770173615.git.wqu@suse.com \
--to=wqu@suse.com \
--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