]> www.infradead.org Git - users/jedix/linux-maple.git/commit
btrfs: don't BUG_ON() when unpinning extents during transaction commit
authorFilipe Manana <fdmanana@suse.com>
Tue, 22 Apr 2025 14:04:51 +0000 (15:04 +0100)
committerDavid Sterba <dsterba@suse.com>
Thu, 15 May 2025 12:30:52 +0000 (14:30 +0200)
commit25983713922494cbf823689bf4847cea3f841935
tree25782c2d386f1c3d154292574a3670061cd32f25
parentb2460c2aee9a757bf0b438dde5b5ee71afc54e44
btrfs: don't BUG_ON() when unpinning extents during transaction commit

In the final phase of a transaction commit, when unpinning extents at
btrfs_finish_extent_commit(), there's no need to BUG_ON() if we fail to
unpin an extent range. All that can happen is that we fail to return the
extent range to the in-memory free space cache, meaning no future space
allocations can reuse that extent range while the fs is mounted.

So instead return the error to the caller and make it abort the
transaction, so that the error is noticed and prevent misteriously leaking
space. We keep track of the first error we get while unpinning an extent
range and keep trying to unpin all the following extent ranges, so that
we attempt to do all discards. The transaction abort will deal with all
resource cleanups.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent-tree.c
fs/btrfs/transaction.c