fstests: btrfs: Add reserved space leak check for rewrite dirty page
authorQu Wenruo <quwenruo@cn.fujitsu.com>
Mon, 21 Sep 2015 03:06:18 +0000 (13:06 +1000)
committerDave Chinner <david@fromorbit.com>
Mon, 21 Sep 2015 03:06:18 +0000 (13:06 +1000)
commit04188a67ae65b58a36bcaf84433a37921bb44a48
tree7cf51572839dbe4f06cc7371edce069c3a962432
parentdbbaa6d4bcea986bf7678be63b071efe52d92292
fstests: btrfs: Add reserved space leak check for rewrite dirty page

Btrfs qgroup reserve codes lacks check for rewrite dirty page, causing
every write, even rewriting a uncommitted dirty page, to reserve space.

But only written data will free the reserved space, causing reserved
space leaking.

The bug exists almost from the beginning of btrfs qgroup codes, but
nobody found it.

For example:

1)Write [0, 12K) into file A
  reserve 12K space

File A:
0 4K 8K 12K
|<--------dirty-------->|
reserved: 12K

2)Write [0,4K) into file A
0 4K 8K 12K
|<--------dirty-------->|
reserved: 16K <<< Should be 12K

3) Commit transaction
Dirty pages [0,12) written to disk.
Free 12K reserved space.
reserved: 4K <<< Should be 0

This testcase will test such problem.
Kernel fix will need some huge change, so won't be soon.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
tests/btrfs/099 [new file with mode: 0755]
tests/btrfs/099.out [new file with mode: 0644]
tests/btrfs/group