• Qu Wenruo's avatar
    btrfs: raid56: allocate memory separately for rbio pointers · 797d74b7
    Qu Wenruo authored
    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: default avatarQu Wenruo <wqu@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    797d74b7
raid56.c 72.1 KB