]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
btrfs: replace BUG_ON() with error return in cache_save_setup()
authorTeng Liu <27rabbitlt@gmail.com>
Sat, 28 Mar 2026 06:40:59 +0000 (07:40 +0100)
committerDavid Sterba <dsterba@suse.com>
Tue, 7 Apr 2026 16:56:08 +0000 (18:56 +0200)
commit30d537f723d6f37a8ddfb17fe668bb9808f5b49f
tree19c61c8c04a34bc96c8d00b7b5b78da2e6f263e8
parentf0d3b4c7b82b6bc8bf23be58150d49ecc51ec897
btrfs: replace BUG_ON() with error return in cache_save_setup()

In cache_save_setup(), if create_free_space_inode() succeeds but the
subsequent lookup_free_space_inode() still fails on retry, the
BUG_ON(retries) will crash the kernel. This can happen due to I/O
errors or transient failures, not just programming bugs.

Replace the BUG_ON with proper error handling that returns the original
error code through the existing cleanup path. The callers already handle
this gracefully: disk_cache_state defaults to BTRFS_DC_ERROR, so the
space cache simply won't be written for that block group.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Teng Liu <27rabbitlt@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/block-group.c