* [PATCH] btrfs: do not BUG_ON() on failure to update inode when setting xattr
@ 2022-04-21 10:03 fdmanana
2022-04-21 10:20 ` Qu Wenruo
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: fdmanana @ 2022-04-21 10:03 UTC (permalink / raw)
To: linux-btrfs
From: Filipe Manana <fdmanana@suse.com>
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.
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
fs/btrfs/xattr.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c
index f9d22ff3567f..4a2a5cb1c202 100644
--- a/fs/btrfs/xattr.c
+++ b/fs/btrfs/xattr.c
@@ -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);
@@ -401,7 +402,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);
--
2.35.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] btrfs: do not BUG_ON() on failure to update inode when setting xattr
2022-04-21 10:03 [PATCH] btrfs: do not BUG_ON() on failure to update inode when setting xattr fdmanana
@ 2022-04-21 10:20 ` Qu Wenruo
2022-04-21 11:51 ` Anand Jain
2022-04-21 15:05 ` David Sterba
2 siblings, 0 replies; 4+ messages in thread
From: Qu Wenruo @ 2022-04-21 10:20 UTC (permalink / raw)
To: fdmanana, linux-btrfs
On 2022/4/21 18:03, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
>
> 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.
>
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> fs/btrfs/xattr.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c
> index f9d22ff3567f..4a2a5cb1c202 100644
> --- a/fs/btrfs/xattr.c
> +++ b/fs/btrfs/xattr.c
> @@ -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);
> @@ -401,7 +402,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);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] btrfs: do not BUG_ON() on failure to update inode when setting xattr
2022-04-21 10:03 [PATCH] btrfs: do not BUG_ON() on failure to update inode when setting xattr fdmanana
2022-04-21 10:20 ` Qu Wenruo
@ 2022-04-21 11:51 ` Anand Jain
2022-04-21 15:05 ` David Sterba
2 siblings, 0 replies; 4+ messages in thread
From: Anand Jain @ 2022-04-21 11:51 UTC (permalink / raw)
To: fdmanana, linux-btrfs
On 21/04/2022 18:03, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
>
> 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.
>
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
> ---
> fs/btrfs/xattr.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c
> index f9d22ff3567f..4a2a5cb1c202 100644
> --- a/fs/btrfs/xattr.c
> +++ b/fs/btrfs/xattr.c
> @@ -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);
> @@ -401,7 +402,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);
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Thanks, Anand
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] btrfs: do not BUG_ON() on failure to update inode when setting xattr
2022-04-21 10:03 [PATCH] btrfs: do not BUG_ON() on failure to update inode when setting xattr fdmanana
2022-04-21 10:20 ` Qu Wenruo
2022-04-21 11:51 ` Anand Jain
@ 2022-04-21 15:05 ` David Sterba
2 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2022-04-21 15:05 UTC (permalink / raw)
To: fdmanana; +Cc: linux-btrfs
On Thu, Apr 21, 2022 at 11:03:09AM +0100, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
>
> 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.
>
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
Added to misc-next, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-04-21 15:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-21 10:03 [PATCH] btrfs: do not BUG_ON() on failure to update inode when setting xattr fdmanana
2022-04-21 10:20 ` Qu Wenruo
2022-04-21 11:51 ` Anand Jain
2022-04-21 15:05 ` David Sterba
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.