diff options
author | Qu Wenruo <wqu@suse.com> | 2020-06-24 18:02:55 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-09-07 20:57:27 -0400 |
commit | 75b0817babe733ecf8d503c3ecce371e9991ca76 (patch) | |
tree | 9d8fa004e9265b872cb2ce9df1e2f49c15bf1d87 /fs/btrfs/ctree.h | |
parent | b1f0067aba5cc51540922e4187d5e8c8f77b1431 (diff) | |
download | u-boot-75b0817babe733ecf8d503c3ecce371e9991ca76.tar.gz u-boot-75b0817babe733ecf8d503c3ecce371e9991ca76.tar.xz u-boot-75b0817babe733ecf8d503c3ecce371e9991ca76.zip |
fs: btrfs: Crossport read_tree_block() from btrfs-progs
This is the one of the basic stone function for btrfs, which:
- Resolves the chunk mappings
- Reads data from disk
- Does various sanity check
With read_tree_block(), we can finally crossport needed btrfs btree
operations to U-Boot.
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Marek BehĂșn <marek.behun@nic.cz>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r-- | fs/btrfs/ctree.h | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index c746d3fd45..7f024c0145 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -59,6 +59,16 @@ static inline unsigned long btrfs_chunk_item_size(int num_stripes) #define BTRFS_MAX_EXTENT_SIZE SZ_128M +enum btrfs_tree_block_status { + BTRFS_TREE_BLOCK_CLEAN, + BTRFS_TREE_BLOCK_INVALID_NRITEMS, + BTRFS_TREE_BLOCK_INVALID_PARENT_KEY, + BTRFS_TREE_BLOCK_BAD_KEY_ORDER, + BTRFS_TREE_BLOCK_INVALID_LEVEL, + BTRFS_TREE_BLOCK_INVALID_FREE_SPACE, + BTRFS_TREE_BLOCK_INVALID_OFFSETS, +}; + struct btrfs_device; struct btrfs_fs_devices; struct btrfs_fs_info { @@ -88,6 +98,35 @@ struct btrfs_fs_info { u32 stripesize; }; +static inline u32 BTRFS_MAX_ITEM_SIZE(const struct btrfs_fs_info *info) +{ + return BTRFS_LEAF_DATA_SIZE(info) - sizeof(struct btrfs_item); +} + +static inline u32 BTRFS_NODEPTRS_PER_BLOCK(const struct btrfs_fs_info *info) +{ + return BTRFS_LEAF_DATA_SIZE(info) / sizeof(struct btrfs_key_ptr); +} + +static inline u32 BTRFS_NODEPTRS_PER_EXTENT_BUFFER(const struct extent_buffer *eb) +{ + BUG_ON(eb->fs_info && eb->fs_info->nodesize != eb->len); + return __BTRFS_LEAF_DATA_SIZE(eb->len) / sizeof(struct btrfs_key_ptr); +} + +#define BTRFS_FILE_EXTENT_INLINE_DATA_START \ + (offsetof(struct btrfs_file_extent_item, disk_bytenr)) +static inline u32 BTRFS_MAX_INLINE_DATA_SIZE(const struct btrfs_fs_info *info) +{ + return BTRFS_MAX_ITEM_SIZE(info) - + BTRFS_FILE_EXTENT_INLINE_DATA_START; +} + +static inline u32 BTRFS_MAX_XATTR_SIZE(const struct btrfs_fs_info *info) +{ + return BTRFS_MAX_ITEM_SIZE(info) - sizeof(struct btrfs_dir_item); +} + /* * File system states */ @@ -1149,7 +1188,7 @@ struct btrfs_root { u64 root_dirid; }; -int btrfs_comp_keys(struct btrfs_key *, struct btrfs_key *); +int __btrfs_comp_keys(struct btrfs_key *, struct btrfs_key *); int btrfs_comp_keys_type(struct btrfs_key *, struct btrfs_key *); int btrfs_bin_search(union btrfs_tree_node *, struct btrfs_key *, int *); void btrfs_free_path(struct btrfs_path *); @@ -1209,4 +1248,13 @@ const char *btrfs_super_csum_name(u16 csum_type); u16 btrfs_csum_type_size(u16 csum_type); size_t btrfs_super_num_csums(void); +/* ctree.c */ +int btrfs_comp_cpu_keys(const struct btrfs_key *k1, const struct btrfs_key *k2); +enum btrfs_tree_block_status +btrfs_check_node(struct btrfs_fs_info *fs_info, + struct btrfs_disk_key *parent_key, struct extent_buffer *buf); +enum btrfs_tree_block_status +btrfs_check_leaf(struct btrfs_fs_info *fs_info, + struct btrfs_disk_key *parent_key, struct extent_buffer *buf); +int btrfs_leaf_free_space(struct extent_buffer *leaf); #endif /* __BTRFS_CTREE_H__ */ |