Commit | Line | Data |
---|---|---|
9888c340 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
557ea5dd QW |
2 | /* |
3 | * Copyright (C) Qu Wenruo 2017. All rights reserved. | |
557ea5dd QW |
4 | */ |
5 | ||
9888c340 DS |
6 | #ifndef BTRFS_TREE_CHECKER_H |
7 | #define BTRFS_TREE_CHECKER_H | |
557ea5dd | 8 | |
27137fac CH |
9 | #include <uapi/linux/btrfs_tree.h> |
10 | ||
11 | struct extent_buffer; | |
12 | struct btrfs_chunk; | |
13 | ||
14 | /* All the extra info needed to verify the parentness of a tree block. */ | |
15 | struct btrfs_tree_parent_check { | |
16 | /* | |
17 | * The owner check against the tree block. | |
18 | * | |
19 | * Can be 0 to skip the owner check. | |
20 | */ | |
21 | u64 owner_root; | |
22 | ||
23 | /* | |
24 | * Expected transid, can be 0 to skip the check, but such skip | |
25 | * should only be utlized for backref walk related code. | |
26 | */ | |
27 | u64 transid; | |
28 | ||
29 | /* | |
30 | * The expected first key. | |
31 | * | |
32 | * This check can be skipped if @has_first_key is false, such skip | |
33 | * can happen for case where we don't have the parent node key, | |
34 | * e.g. reading the tree root, doing backref walk. | |
35 | */ | |
36 | struct btrfs_key first_key; | |
37 | bool has_first_key; | |
38 | ||
39 | /* The expected level. Should always be set. */ | |
40 | u8 level; | |
41 | }; | |
557ea5dd | 42 | |
a7b4e6c7 JB |
43 | enum btrfs_tree_block_status { |
44 | BTRFS_TREE_BLOCK_CLEAN, | |
45 | BTRFS_TREE_BLOCK_INVALID_NRITEMS, | |
46 | BTRFS_TREE_BLOCK_INVALID_PARENT_KEY, | |
47 | BTRFS_TREE_BLOCK_BAD_KEY_ORDER, | |
48 | BTRFS_TREE_BLOCK_INVALID_LEVEL, | |
49 | BTRFS_TREE_BLOCK_INVALID_FREE_SPACE, | |
50 | BTRFS_TREE_BLOCK_INVALID_OFFSETS, | |
51 | BTRFS_TREE_BLOCK_INVALID_BLOCKPTR, | |
52 | BTRFS_TREE_BLOCK_INVALID_ITEM, | |
53 | BTRFS_TREE_BLOCK_INVALID_OWNER, | |
54 | }; | |
55 | ||
924452c8 JB |
56 | /* |
57 | * Exported simply for btrfs-progs which wants to have the | |
58 | * btrfs_tree_block_status return codes. | |
59 | */ | |
60 | enum btrfs_tree_block_status __btrfs_check_leaf(struct extent_buffer *leaf); | |
c26fa931 | 61 | enum btrfs_tree_block_status __btrfs_check_node(struct extent_buffer *node); |
924452c8 | 62 | |
85d8a826 | 63 | int btrfs_check_leaf(struct extent_buffer *leaf); |
813fd1dc | 64 | int btrfs_check_node(struct extent_buffer *node); |
557ea5dd | 65 | |
ddaf1d5a | 66 | int btrfs_check_chunk_valid(struct extent_buffer *leaf, |
82fc28fb | 67 | struct btrfs_chunk *chunk, u64 logical); |
88c602ab | 68 | int btrfs_check_eb_owner(const struct extent_buffer *eb, u64 root_owner); |
2cac5af1 JB |
69 | int btrfs_verify_level_key(struct extent_buffer *eb, int level, |
70 | struct btrfs_key *first_key, u64 parent_transid); | |
82fc28fb | 71 | |
557ea5dd | 72 | #endif |