• Qu Wenruo's avatar
    btrfs: qgroup: iterate qgroups without memory allocation for qgroup_reserve() · 686c4a5a
    Qu Wenruo authored
    Qgroup heavily relies on ulist to go through all the involved
    qgroups, but since we're using ulist inside fs_info->qgroup_lock
    spinlock, this means we're doing a lot of GFP_ATOMIC allocations.
    
    This patch reduces the GFP_ATOMIC usage for qgroup_reserve() by
    eliminating the memory allocation completely.
    
    This is done by moving the needed memory to btrfs_qgroup::iterator
    list_head, so that we can put all the involved qgroup into a on-stack
    list, thus eliminating the need to allocate memory while holding
    spinlock.
    
    The only cost is the slightly higher memory usage, but considering the
    reduce GFP_ATOMIC during a hot path, it should still be acceptable.
    
    Function qgroup_reserve() is the perfect start point for this
    conversion.
    Reviewed-by: default avatarBoris Burkov <boris@bur.io>
    Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    686c4a5a
qgroup.c 116 KB