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

There is a kernel regression caused by commit e15e9f43c7ca ("btrfs:
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 <>
Reviewed-by: Filipe Manana <>
Reviewed-by: Anand Jain <>
Signed-off-by: Anand Jain <>
2 files changed