btrfs: remove BUG_ON() in find_parent_nodes()
authorJosef Bacik <josef@toxicpanda.com>
Fri, 5 Nov 2021 20:45:34 +0000 (16:45 -0400)
committerDavid Sterba <dsterba@suse.com>
Mon, 3 Jan 2022 14:09:47 +0000 (15:09 +0100)
We search for an extent entry with .offset = -1, which shouldn't be a
thing, but corruption happens.  Add an ASSERT() for the developers,
return -EUCLEAN for mortals.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/backref.c

index cebdb75..01e1a08 100644 (file)
@@ -1210,7 +1210,12 @@ again:
        ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
        if (ret < 0)
                goto out;
-       BUG_ON(ret == 0);
+       if (ret == 0) {
+               /* This shouldn't happen, indicates a bug or fs corruption. */
+               ASSERT(ret != 0);
+               ret = -EUCLEAN;
+               goto out;
+       }
 
        if (trans && likely(trans->type != __TRANS_DUMMY) &&
            time_seq != BTRFS_SEQ_LAST) {