]> git.ipfire.org Git - thirdparty/linux.git/commit
btrfs: ignore ENOMEM from alloc_bitmap()
authorBoris Burkov <boris@bur.io>
Tue, 23 Sep 2025 17:57:02 +0000 (10:57 -0700)
committerDavid Sterba <dsterba@suse.com>
Mon, 24 Nov 2025 17:29:28 +0000 (18:29 +0100)
commit828ec765f7968c636c4c163c050ad13da959adef
treedb99858560c9b6dd719a5c0a723559730571eb46
parentac3fd01e4c1efce8f2c054cdeb2ddd2fc0fb150d
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>
fs/btrfs/free-space-tree.c