]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
btrfs: remove BUG_ON(!eie) in find_parent_nodes
authorJosef Bacik <josef@toxicpanda.com>
Fri, 5 Nov 2021 20:45:35 +0000 (16:45 -0400)
committerPaolo Pisati <paolo.pisati@canonical.com>
Fri, 28 Jan 2022 10:02:52 +0000 (11:02 +0100)
BugLink: https://bugs.launchpad.net/bugs/1959376
[ Upstream commit 9f05c09d6baef789726346397438cca4ec43c3ee ]

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>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
fs/btrfs/backref.c

index 6b4b0f105a5724c5121fd18d375852b8a5ab7b21..8b090c40daf773f5e1d6473ad6939a11f190e238 100644 (file)
@@ -1365,10 +1365,18 @@ again:
                                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;