linux-yocto/fs/btrfs
Filipe Manana 3499dcb6c5 btrfs: fix qgroup reservation leak on failure to allocate ordered extent
[ Upstream commit 1f2889f559 ]

If we fail to allocate an ordered extent for a COW write we end up leaking
a qgroup data reservation since we called btrfs_qgroup_release_data() but
we didn't call btrfs_qgroup_free_refroot() (which would happen when
running the respective data delayed ref created by ordered extent
completion or when finishing the ordered extent in case an error happened).

So make sure we call btrfs_qgroup_free_refroot() if we fail to allocate an
ordered extent for a COW write.

Fixes: 7dbeaad0af ("btrfs: change timing for qgroup reserved space for ordered extents to fix reserved space leak")
CC: stable@vger.kernel.org # 6.1+
Reviewed-by: Boris Burkov <boris@bur.io>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-07-10 16:03:12 +02:00
..
tests btrfs: tests: allocate dummy fs_info and root in test_find_delalloc() 2024-08-29 17:33:37 +02:00
accessors.c
accessors.h btrfs: use helper sizeof_field in struct accessors 2023-08-21 14:52:13 +02:00
acl.c
acl.h
async-thread.c btrfs: use alloc_ordered_workqueue() to create ordered workqueues 2023-06-19 13:59:30 +02:00
async-thread.h btrfs: use alloc_ordered_workqueue() to create ordered workqueues 2023-06-19 13:59:30 +02:00
backref.c btrfs: drop the backref cache during relocation if we commit 2024-10-10 11:58:06 +02:00
backref.h btrfs: fix unwritten extent buffer after snapshotting a new subvolume 2023-10-23 17:17:30 +02:00
bio.c btrfs: fix a use-after-free when hitting errors inside btrfs_submit_chunk() 2024-09-04 13:28:18 +02:00
bio.h btrfs: add an ordered_extent pointer to struct btrfs_bio 2023-06-19 13:59:36 +02:00
block-group.c btrfs: get zone unusable bytes while holding lock at btrfs_reclaim_bgs_work() 2025-06-04 14:41:57 +02:00
block-group.h btrfs: add and use helper to check if block group is used 2024-02-23 09:24:47 +01:00
block-rsv.c btrfs: fix data race at btrfs_use_block_rsv() when accessing block reserve 2024-03-26 18:19:13 -04:00
block-rsv.h btrfs: fix data race at btrfs_use_block_rsv() when accessing block reserve 2024-03-26 18:19:13 -04:00
btrfs_inode.h btrfs: fix race setting file private on concurrent lseek using same fd 2024-10-04 16:29:59 +02:00
check-integrity.c btrfs: rename __btrfs_map_block to btrfs_map_block 2023-06-19 13:59:34 +02:00
check-integrity.h
compression.c btrfs: zlib: fix and simplify the inline extent decompression 2024-08-29 17:33:32 +02:00
compression.h btrfs: zlib: fix and simplify the inline extent decompression 2024-08-29 17:33:32 +02:00
ctree.c btrfs: fix use-after-free when COWing tree bock and tracing is enabled 2025-01-09 13:31:52 +01:00
ctree.h btrfs: rename and export __btrfs_cow_block() 2025-01-09 13:31:52 +01:00
defrag.c btrfs: defrag: change BUG_ON to assertion in btrfs_defrag_leaves() 2024-08-29 17:33:37 +02:00
defrag.h
delalloc-space.c btrfs: don't reserve space for checksums when writing to nocow files 2024-02-23 09:24:48 +01:00
delalloc-space.h
delayed-inode.c btrfs: change BUG_ON to assertion when checking for delayed_node root 2024-08-29 17:33:37 +02:00
delayed-inode.h btrfs: add __counted_by for struct btrfs_delayed_item and use struct_size() 2023-10-11 11:37:19 +02:00
delayed-ref.c btrfs: reinitialize delayed ref list after deleting it from the list 2024-11-14 13:19:38 +01:00
delayed-ref.h btrfs: prevent transaction block reserve underflow when starting transaction 2023-09-20 20:42:18 +02:00
dev-replace.c btrfs: don't take dev_replace rwsem on task already holding it 2024-12-14 19:59:58 +01:00
dev-replace.h
dir-item.c btrfs: fix passing 0 to ERR_PTR in btrfs_search_dir_index_item() 2024-11-01 01:58:32 +01:00
dir-item.h
discard.c btrfs: make btrfs_discard_workfn() block_group ref explicit 2025-06-04 14:41:57 +02:00
discard.h
disk-io.c btrfs: handle csum tree error with rescue=ibadroots correctly 2025-07-06 11:00:09 +02:00
disk-io.h btrfs: fix double free of anonymous device after snapshot creation failure 2024-03-06 14:48:40 +00:00
export.c btrfs: export: handle invalid inode or root reference in btrfs_get_parent() 2024-04-13 13:07:32 +02:00
export.h
extent_io.c btrfs: avoid linker error in btrfs_find_create_tree_block() 2025-06-04 14:41:57 +02:00
extent_io.h btrfs: zoned: introduce block group context to btrfs_eb_write_context 2023-08-21 14:52:19 +02:00
extent_map.c btrfs: fix wrong block_start calculation for btrfs_drop_extent_map_range() 2024-05-02 16:32:44 +02:00
extent_map.h btrfs: pass the new logical address to split_extent_map 2023-06-19 13:59:33 +02:00
extent-io-tree.c btrfs: make find_first_extent_bit() return a boolean 2023-08-21 14:52:12 +02:00
extent-io-tree.h btrfs: make find_first_extent_bit() return a boolean 2023-08-21 14:52:12 +02:00
extent-tree.c btrfs: don't BUG_ON() when 0 reference count at btrfs_lookup_extent_info() 2025-05-22 14:12:26 +02:00
extent-tree.h btrfs: do not BUG_ON() when freeing tree block after error 2024-12-09 10:32:41 +01:00
file-item.c btrfs: abort transaction on generation mismatch when marking eb as dirty 2023-11-28 17:19:35 +00:00
file-item.h btrfs: scrub: avoid unnecessary csum tree search preparing stripes 2023-08-21 14:54:48 +02:00
file.c btrfs: avoid page_lockend underflow in btrfs_punch_hole_lock_range() 2025-05-02 07:50:43 +02:00
file.h
free-space-cache.c btrfs: add cancellation points to trim loops 2024-12-14 20:00:22 +01:00
free-space-cache.h btrfs: add cancellation points to trim loops 2024-12-14 20:00:22 +01:00
free-space-tree.c btrfs: do not BUG_ON() when freeing tree block after error 2024-12-09 10:32:41 +01:00
free-space-tree.h
fs.c
fs.h btrfs: don't take dev_replace rwsem on task already holding it 2024-12-14 19:59:58 +01:00
inode-item.c btrfs: abort transaction on generation mismatch when marking eb as dirty 2023-11-28 17:19:35 +00:00
inode-item.h
inode.c btrfs: use btrfs_record_snapshot_destroy() during rmdir 2025-07-10 16:03:08 +02:00
ioctl.c btrfs: do not BUG_ON() when freeing tree block after error 2024-12-09 10:32:41 +01:00
ioctl.h
Kconfig MAINTAINERS: remove links to obsolete btrfs.wiki.kernel.org 2023-09-08 14:21:27 +02:00
locking.c btrfs: add block-group tree to lockdep classes 2023-06-19 13:59:35 +02:00
locking.h btrfs: do not block starts waiting on previous transaction commit 2023-09-08 14:10:49 +02:00
lru_cache.c
lru_cache.h
lzo.c btrfs: disable allocation warnings for compression workspaces 2023-06-19 13:59:34 +02:00
Makefile
messages.c btrfs: remove v0 extent handling 2023-08-21 14:54:48 +02:00
messages.h btrfs: remove v0 extent handling 2023-08-21 14:54:48 +02:00
misc.h minmax: add in_range() macro 2023-08-24 16:20:18 -07:00
ordered-data.c btrfs: fix qgroup reservation leak on failure to allocate ordered extent 2025-07-10 16:03:12 +02:00
ordered-data.h btrfs: add a btrfs_finish_ordered_extent helper 2023-06-19 13:59:37 +02:00
orphan.c
orphan.h
print-tree.c btrfs: avoid using fixed char array size for tree names 2024-08-14 13:58:59 +02:00
print-tree.h
props.c
props.h
qgroup.c btrfs: do not BUG_ON() when freeing tree block after error 2024-12-09 10:32:41 +01:00
qgroup.h btrfs: qgroup: iterate qgroups without memory allocation for qgroup_reserve() 2024-01-01 12:42:24 +00:00
raid56.c btrfs: scrub: avoid unnecessary csum tree search preparing stripes 2023-08-21 14:54:48 +02:00
raid56.h btrfs: raid56: remove unused BTRFS_RBIO_REBUILD_MISSING 2023-08-21 14:52:12 +02:00
rcu-string.h
ref-verify.c btrfs: ref-verify: fix use-after-free after invalid ref action 2024-12-09 10:33:01 +01:00
ref-verify.h
reflink.c btrfs: replace sb::s_blocksize by fs_info::sectorsize 2024-08-29 17:33:43 +02:00
reflink.h
relocation.c btrfs: check folio mapping after unlock in relocate_one_folio() 2025-06-04 14:42:22 +02:00
relocation.h btrfs: relocation: constify parameters where possible 2024-10-10 11:58:06 +02:00
root-tree.c btrfs: qgroup: fix qgroup prealloc rsv leak in subvolume operations 2024-04-17 11:19:33 +02:00
root-tree.h btrfs: qgroup: fix qgroup prealloc rsv leak in subvolume operations 2024-04-17 11:19:33 +02:00
scrub.c btrfs: scrub: fix a wrong error type when metadata bytenr mismatches 2025-06-19 15:28:03 +02:00
scrub.h
send.c btrfs: send: return -ENAMETOOLONG when attempting a path that is too long 2025-06-04 14:41:57 +02:00
send.h
space-info.c btrfs: do not subtract delalloc from avail bytes 2024-08-11 12:47:24 +02:00
space-info.h btrfs: zoned: fix zone_unusable accounting on making block group read-write again 2024-08-11 12:47:24 +02:00
subpage.c btrfs: subpage: fix the bitmap dump which can cause bitmap corruption 2024-10-04 16:29:59 +02:00
subpage.h btrfs: stop setting PageError in the data I/O path 2023-06-19 13:59:35 +02:00
super.c btrfs: correctly escape subvol in btrfs_show_options() 2025-04-25 10:45:47 +02:00
super.h
sysfs.c btrfs: sysfs: fix direct super block member reads 2025-01-02 10:32:11 +01:00
sysfs.h
transaction.c btrfs: fix use-after-free when attempting to join an aborted transaction 2025-02-17 09:40:02 +01:00
transaction.h btrfs: fix race between direct IO write and fsync when using same fd 2024-09-12 11:11:45 +02:00
tree-checker.c btrfs: make sure that WRITTEN is set on all metadata blocks 2025-03-28 21:59:56 +01:00
tree-checker.h btrfs: make sure that WRITTEN is set on all metadata blocks 2025-03-28 21:59:56 +01:00
tree-log.c btrfs: fix iteration of extrefs during log replay 2025-07-10 16:03:07 +02:00
tree-log.h
tree-mod-log.c btrfs: avoid tree mod log ENOMEM failures when we don't need to log 2023-06-19 13:59:38 +02:00
tree-mod-log.h
ulist.c
ulist.h
uuid-tree.c btrfs: abort transaction on generation mismatch when marking eb as dirty 2023-11-28 17:19:35 +00:00
uuid-tree.h
verity.c btrfs: convert btrfs_read_merkle_tree_page() to use a folio 2023-09-13 18:40:54 +02:00
verity.h
volumes.c btrfs: update superblock's device bytes_used when dropping chunk 2025-07-06 11:00:13 +02:00
volumes.h btrfs: split remaining space to discard in chunks 2024-10-17 15:24:37 +02:00
xattr.c btrfs: abort transaction on generation mismatch when marking eb as dirty 2023-11-28 17:19:35 +00:00
xattr.h
zlib.c btrfs: zlib: fix and simplify the inline extent decompression 2024-08-29 17:33:32 +02:00
zoned.c btrfs: zoned: fix zone finishing with missing devices 2025-04-25 10:45:30 +02:00
zoned.h btrfs: zoned: reserve zones for an active metadata/system block group 2023-08-21 14:52:19 +02:00
zstd.c btrfs: disable allocation warnings for compression workspaces 2023-06-19 13:59:34 +02:00