diff options
author | Boris Burkov <boris@bur.io> | 2025-05-07 12:42:24 -0700 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2025-05-12 21:39:13 +0200 |
commit | a0fd1c6098633f9a95fc2f636383546c82b704c3 (patch) | |
tree | 4e995fd5e704e6b700023f6cefe0f3491a0ecd77 /lib/mpi/mpi-mpow.c | |
parent | 54db6d1bdd71fa90172a2a6aca3308bbf7fa7eb5 (diff) |
btrfs: fix folio leak in submit_one_async_extent()
If btrfs_reserve_extent() fails while submitting an async_extent for a
compressed write, then we fail to call free_async_extent_pages() on the
async_extent and leak its folios. A likely cause for such a failure
would be btrfs_reserve_extent() failing to find a large enough
contiguous free extent for the compressed extent.
I was able to reproduce this by:
1. mount with compress-force=zstd:3
2. fallocating most of a filesystem to a big file
3. fragmenting the remaining free space
4. trying to copy in a file which zstd would generate large compressed
extents for (vmlinux worked well for this)
Step 4. hits the memory leak and can be repeated ad nauseam to
eventually exhaust the system memory.
Fix this by detecting the case where we fallback to uncompressed
submission for a compressed async_extent and ensuring that we call
free_async_extent_pages().
Fixes: 131a821a243f ("btrfs: fallback if compressed IO fails for ENOSPC")
CC: stable@vger.kernel.org # 6.1+
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Co-developed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Boris Burkov <boris@bur.io>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'lib/mpi/mpi-mpow.c')
0 files changed, 0 insertions, 0 deletions