Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Teng Liu and committed by
David Sterba
30d537f7 f0d3b4c7

+7 -1
+7 -1
fs/btrfs/block-group.c
··· 3381 3381 } 3382 3382 3383 3383 if (IS_ERR(inode)) { 3384 - BUG_ON(retries); 3384 + if (retries) { 3385 + ret = PTR_ERR(inode); 3386 + btrfs_err(fs_info, 3387 + "failed to lookup free space inode after creation for block group %llu: %d", 3388 + block_group->start, ret); 3389 + goto out_free; 3390 + } 3385 3391 retries++; 3386 3392 3387 3393 if (block_group->ro)