]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: Fix quota reservation leak on preallocated files
authorJustin Maggard <jmaggard10@gmail.com>
Mon, 30 Oct 2017 22:29:10 +0000 (15:29 -0700)
committerDavid Sterba <dsterba@suse.com>
Wed, 6 Dec 2017 23:28:12 +0000 (00:28 +0100)
commit471fa20526cda98dd5e3e81fc7ce8b0c2a37f254
treeca2af23f06f099dadbf6b58524e9a45e5025496c
parentc75601e93bf4ea09a776fe8dec62b975a5a2aad9
btrfs: Fix quota reservation leak on preallocated files

Commit 6d36299c289d ("Btrfs: don't do nocow check unless we have to")
changed the behavior of __btrfs_buffered_write() so that it first tries
to get a data space reservation, and then skips the relatively expensive
nocow check if the reservation succeeded.

If we have quotas enabled, the data space reservation also includes a
quota reservation.  But in the rewrite case, the space has already been
accounted for in qgroups.  So btrfs_check_data_free_space() increases
the quota reservation, but it never gets decreased when the data
actually gets written and overwrites the pre-existing data.  So we're
left with both the qgroup and qgroup reservation accounting for the same
space.

This commit adds the missing btrfs_qgroup_free_data() call in the case
of BTRFS_ORDERED_PREALLOC extents.

Fixes: 6d36299c289d ("Btrfs: don't do nocow check unless we have to")
Signed-off-by: Justin Maggard <jmaggard@netgear.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/inode.c