btrfs: ref-verify: handle damaged extent root tree

Syzbot hits a problem with enabled ref-verify, ignorebadroots and a
fuzzed/damaged extent tree. There's no fallback option like in other
places that can deal with it so disable the whole ref-verify as it is
just a debugging feature.

Reported-by: syzbot+9c3e0cdfbfe351b0bc0e@syzkaller.appspotmail.com
Link: https://lore.kernel.org/all/0000000000001b6052062139be1c@google.com/
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>

+8 -1
+8 -1
fs/btrfs/ref-verify.c
··· 980 980 if (!btrfs_test_opt(fs_info, REF_VERIFY)) 981 981 return 0; 982 982 983 + extent_root = btrfs_extent_root(fs_info, 0); 984 + /* If the extent tree is damaged we cannot ignore it (IGNOREBADROOTS). */ 985 + if (IS_ERR(extent_root)) { 986 + btrfs_warn(fs_info, "ref-verify: extent tree not available, disabling"); 987 + btrfs_clear_opt(fs_info->mount_opt, REF_VERIFY); 988 + return 0; 989 + } 990 + 983 991 path = btrfs_alloc_path(); 984 992 if (!path) 985 993 return -ENOMEM; 986 994 987 - extent_root = btrfs_extent_root(fs_info, 0); 988 995 eb = btrfs_read_lock_root_node(extent_root); 989 996 level = btrfs_header_level(eb); 990 997 path->nodes[level] = eb;