xref: /openbmc/linux/fs/btrfs/extent-tree.h (revision 9d5dbfe0)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 #ifndef BTRFS_EXTENT_TREE_H
4 #define BTRFS_EXTENT_TREE_H
5 
6 enum btrfs_inline_ref_type {
7 	BTRFS_REF_TYPE_INVALID,
8 	BTRFS_REF_TYPE_BLOCK,
9 	BTRFS_REF_TYPE_DATA,
10 	BTRFS_REF_TYPE_ANY,
11 };
12 
13 int btrfs_get_extent_inline_ref_type(const struct extent_buffer *eb,
14 				     struct btrfs_extent_inline_ref *iref,
15 				     enum btrfs_inline_ref_type is_data);
16 u64 hash_extent_data_ref(u64 root_objectid, u64 owner, u64 offset);
17 
18 int btrfs_add_excluded_extent(struct btrfs_fs_info *fs_info,
19 			      u64 start, u64 num_bytes);
20 void btrfs_free_excluded_extents(struct btrfs_block_group *cache);
21 int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans, unsigned long count);
22 void btrfs_cleanup_ref_head_accounting(struct btrfs_fs_info *fs_info,
23 				  struct btrfs_delayed_ref_root *delayed_refs,
24 				  struct btrfs_delayed_ref_head *head);
25 int btrfs_lookup_data_extent(struct btrfs_fs_info *fs_info, u64 start, u64 len);
26 int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
27 			     struct btrfs_fs_info *fs_info, u64 bytenr,
28 			     u64 offset, int metadata, u64 *refs, u64 *flags);
29 int btrfs_pin_extent(struct btrfs_trans_handle *trans, u64 bytenr, u64 num,
30 		     int reserved);
31 int btrfs_pin_extent_for_log_replay(struct btrfs_trans_handle *trans,
32 				    u64 bytenr, u64 num_bytes);
33 int btrfs_exclude_logged_extents(struct extent_buffer *eb);
34 int btrfs_cross_ref_exist(struct btrfs_root *root,
35 			  u64 objectid, u64 offset, u64 bytenr, bool strict,
36 			  struct btrfs_path *path);
37 struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans,
38 					     struct btrfs_root *root,
39 					     u64 parent, u64 root_objectid,
40 					     const struct btrfs_disk_key *key,
41 					     int level, u64 hint,
42 					     u64 empty_size,
43 					     enum btrfs_lock_nesting nest);
44 void btrfs_free_tree_block(struct btrfs_trans_handle *trans,
45 			   u64 root_id,
46 			   struct extent_buffer *buf,
47 			   u64 parent, int last_ref);
48 int btrfs_alloc_reserved_file_extent(struct btrfs_trans_handle *trans,
49 				     struct btrfs_root *root, u64 owner,
50 				     u64 offset, u64 ram_bytes,
51 				     struct btrfs_key *ins);
52 int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans,
53 				   u64 root_objectid, u64 owner, u64 offset,
54 				   struct btrfs_key *ins);
55 int btrfs_reserve_extent(struct btrfs_root *root, u64 ram_bytes, u64 num_bytes,
56 			 u64 min_alloc_size, u64 empty_size, u64 hint_byte,
57 			 struct btrfs_key *ins, int is_data, int delalloc);
58 int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
59 		  struct extent_buffer *buf, int full_backref);
60 int btrfs_dec_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
61 		  struct extent_buffer *buf, int full_backref);
62 int btrfs_set_disk_extent_flags(struct btrfs_trans_handle *trans,
63 				struct extent_buffer *eb, u64 flags, int level);
64 int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_ref *ref);
65 
66 int btrfs_free_reserved_extent(struct btrfs_fs_info *fs_info,
67 			       u64 start, u64 len, int delalloc);
68 int btrfs_pin_reserved_extent(struct btrfs_trans_handle *trans, u64 start, u64 len);
69 int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans);
70 int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans, struct btrfs_ref *generic_ref);
71 int __must_check btrfs_drop_snapshot(struct btrfs_root *root, int update_ref,
72 				     int for_reloc);
73 int btrfs_drop_subtree(struct btrfs_trans_handle *trans,
74 			struct btrfs_root *root,
75 			struct extent_buffer *node,
76 			struct extent_buffer *parent);
77 
78 #endif
79