lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20260204151757.GU26902@twin.jikos.cz>
Date: Wed, 4 Feb 2026 16:17:57 +0100
From: David Sterba <dsterba@...e.cz>
To: Jiasheng Jiang <jiashengjiangcool@...il.com>
Cc: boris@....io, clm@...com, dsterba@...e.com, fdmanana@...nel.org,
	linux-btrfs@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v5] btrfs: reset block group size class when it becomes
 empty

On Wed, Jan 14, 2026 at 01:13:38AM +0000, Jiasheng Jiang wrote:
> Differential analysis of block-group.c shows an inconsistency in how
> block group size classes are managed.
> 
> Currently, btrfs_use_block_group_size_class() sets a block group's size
> class to specialize it for a specific allocation size. However, this
> size class remains "stale" even if the block group becomes completely
> empty (both used and reserved bytes reach zero).
> 
> This happens in two scenarios:
> 1. When space reservations are freed (e.g., due to errors or transaction
>    aborts) via btrfs_free_reserved_bytes().
> 2. When the last extent in a block group is freed via
>    btrfs_update_block_group().
> 
> While size classes are advisory, a stale size class can cause
> find_free_extent to unnecessarily skip candidate block groups during
> initial search loops. This undermines the purpose of size classes—to
> reduce fragmentation—by keeping block groups restricted to a specific
> size class when they could be reused for any size.
> 
> Fix this by resetting the size class to BTRFS_BG_SZ_NONE whenever a
> block group's used and reserved counts both reach zero. This ensures
> that empty block groups are fully available for any allocation size in
> the next cycle.
> 
> Signed-off-by: Jiasheng Jiang <jiashengjiangcool@...il.com>

Added to for-next, thanks.

> v4 -> v5:
> 1. Remove the Fixes tag.

I've added the tag back as I think it may make sense to backport it.

> +static void btrfs_maybe_reset_size_class(struct btrfs_block_group *cache)

Renamed 'cache' to 'bg' as the cache was from old code where it was
referring to the in memory cache of block groups, while the object we
care about is the block group.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ