btrfs: fix insert_reserved error handling
authorJosef Bacik <josef@toxicpanda.com>
Thu, 11 Oct 2018 19:54:22 +0000 (15:54 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 13 Nov 2018 19:12:58 +0000 (11:12 -0800)
commit13d6628c019d7d3ddd749d09ffb4152ae0ad8e8b
tree2daba0a93d7342e8f285fe969279f5a64b456cce
parent68c7db7c8f76e80d2128da46249561208f51d988
btrfs: fix insert_reserved error handling

commit 80ee54bfe8a3850015585ebc84e8d207fcae6831 upstream.

We were not handling the reserved byte accounting properly for data
references.  Metadata was fine, if it errored out the error paths would
free the bytes_reserved count and pin the extent, but it even missed one
of the error cases.  So instead move this handling up into
run_one_delayed_ref so we are sure that both cases are properly cleaned
up in case of a transaction abort.

CC: stable@vger.kernel.org # 4.18+
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/extent-tree.c