]>
Commit | Line | Data |
---|---|---|
3d4ecfe4 SL |
1 | From 88399b6abc07be1fcf487b7d3c87f16c7f2c9931 Mon Sep 17 00:00:00 2001 |
2 | From: Qu Wenruo <wqu@suse.com> | |
3 | Date: Tue, 26 Feb 2019 16:33:56 +0800 | |
4 | Subject: btrfs: Don't panic when we can't find a root key | |
5 | ||
6 | [ Upstream commit 7ac1e464c4d473b517bb784f30d40da1f842482e ] | |
7 | ||
8 | When we failed to find a root key in btrfs_update_root(), we just panic. | |
9 | ||
10 | That's definitely not cool, fix it by outputting an unique error | |
11 | message, aborting current transaction and return -EUCLEAN. This should | |
12 | not normally happen as the root has been used by the callers in some | |
13 | way. | |
14 | ||
15 | Reviewed-by: Filipe Manana <fdmanana@suse.com> | |
16 | Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> | |
17 | Signed-off-by: Qu Wenruo <wqu@suse.com> | |
18 | Reviewed-by: David Sterba <dsterba@suse.com> | |
19 | Signed-off-by: David Sterba <dsterba@suse.com> | |
20 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
21 | --- | |
22 | fs/btrfs/root-tree.c | 13 ++++++++----- | |
23 | 1 file changed, 8 insertions(+), 5 deletions(-) | |
24 | ||
25 | diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c | |
26 | index a44519b1897fe..7bae7cff150e9 100644 | |
27 | --- a/fs/btrfs/root-tree.c | |
28 | +++ b/fs/btrfs/root-tree.c | |
29 | @@ -148,11 +148,14 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root | |
30 | if (ret < 0) | |
31 | goto out; | |
32 | ||
33 | - if (ret != 0) { | |
34 | - btrfs_print_leaf(path->nodes[0]); | |
35 | - btrfs_crit(fs_info, "unable to update root key %llu %u %llu", | |
36 | - key->objectid, key->type, key->offset); | |
37 | - BUG_ON(1); | |
38 | + if (ret > 0) { | |
39 | + btrfs_crit(fs_info, | |
40 | + "unable to find root key (%llu %u %llu) in tree %llu", | |
41 | + key->objectid, key->type, key->offset, | |
42 | + root->root_key.objectid); | |
43 | + ret = -EUCLEAN; | |
44 | + btrfs_abort_transaction(trans, ret); | |
45 | + goto out; | |
46 | } | |
47 | ||
48 | l = path->nodes[0]; | |
49 | -- | |
50 | 2.20.1 | |
51 |