btrfs: Incorrect exclusive reference number after file clone.
authorQu Wenruo <quwenruo@cn.fujitsu.com>
Mon, 4 May 2015 12:56:13 +0000 (22:56 +1000)
committerDave Chinner <david@fromorbit.com>
Mon, 4 May 2015 12:56:13 +0000 (22:56 +1000)
commitf24afad0f8cf5d6961adf901b7271fc4efa8a7a9
treedf74140f73d992b493436461b18e10ecf59e7190
parent842c5a594148dab1db9f6573090efc151aab87bf
btrfs: Incorrect exclusive reference number after file clone.

[Problem]
Since commit fcebe4562dec83b3f8d308 ("Btrfs: rework qgroup accounting"),
quota data update is delayed after delayed_ref calculation, and lacks
correct protection to detect root reference which shouldn't be counted
in current sequence number but already written into extent backref.

This makes exclusive reference not decreased correctly and give incorrect
result.

[Test procedure]
1. Create a btrfs with 3 subvolumes, quota enabled and rescanned.
2. Create a file in 1st subvolume
3. Clone the file to 2nd and 3rd subvolume
4. Sync the fs to reflect the changes in qgroup.
5. Check the qgroup data

[Expected result]
None of the subvolume has exclusive reference to the file.

[Actual result]
The first subvolume still have exclusive reference to the file.

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