diff options
author | David Sterba <dsterba@suse.com> | 2024-01-23 23:19:19 +0100 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2024-03-04 16:24:47 +0100 |
commit | 0fe29838ba0aee39a7bca46bb47e7ca348a9e161 (patch) | |
tree | 345cba16e8a235561c8c060d99769d575ea15aec /fs/btrfs/root-tree.c | |
parent | btrfs: handle block group lookup error when it's being removed (diff) | |
download | linux-0fe29838ba0aee39a7bca46bb47e7ca348a9e161.tar.xz linux-0fe29838ba0aee39a7bca46bb47e7ca348a9e161.zip |
btrfs: handle root deletion lookup error in btrfs_del_root()
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>
Diffstat (limited to 'fs/btrfs/root-tree.c')
-rw-r--r-- | fs/btrfs/root-tree.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c index 3f6d10eb1aaf..ce831660550b 100644 --- a/fs/btrfs/root-tree.c +++ b/fs/btrfs/root-tree.c @@ -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: |