All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: [PATCH 09/25] btrfs: remove BUG_ON(!eie) in find_parent_nodes
Date: Fri,  5 Nov 2021 16:45:35 -0400	[thread overview]
Message-ID: <21a64e8283e1d7567aff82e07826e8631d6123c1.1636144971.git.josef@toxicpanda.com> (raw)
In-Reply-To: <cover.1636144971.git.josef@toxicpanda.com>

If we're looking for leafs that point to a data extent we want to record
the extent items that point at our bytenr.  At this point we have the
reference and we know for a fact that this leaf should have a reference
to our bytenr.  However if there's some sort of corruption we may not
find any references to our leaf, and thus could end up with eie == NULL.
Replace this BUG_ON() with an ASSERT() and then return -EUCLEAN for the
mortals.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/backref.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index 7d942f5d6443..72ca4334186c 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -1359,10 +1359,18 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans,
 				goto out;
 			if (!ret && extent_item_pos) {
 				/*
-				 * we've recorded that parent, so we must extend
-				 * its inode list here
+				 * We've recorded that parent, so we must extend
+				 * its inode list here.
+				 *
+				 * However if there was corruption we may not
+				 * have found an eie, return an error in this
+				 * case.
 				 */
-				BUG_ON(!eie);
+				ASSERT(eie);
+				if (!eie) {
+					ret = -EUCLEAN;
+					goto out;
+				}
 				while (eie->next)
 					eie = eie->next;
 				eie->next = ref->inode_list;
-- 
2.26.3


  parent reply	other threads:[~2021-11-05 20:46 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-05 20:45 [PATCH 00/25] btrfs: extent tree v2 prep work for global roots Josef Bacik
2021-11-05 20:45 ` [PATCH 01/25] btrfs: kill BTRFS_FS_BARRIER Josef Bacik
2021-11-18 11:50   ` David Sterba
2021-11-05 20:45 ` [PATCH 02/25] btrfs: rework async transaction committing Josef Bacik
2021-11-18 12:12   ` David Sterba
2021-11-23 17:19     ` David Sterba
2021-11-05 20:45 ` [PATCH 03/25] btrfs: pass fs_info to trace_btrfs_transaction_commit Josef Bacik
2021-11-05 20:45 ` [PATCH 04/25] btrfs: remove trans_handle->root Josef Bacik
2021-11-05 20:45 ` [PATCH 05/25] btrfs: pass the root to add_keyed_refs Josef Bacik
2021-11-05 20:45 ` [PATCH 06/25] btrfs: move comment in find_parent_nodes() Josef Bacik
2021-11-05 20:45 ` [PATCH 07/25] btrfs: remove SANITY_TESTS check form find_parent_nodes Josef Bacik
2021-11-05 20:45 ` [PATCH 08/25] btrfs: remove BUG_ON() in find_parent_nodes() Josef Bacik
2021-11-23 20:53   ` Nikolay Borisov
2021-11-23 21:35     ` Josef Bacik
2021-11-05 20:45 ` Josef Bacik [this message]
2021-11-05 20:45 ` [PATCH 10/25] btrfs: add a btrfs_block_group_root() helper Josef Bacik
2021-11-05 20:45 ` [PATCH 11/25] btrfs: make remove_extent_backref pass the root Josef Bacik
2021-11-05 20:45 ` [PATCH 12/25] btrfs: use chunk_root in find_free_extent_update_loop Josef Bacik
2021-11-25 10:11   ` Nikolay Borisov
2021-11-05 20:45 ` [PATCH 13/25] btrfs: do not special case the extent root for switch commit roots Josef Bacik
2021-11-05 20:45 ` [PATCH 14/25] btrfs: remove unnecessary extent root check in btrfs_defrag_leaves Josef Bacik
2021-11-05 20:45 ` [PATCH 15/25] btrfs: don't use the extent root in btrfs_chunk_alloc_add_chunk_item Josef Bacik
2021-11-05 20:45 ` [PATCH 16/25] btrfs: don't use extent_root in iterate_extent_inodes Josef Bacik
2021-11-05 20:45 ` [PATCH 17/25] btrfs: don't use the extent_root in flush_space Josef Bacik
2021-11-05 20:45 ` [PATCH 18/25] btrfs: init root block_rsv at init root time Josef Bacik
2021-11-05 20:45 ` [PATCH 19/25] btrfs: stop accessing ->extent_root directly Josef Bacik
2021-11-05 20:45 ` [PATCH 20/25] btrfs: fix csum assert to check objectid of the root Josef Bacik
2021-11-05 20:45 ` [PATCH 21/25] btrfs: set BTRFS_FS_STATE_NO_CSUMS if we fail to load the csum root Josef Bacik
2021-11-25 15:05   ` Nikolay Borisov
2021-11-05 20:45 ` [PATCH 22/25] btrfs: stop accessing ->csum_root directly Josef Bacik
2021-11-05 20:45 ` [PATCH 23/25] btrfs: stop accessing ->free_space_root directly Josef Bacik
2021-11-05 20:45 ` [PATCH 24/25] btrfs: remove useless WARN_ON in record_root_in_trans Josef Bacik
2021-11-05 20:45 ` [PATCH 25/25] btrfs: track the csum, extent, and free space trees in a rb tree Josef Bacik
2021-11-18 12:22   ` David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=21a64e8283e1d7567aff82e07826e8631d6123c1.1636144971.git.josef@toxicpanda.com \
    --to=josef@toxicpanda.com \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.