btrfs: handle errors while updating refcounts in update_ref_for_cow
authorJeff Mahoney <jeffm@suse.com>
Tue, 21 Nov 2017 18:58:49 +0000 (13:58 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 14 Dec 2017 08:52:54 +0000 (09:52 +0100)
commita121ecb3764e84da656b8d20138997f2fd6aed6f
tree3079616a35a6e4f3af27495ad519854797c6f8d6
parent85ab61fdfa4866cd0465c75fb97a0601fed9973d
btrfs: handle errors while updating refcounts in update_ref_for_cow

commit 692826b2738101549f032a761a9191636e83be4e upstream.

Since commit fb235dc06fa (btrfs: qgroup: Move half of the qgroup
accounting time out of commit trans) the assumption that
btrfs_add_delayed_{data,tree}_ref can only return 0 or -ENOMEM has
been false.  The qgroup operations call into btrfs_search_slot
and friends and can now return the full spectrum of error codes.

Fortunately, the fix here is easy since update_ref_for_cow failing
is already handled so we just need to bail early with the error
code.

Fixes: fb235dc06fa (btrfs: qgroup: Move half of the qgroup accounting ...)
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Reviewed-by: Edmund Nadolski <enadolski@suse.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/ctree.c