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:08:59 +0000 (11:08 -0800)
commit186b52489a4fc6f08a9f746c9a73a57893a2e898
tree3cd6b92d936c47b472cff6917ae0ef5128dd6a64
parent5a1e9bf45a3ce2843bd3d008d07e7de05f3fe105
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