btrfs: check qgroup doesn't crash when beyond limit
authorQu Wenruo <wqu@suse.com>
Tue, 12 Jan 2021 07:40:24 +0000 (15:40 +0800)
committerEryu Guan <guaneryu@gmail.com>
Sun, 17 Jan 2021 15:11:16 +0000 (23:11 +0800)
commit0e195a4ca997436f4237cb6d21edefb6db1f93d7
tree5963ea154f3d9f02ba8a0ae8ededcca7b77f3fac
parentd6dafbf074d3b66e8104f228d95790a93e3b8b13
btrfs: check qgroup doesn't crash when beyond limit

There is a bug that, when btrfs is beyond qgroup limit, touching a file
could crash btrfs.

Such beyond limit situation needs to be intentionally created, e.g.
writing 1GiB file, then limit the subvolume to 512 MiB.
As current qgroup works pretty well at preventing us from reaching the
limit.

This makes existing qgroup test cases unable to detect it.

The regression is introduced by commit c53e9653605d ("btrfs: qgroup:
try to flush qgroup space when we get -EDQUOT"), and the fix is
commit 6f23277a49e6 ("btrfs: qgroup: don't commit transaction when
we already hold the handle")

Link: https://bugzilla.suse.com/show_bug.cgi?id=1178634
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
tests/btrfs/230 [new file with mode: 0755]
tests/btrfs/230.out [new file with mode: 0644]
tests/btrfs/group