mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
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>
This commit is contained in:
committed by
David Sterba
parent
ac3fd01e4c
commit
828ec765f7
@@ -218,11 +218,8 @@ int btrfs_convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans,
|
||||
|
||||
bitmap_size = free_space_bitmap_size(fs_info, block_group->length);
|
||||
bitmap = alloc_bitmap(bitmap_size);
|
||||
if (unlikely(!bitmap)) {
|
||||
ret = -ENOMEM;
|
||||
btrfs_abort_transaction(trans, ret);
|
||||
goto out;
|
||||
}
|
||||
if (unlikely(!bitmap))
|
||||
return 0;
|
||||
|
||||
start = block_group->start;
|
||||
end = block_group->start + block_group->length;
|
||||
@@ -361,11 +358,8 @@ int btrfs_convert_free_space_to_extents(struct btrfs_trans_handle *trans,
|
||||
|
||||
bitmap_size = free_space_bitmap_size(fs_info, block_group->length);
|
||||
bitmap = alloc_bitmap(bitmap_size);
|
||||
if (unlikely(!bitmap)) {
|
||||
ret = -ENOMEM;
|
||||
btrfs_abort_transaction(trans, ret);
|
||||
goto out;
|
||||
}
|
||||
if (unlikely(!bitmap))
|
||||
return 0;
|
||||
|
||||
start = block_group->start;
|
||||
end = block_group->start + block_group->length;
|
||||
|
||||
Reference in New Issue
Block a user