public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] btrfs: unbalanced disks aware per-profile available space estimation
@ 2026-02-04  2:54 Qu Wenruo
  2026-02-04  2:54 ` [PATCH v2 1/3] btrfs: introduce the device layout aware per-profile available space Qu Wenruo
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Qu Wenruo @ 2026-02-04  2:54 UTC (permalink / raw)
  To: linux-btrfs

[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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-02-13  4:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-04  2:54 [PATCH v2 0/3] btrfs: unbalanced disks aware per-profile available space estimation Qu Wenruo
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox