btrfs: qgroup: Use independent and accurate per inode qgroup rsv
authorQu Wenruo <wqu@suse.com>
Thu, 21 Dec 2017 05:42:04 +0000 (13:42 +0800)
committerDavid Sterba <dsterba@suse.com>
Wed, 18 Apr 2018 14:46:51 +0000 (16:46 +0200)
commitff6bc37eb7f6e7b052e50c13a480e1080b3ec07a
tree9a583583fbd29c65d866562c3f54daf6f9de445d
parenta514d63882c3d2063b21b865447266ebcb18b04c
btrfs: qgroup: Use independent and accurate per inode qgroup rsv

Unlike reservation calculation used in inode rsv for metadata, qgroup
doesn't really need to care about things like csum size or extent usage
for the whole tree COW.

Qgroups care more about net change of the extent usage.
That's to say, if we're going to insert one file extent, it will mostly
find its place in COWed tree block, leaving no change in extent usage.
Or causing a leaf split, resulting in one new net extent and increasing
qgroup number by nodesize.
Or in an even more rare case, increase the tree level, increasing qgroup
number by 2 * nodesize.

So here instead of using the complicated calculation for extent
allocator, which cares more about accuracy and no error, qgroup doesn't
need that over-estimated reservation.

This patch will maintain 2 new members in btrfs_block_rsv structure for
qgroup, using much smaller calculation for qgroup rsv, reducing false
EDQUOT.

Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
fs/btrfs/ctree.h
fs/btrfs/extent-tree.c