FAILED: patch "[PATCH] btrfs: do not BUG_ON() on failure to update inode when" failed to apply to 5.10-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 193b4e83986d7ee6caa8ceefb5ee9f58240fbee0 Mon Sep 17 00:00:00 2001
From: Filipe Manana <[email protected]>
Date: Thu, 21 Apr 2022 11:03:09 +0100
Subject: [PATCH] btrfs: do not BUG_ON() on failure to update inode when
setting xattr
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.
fs/btrfs/xattr.c +4 -2
@@ -262,7 +262,8 @@ int btrfs_setxattr_trans(struct inode *inode, const char *name,inode_inc_iversion (inode); inode->i_ctime =current_time (inode); ret =btrfs_update_inode (trans, root,BTRFS_I (inode)); -BUG_ON (ret); +if (ret) +btrfs_abort_transaction (trans, ret); out:if (start_trans)btrfs_end_transaction (trans);
@@ -416,7 +417,8 @@ static int btrfs_xattr_handler_set_prop(const struct xattr_handler *handler,inode_inc_iversion (inode); inode->i_ctime =current_time (inode); ret =btrfs_update_inode (trans, root,BTRFS_I (inode)); -BUG_ON (ret); +if (ret) +btrfs_abort_transaction (trans, ret); }btrfs_end_transaction (trans);