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: ignore ENOMEM from alloc_bitmap()

btrfs_convert_free_space_to_bitmaps() and
btrfs_convert_free_space_to_extents() both allocate a bitmap struct
with:

bitmap_size = free_space_bitmap_size(fs_info, block_group->length);
bitmap = alloc_bitmap(bitmap_size);
if (!bitmap) {
ret = -ENOMEM;
btrfs_abort_transaction(trans);
return ret;
}

This conversion is done based on a heuristic and the check triggers each
time we call update_free_space_extent_count() on a block group (each
time we add/remove an extent or modify a bitmap). Furthermore, nothing
relies on maintaining some invariant of bitmap density, it's just an
optimization for space usage. Therefore, it is safe to simply ignore
any memory allocation errors that occur, rather than aborting the
transaction and leaving the fs read only.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Boris Burkov <boris@bur.io>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>

authored by

Boris Burkov and committed by
David Sterba
828ec765 ac3fd01e

+4 -10
+4 -10
fs/btrfs/free-space-tree.c
··· 218 218 219 219 bitmap_size = free_space_bitmap_size(fs_info, block_group->length); 220 220 bitmap = alloc_bitmap(bitmap_size); 221 - if (unlikely(!bitmap)) { 222 - ret = -ENOMEM; 223 - btrfs_abort_transaction(trans, ret); 224 - goto out; 225 - } 221 + if (unlikely(!bitmap)) 222 + return 0; 226 223 227 224 start = block_group->start; 228 225 end = block_group->start + block_group->length; ··· 358 361 359 362 bitmap_size = free_space_bitmap_size(fs_info, block_group->length); 360 363 bitmap = alloc_bitmap(bitmap_size); 361 - if (unlikely(!bitmap)) { 362 - ret = -ENOMEM; 363 - btrfs_abort_transaction(trans, ret); 364 - goto out; 365 - } 364 + if (unlikely(!bitmap)) 365 + return 0; 366 366 367 367 start = block_group->start; 368 368 end = block_group->start + block_group->length;