]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.14.123/btrfs-don-t-panic-when-we-can-t-find-a-root-key.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.14.123 / btrfs-don-t-panic-when-we-can-t-find-a-root-key.patch
CommitLineData
3d4ecfe4
SL
1From 88399b6abc07be1fcf487b7d3c87f16c7f2c9931 Mon Sep 17 00:00:00 2001
2From: Qu Wenruo <wqu@suse.com>
3Date: Tue, 26 Feb 2019 16:33:56 +0800
4Subject: btrfs: Don't panic when we can't find a root key
5
6[ Upstream commit 7ac1e464c4d473b517bb784f30d40da1f842482e ]
7
8When we failed to find a root key in btrfs_update_root(), we just panic.
9
10That's definitely not cool, fix it by outputting an unique error
11message, aborting current transaction and return -EUCLEAN. This should
12not normally happen as the root has been used by the callers in some
13way.
14
15Reviewed-by: Filipe Manana <fdmanana@suse.com>
16Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
17Signed-off-by: Qu Wenruo <wqu@suse.com>
18Reviewed-by: David Sterba <dsterba@suse.com>
19Signed-off-by: David Sterba <dsterba@suse.com>
20Signed-off-by: Sasha Levin <sashal@kernel.org>
21---
22 fs/btrfs/root-tree.c | 13 ++++++++-----
23 1 file changed, 8 insertions(+), 5 deletions(-)
24
25diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c
26index 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--
502.20.1
51