Skip to content

Commit ace33eb

Browse files
boryaskdave
authored andcommitted
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 <[email protected]> Reviewed-by: Filipe Manana <[email protected]> Signed-off-by: Boris Burkov <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 09abde4 commit ace33eb

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

fs/btrfs/free-space-tree.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,8 @@ int btrfs_convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans,
218218

219219
bitmap_size = free_space_bitmap_size(fs_info, block_group->length);
220220
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;
226223

227224
start = block_group->start;
228225
end = block_group->start + block_group->length;
@@ -361,11 +358,8 @@ int btrfs_convert_free_space_to_extents(struct btrfs_trans_handle *trans,
361358

362359
bitmap_size = free_space_bitmap_size(fs_info, block_group->length);
363360
bitmap = alloc_bitmap(bitmap_size);
364-
if (unlikely(!bitmap)) {
365-
ret = -ENOMEM;
366-
btrfs_abort_transaction(trans, ret);
367-
goto out;
368-
}
361+
if (unlikely(!bitmap))
362+
return 0;
369363

370364
start = block_group->start;
371365
end = block_group->start + block_group->length;

0 commit comments

Comments
 (0)