]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
btrfs: handle root deletion lookup error in btrfs_del_root()
authorDavid Sterba <dsterba@suse.com>
Tue, 23 Jan 2024 22:19:19 +0000 (23:19 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 4 Mar 2024 15:24:47 +0000 (16:24 +0100)
We're deleting a root and looking it up by key does not succeed, this
is an inconsistent state and we can't do anything. All callers handle
errors and abort a transaction.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/root-tree.c

index 3f6d10eb1aafca9054d175f69e123f0dd06d0b76..ce831660550bfd117c27ca6a4cf8f6a0695b6728 100644 (file)
@@ -322,8 +322,11 @@ int btrfs_del_root(struct btrfs_trans_handle *trans,
        ret = btrfs_search_slot(trans, root, key, path, -1, 1);
        if (ret < 0)
                goto out;
-
-       BUG_ON(ret != 0);
+       if (ret != 0) {
+               /* The root must exist but we did not find it by the key. */
+               ret = -EUCLEAN;
+               goto out;
+       }
 
        ret = btrfs_del_item(trans, root, path);
 out: