Currently kernel doesn not allow to delete non-empty qgroups
A qgroup can only be empty after fully dropped and a transaction is committed
Things like drop_subtree_threshold or other operations can mark qgroup inconsistent and skip accounting
The option --delete-qgroup has been removed but the same can happen with btrfs qgroup destroy as it's the same implementation by an ioctl.
We need to catch the conditions preventing the deletion and warn, or add options that will try to do the right thing at some cost, like waiting until the subvolume is cleaned.
Removing a stale qgroup may not succeed for several reasons:
https://lore.kernel.org/linux-btrfs/fa8f65936f31c07ca4783229140ecfb1f7ada785.1714082499.git.wqu@suse.com/ :
The option --delete-qgroup has been removed but the same can happen with
btrfs qgroup destroy
as it's the same implementation by an ioctl.We need to catch the conditions preventing the deletion and warn, or add options that will try to do the right thing at some cost, like waiting until the subvolume is cleaned.