]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
btrfs: raid56: allocate memory separately for rbio pointers
authorQu Wenruo <wqu@suse.com>
Mon, 10 Oct 2022 10:36:09 +0000 (18:36 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 5 Dec 2022 17:00:38 +0000 (18:00 +0100)
commit797d74b749850a5b81c47560caec26e00e7e3768
treee21f4bb9eea86c348440dc0cf9df66a3ce0fe926
parentff2b64a22a2efcc087520e94ad06b005268a5f9d
btrfs: raid56: allocate memory separately for rbio pointers

Currently inside alloc_rbio(), we allocate a larger memory to contain
the following members:

- struct btrfs_raid_rbio itself
- stripe_pages array
- bio_sectors array
- stripe_sectors array
- finish_pointers array

Then update rbio pointers to point the extra space after the rbio
structure itself.

Thus it introduced a complex CONSUME_ALLOC() macro to help the thing.

This is too hacky, and is going to make later pointers expansion harder.

This patch will change it to use regular kcalloc() for each pointer
inside btrfs_raid_bio, making the later expansion much easier.

And introduce a helper free_raid_bio_pointers() to free up all the
pointer members in btrfs_raid_bio, which will be used in both
free_raid_bio() and error path of alloc_rbio().

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