]> git.hungrycats.org Git - linux/commit
btrfs: update per-profile available estimation
authorQu Wenruo <wqu@suse.com>
Wed, 4 Feb 2026 02:54:07 +0000 (13:24 +1030)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Mon, 2 Nov 2026 02:04:15 +0000 (21:04 -0500)
commit7540f13f399886f395c8668a3f971afcb4ce5232
tree668763205dfaa838bcd0277e30dd42826514635a
parent7907c2fc76478d911b82bc6bc7839c12a1e4af6d
btrfs: update per-profile available estimation

This involves the following timing:

- Chunk allocation
- Chunk removal
- After Mount
- New device
- Device removal
- Device shrink
- Device enlarge

And since the function btrfs_update_per_profile_avail() will not return
an error, this won't cause new error handling path.

Although when btrfs_update_per_profile_avail() failed (only ENOSPC
possible) it will mark the per-profile available estimation as
unreliable, so later btrfs_get_per_profile_avail() will return false and
require the caller to have a fallback solution.

The function btrfs_update_per_profile_avail() will be executed with
chunk_mutex hold, thus it will slightly slow down those involved
functions, but not a lot.

As all the core workload is just various u64 calculations inside a loop,
without any tree search, the overhead should be acceptable even for all
supported 9 profiles.

For 4 disks (which exercises all 9 profiles), the execution time of that
function will still be less than 10 us.

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
(cherry picked from commit c84053d9f7f758c79320716caa098cafc70a74da)
fs/btrfs/volumes.c