Commit 7ac1e464 authored by Qu Wenruo's avatar Qu Wenruo Committed by David Sterba

btrfs: Don't panic when we can't find a root key

When we failed to find a root key in btrfs_update_root(), we just panic.

That's definitely not cool, fix it by outputting an unique error
message, aborting current transaction and return -EUCLEAN. This should
not normally happen as the root has been used by the callers in some
way.
Reviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent c53839fc
...@@ -137,11 +137,14 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root ...@@ -137,11 +137,14 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
goto out; goto out;
} }
if (ret != 0) { if (ret > 0) {
btrfs_print_leaf(path->nodes[0]); btrfs_crit(fs_info,
btrfs_crit(fs_info, "unable to update root key %llu %u %llu", "unable to find root key (%llu %u %llu) in tree %llu",
key->objectid, key->type, key->offset); key->objectid, key->type, key->offset,
BUG_ON(1); root->root_key.objectid);
ret = -EUCLEAN;
btrfs_abort_transaction(trans, ret);
goto out;
} }
l = path->nodes[0]; l = path->nodes[0];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment