linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: replace the BUG_ON() in btrfs_del_root_ref() with proper error handling
@ 2021-12-01 11:56 Qu Wenruo
  2021-12-01 16:48 ` Josef Bacik
  2021-12-07 19:25 ` David Sterba
  0 siblings, 2 replies; 3+ messages in thread
From: Qu Wenruo @ 2021-12-01 11:56 UTC (permalink / raw)
  To: linux-btrfs

I hit the BUG_ON() with generic/475 test case, and to my surprise, all
callers of btrfs_del_root_ref() are already aborting transaction, thus
there is not need for such BUG_ON(), just go to @out label and caller
will properly handle the error.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 fs/btrfs/root-tree.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c
index aa2809796c0e..3d68d2dcd83e 100644
--- a/fs/btrfs/root-tree.c
+++ b/fs/btrfs/root-tree.c
@@ -334,7 +334,8 @@ int btrfs_del_root_ref(struct btrfs_trans_handle *trans, u64 root_id,
 	key.offset = ref_id;
 again:
 	ret = btrfs_search_slot(trans, tree_root, &key, path, -1, 1);
-	BUG_ON(ret < 0);
+	if (ret < 0)
+		goto out;
 	if (ret == 0) {
 		leaf = path->nodes[0];
 		ref = btrfs_item_ptr(leaf, path->slots[0],
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: replace the BUG_ON() in btrfs_del_root_ref() with proper error handling
  2021-12-01 11:56 [PATCH] btrfs: replace the BUG_ON() in btrfs_del_root_ref() with proper error handling Qu Wenruo
@ 2021-12-01 16:48 ` Josef Bacik
  2021-12-07 19:25 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: Josef Bacik @ 2021-12-01 16:48 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: linux-btrfs

On Wed, Dec 01, 2021 at 07:56:17PM +0800, Qu Wenruo wrote:
> I hit the BUG_ON() with generic/475 test case, and to my surprise, all
> callers of btrfs_del_root_ref() are already aborting transaction, thus
> there is not need for such BUG_ON(), just go to @out label and caller
> will properly handle the error.
> 
> Signed-off-by: Qu Wenruo <wqu@suse.com>

Reviewed-by: Josef Bacik <josef@toxicpanda.com>

Thanks,

Josef

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: replace the BUG_ON() in btrfs_del_root_ref() with proper error handling
  2021-12-01 11:56 [PATCH] btrfs: replace the BUG_ON() in btrfs_del_root_ref() with proper error handling Qu Wenruo
  2021-12-01 16:48 ` Josef Bacik
@ 2021-12-07 19:25 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2021-12-07 19:25 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: linux-btrfs

On Wed, Dec 01, 2021 at 07:56:17PM +0800, Qu Wenruo wrote:
> I hit the BUG_ON() with generic/475 test case, and to my surprise, all
> callers of btrfs_del_root_ref() are already aborting transaction, thus
> there is not need for such BUG_ON(), just go to @out label and caller
> will properly handle the error.
> 
> Signed-off-by: Qu Wenruo <wqu@suse.com>

Added to misc-next, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-12-07 19:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-01 11:56 [PATCH] btrfs: replace the BUG_ON() in btrfs_del_root_ref() with proper error handling Qu Wenruo
2021-12-01 16:48 ` Josef Bacik
2021-12-07 19:25 ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).