• Qu Wenruo's avatar
    btrfs: qgroup: pre-allocate btrfs_qgroup to reduce GFP_ATOMIC usage · 8d54518b
    Qu Wenruo authored
    Qgroup is the heaviest user of GFP_ATOMIC, but one call site does not
    really need GFP_ATOMIC, that is add_qgroup_rb().
    
    That function only searches the rbtree to find if we already have such
    entry.  If not, then it would try to allocate memory for it.
    
    This means we can afford to pre-allocate such structure unconditionally,
    then free the memory if it's not needed.
    
    Considering this function is not a hot path, only utilized by the
    following functions:
    
    - btrfs_qgroup_inherit()
      For "btrfs subvolume snapshot -i" option.
    
    - btrfs_read_qgroup_config()
      At mount time, and we're ensured there would be no existing rb tree
      entry for each qgroup.
    
    - btrfs_create_qgroup()
    
    Thus we're completely safe to pre-allocate the extra memory for btrfs_qgroup
    structure, and reduce unnecessary GFP_ATOMIC usage.
    Reviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
    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>
    8d54518b
qgroup.c 115 KB