aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent_map.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/extent_map.h')
-rw-r--r--fs/btrfs/extent_map.h89
1 files changed, 89 insertions, 0 deletions
diff --git a/fs/btrfs/extent_map.h b/fs/btrfs/extent_map.h
new file mode 100644
index 000000000000..108944aab4bd
--- /dev/null
+++ b/fs/btrfs/extent_map.h
@@ -0,0 +1,89 @@
1#ifndef __EXTENTMAP__
2#define __EXTENTMAP__
3
4#include <linux/rbtree.h>
5
6#define EXTENT_MAP_INLINE (u64)-2
7#define EXTENT_MAP_DELALLOC (u64)-1
8
9struct extent_map_tree {
10 struct rb_root map;
11 struct rb_root state;
12 struct address_space *mapping;
13 rwlock_t lock;
14};
15
16/* note, this must start with the same fields as fs/extent_map.c:tree_entry */
17struct extent_map {
18 u64 start;
19 u64 end; /* inclusive */
20 int in_tree;
21 struct rb_node rb_node;
22 /* block_start and block_end are in bytes */
23 u64 block_start;
24 u64 block_end; /* inclusive */
25 struct block_device *bdev;
26 atomic_t refs;
27};
28
29/* note, this must start with the same fields as fs/extent_map.c:tree_entry */
30struct extent_state {
31 u64 start;
32 u64 end; /* inclusive */
33 int in_tree;
34 struct rb_node rb_node;
35 wait_queue_head_t wq;
36 atomic_t refs;
37 unsigned long state;
38 struct list_head list;
39};
40
41struct extent_buffer {
42 u64 start;
43 u64 end; /* inclusive */
44 char *addr;
45 struct page *pages[];
46};
47
48typedef struct extent_map *(get_extent_t)(struct inode *inode,
49 struct page *page,
50 size_t page_offset,
51 u64 start, u64 end,
52 int create);
53
54void extent_map_tree_init(struct extent_map_tree *tree,
55 struct address_space *mapping, gfp_t mask);
56struct extent_map *lookup_extent_mapping(struct extent_map_tree *tree,
57 u64 start, u64 end);
58int add_extent_mapping(struct extent_map_tree *tree,
59 struct extent_map *em);
60int remove_extent_mapping(struct extent_map_tree *tree, struct extent_map *em);
61int try_release_extent_mapping(struct extent_map_tree *tree, struct page *page);
62int lock_extent(struct extent_map_tree *tree, u64 start, u64 end, gfp_t mask);
63int unlock_extent(struct extent_map_tree *tree, u64 start, u64 end, gfp_t mask);
64struct extent_map *alloc_extent_map(gfp_t mask);
65void free_extent_map(struct extent_map *em);
66int extent_read_full_page(struct extent_map_tree *tree, struct page *page,
67 get_extent_t *get_extent);
68void __init extent_map_init(void);
69void __exit extent_map_exit(void);
70int extent_clean_all_trees(struct extent_map_tree *tree);
71int set_extent_uptodate(struct extent_map_tree *tree, u64 start, u64 end,
72 gfp_t mask);
73int set_extent_new(struct extent_map_tree *tree, u64 start, u64 end,
74 gfp_t mask);
75int set_extent_dirty(struct extent_map_tree *tree, u64 start, u64 end,
76 gfp_t mask);
77int extent_invalidatepage(struct extent_map_tree *tree,
78 struct page *page, unsigned long offset);
79int extent_write_full_page(struct extent_map_tree *tree, struct page *page,
80 get_extent_t *get_extent,
81 struct writeback_control *wbc);
82int extent_prepare_write(struct extent_map_tree *tree,
83 struct inode *inode, struct page *page,
84 unsigned from, unsigned to, get_extent_t *get_extent);
85int extent_commit_write(struct extent_map_tree *tree,
86 struct inode *inode, struct page *page,
87 unsigned from, unsigned to);
88int set_range_dirty(struct extent_map_tree *tree, u64 start, u64 end);
89#endif