btrfs: validate inconsitent qgroup won't leak reserved data space

There is a kernel regression caused by commit e15e9f43c7ca ("btrfs:
introduce BTRFS_QGROUP_RUNTIME_FLAG_NO_ACCOUNTING to skip qgroup
accounting"), where if qgroup is inconsistent (not that hard to trigger)
btrfs would leak its qgroup data reserved space, and cause a warning at
unmount time.

The test case would verify the behavior by:

- Enable qgroup first

- Intentionally mark qgroup inconsistent
  This is done by taking a snapshot and assign it to a higher level
  qgroup, meanwhile the source has no higher level qgroup.

- Trigger a large enough write to cause qgroup data space leak

- Unmount and check the dmesg for the qgroup rsv leak warning

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
2 files changed