btrfs: do not BUG_ON() on failure to update inode when setting xattr
authorFilipe Manana <fdmanana@suse.com>
Thu, 21 Apr 2022 10:03:09 +0000 (11:03 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 May 2022 10:30:18 +0000 (12:30 +0200)
commit74b9abc46862aa82606893afaef4d01f4bc9cf8d
tree09a2a812021d8ad03c997e5dfafbb48fd3b2a42c
parentb79815c35416ca8860dc3062a0f9591d772e94ba
btrfs: do not BUG_ON() on failure to update inode when setting xattr

commit 193b4e83986d7ee6caa8ceefb5ee9f58240fbee0 upstream.

We are doing a BUG_ON() if we fail to update an inode after setting (or
clearing) a xattr, but there's really no reason to not instead simply
abort the transaction and return the error to the caller. This should be
a rare error because we have previously reserved enough metadata space to
update the inode and the delayed inode should have already been setup, so
an -ENOSPC or -ENOMEM, which are the possible errors, are very unlikely to
happen.

So replace the BUG_ON()s with a transaction abort.

CC: stable@vger.kernel.org # 4.9+
Reviewed-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Filipe Manana <fdmanana@suse.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/xattr.c