btrfs: qgroup: avoid memory allocation if qgroups are not enabled
authorFilipe Manana <fdmanana@suse.com>
Thu, 26 Jun 2025 15:57:02 +0000 (16:57 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Jul 2025 21:58:04 +0000 (23:58 +0200)
commit6633a416ed64aeb5c0a971d091d598b144739886
tree7d843078c80cf3afc1b541231b5a3d04bd646d56
parent2fda07effb6f1069b59e93b71c820a6794a703a2
btrfs: qgroup: avoid memory allocation if qgroups are not enabled

At btrfs_qgroup_inherit() we allocate a qgroup record even if qgroups are
not enabled, which is unnecessary overhead and can result in subvolume
creation to fail with -ENOMEM, as create_subvol() calls this function.

Improve on this by making btrfs_qgroup_inherit() check if qgroups are
enabled earlier and return if they are not, avoiding the unnecessary
memory allocation and taking some locks.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/qgroup.c