]> www.infradead.org Git - users/jedix/linux-maple.git/commit
btrfs: scrub: aggregate small bitmaps into a larger one
authorQu Wenruo <wqu@suse.com>
Mon, 5 May 2025 10:03:47 +0000 (19:33 +0930)
committerDavid Sterba <dsterba@suse.com>
Thu, 15 May 2025 12:30:55 +0000 (14:30 +0200)
commit1b660424a6f33da62c2aa03d21dd1cf4cb39a692
treef0b540f6de172b3ce8c3dd7855add003e2711f19
parentf2c19541e421b3235efc515dad88b581f00592ae
btrfs: scrub: aggregate small bitmaps into a larger one

Currently we have several small bitmaps inside scrub_stripe:

- extent_sector_bitmap
- error_bitmap
- io_error_bitmap
- csum_error_bitmap
- meta_error_bitmap
- meta_gen_error_bitmap

All those bitmaps are at most 16 bits long, but unsigned long is
either 32 or 64 (more common) bits.

This means we're wasting 1/2 or 3/4 space for each bitmap.

And we can have 128 scrub_stripe for each device, such wasted space adds up
quickly.

Instead of using a single unsigned long for each bitmap, aggregate them
into a larger bitmap, just like what we're doing for subpage support.

This reduces 24 bytes from each scrub_stripe structure on x86_64
systems.

This will need a lot of macros converting direct bitmap/bit operations into
our scrub_stripe specific helpers, but all those helpers are very small
and can be inlined.

So overall the overhead shouldn't be that huge, and we save quite some
memory space.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/scrub.c