]> git.hungrycats.org Git - linux/commit
btrfs: zstd: prevent leak of workspace below maximum level
authorFilipe Manana <fdmanana@suse.com>
Wed, 28 Oct 2026 16:06:27 +0000 (16:06 +0000)
committerDavid Sterba <dsterba@suse.com>
Fri, 30 Oct 2026 20:36:19 +0000 (21:36 +0100)
commita1cffaf0ef93d2a8a58d32deee7b07a0403c259a
treec6c1d23f15ea36eb37c883ba2c1b121d16114e87
parentf750b1dd48985d6cdfbdb6c458d3c2cafe9ed8fe
btrfs: zstd: prevent leak of workspace below maximum level

When putting a workspace we always protect the workspace for the maximum
level from reclaim, since it can be used not just for that level but as
well for any level below it. However the logic is flawed because if we do
the put for a workspace at level 10 for example (maximum is level 15) and
there is currently no idle workspace for the maximum level because all
are currently being used, we don't add the workspace to the LRU list and
that can result in leaking it if we don't get more compression or
decompression requests for level 10 or any level below 10.

Fix this by skipping the addition to the LRU list only if the level of
the workspace matches the maximum level too (besides the list of idle
workspaces for the maximum level being empty).

Fixes: 3f93aef535c8 ("btrfs: add zstd compression level support")
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/zstd.c