diff options
Diffstat (limited to 'fs/btrfs/extent_map.h')
-rw-r--r-- | fs/btrfs/extent_map.h | 75 |
1 files changed, 73 insertions, 2 deletions
diff --git a/fs/btrfs/extent_map.h b/fs/btrfs/extent_map.h index d913ce01248d..430b997a70f6 100644 --- a/fs/btrfs/extent_map.h +++ b/fs/btrfs/extent_map.h | |||
@@ -3,9 +3,20 @@ | |||
3 | 3 | ||
4 | #include <linux/rbtree.h> | 4 | #include <linux/rbtree.h> |
5 | 5 | ||
6 | #define EXTENT_MAP_HOLE (u64)-3 | ||
6 | #define EXTENT_MAP_INLINE (u64)-2 | 7 | #define EXTENT_MAP_INLINE (u64)-2 |
7 | #define EXTENT_MAP_DELALLOC (u64)-1 | 8 | #define EXTENT_MAP_DELALLOC (u64)-1 |
8 | 9 | ||
10 | /* bits for the extent state */ | ||
11 | #define EXTENT_DIRTY 1 | ||
12 | #define EXTENT_WRITEBACK (1 << 1) | ||
13 | #define EXTENT_UPTODATE (1 << 2) | ||
14 | #define EXTENT_LOCKED (1 << 3) | ||
15 | #define EXTENT_NEW (1 << 4) | ||
16 | #define EXTENT_DELALLOC (1 << 5) | ||
17 | #define EXTENT_IOBITS (EXTENT_LOCKED | EXTENT_WRITEBACK) | ||
18 | |||
19 | |||
9 | struct extent_map_ops { | 20 | struct extent_map_ops { |
10 | int (*fill_delalloc)(struct inode *inode, u64 start, u64 end); | 21 | int (*fill_delalloc)(struct inode *inode, u64 start, u64 end); |
11 | int (*writepage_io_hook)(struct page *page, u64 start, u64 end); | 22 | int (*writepage_io_hook)(struct page *page, u64 start, u64 end); |
@@ -51,10 +62,13 @@ struct extent_state { | |||
51 | struct list_head list; | 62 | struct list_head list; |
52 | }; | 63 | }; |
53 | 64 | ||
65 | #define EXTENT_BUFFER_SIZE(nr) (sizeof(struct extent_buffer) + \ | ||
66 | (nr - 1) * sizeof(struct page *)) | ||
54 | struct extent_buffer { | 67 | struct extent_buffer { |
55 | u64 start; | 68 | u64 start; |
56 | u64 end; /* inclusive */ | 69 | unsigned long len; |
57 | char *addr; | 70 | atomic_t refs; |
71 | int flags; | ||
58 | struct page *pages[]; | 72 | struct page *pages[]; |
59 | }; | 73 | }; |
60 | 74 | ||
@@ -87,8 +101,12 @@ int set_extent_new(struct extent_map_tree *tree, u64 start, u64 end, | |||
87 | gfp_t mask); | 101 | gfp_t mask); |
88 | int set_extent_dirty(struct extent_map_tree *tree, u64 start, u64 end, | 102 | int set_extent_dirty(struct extent_map_tree *tree, u64 start, u64 end, |
89 | gfp_t mask); | 103 | gfp_t mask); |
104 | int clear_extent_dirty(struct extent_map_tree *tree, u64 start, u64 end, | ||
105 | gfp_t mask); | ||
90 | int set_extent_delalloc(struct extent_map_tree *tree, u64 start, u64 end, | 106 | int set_extent_delalloc(struct extent_map_tree *tree, u64 start, u64 end, |
91 | gfp_t mask); | 107 | gfp_t mask); |
108 | int find_first_extent_bit(struct extent_map_tree *tree, u64 start, | ||
109 | u64 *start_ret, u64 *end_ret, int bits); | ||
92 | int extent_invalidatepage(struct extent_map_tree *tree, | 110 | int extent_invalidatepage(struct extent_map_tree *tree, |
93 | struct page *page, unsigned long offset); | 111 | struct page *page, unsigned long offset); |
94 | int extent_write_full_page(struct extent_map_tree *tree, struct page *page, | 112 | int extent_write_full_page(struct extent_map_tree *tree, struct page *page, |
@@ -106,4 +124,57 @@ int set_range_dirty(struct extent_map_tree *tree, u64 start, u64 end); | |||
106 | int set_state_private(struct extent_map_tree *tree, u64 start, u64 private); | 124 | int set_state_private(struct extent_map_tree *tree, u64 start, u64 private); |
107 | int get_state_private(struct extent_map_tree *tree, u64 start, u64 *private); | 125 | int get_state_private(struct extent_map_tree *tree, u64 start, u64 *private); |
108 | void set_page_extent_mapped(struct page *page); | 126 | void set_page_extent_mapped(struct page *page); |
127 | |||
128 | struct extent_buffer *alloc_extent_buffer(struct extent_map_tree *tree, | ||
129 | u64 start, unsigned long len, | ||
130 | gfp_t mask); | ||
131 | struct extent_buffer *find_extent_buffer(struct extent_map_tree *tree, | ||
132 | u64 start, unsigned long len, | ||
133 | gfp_t mask); | ||
134 | void free_extent_buffer(struct extent_buffer *eb); | ||
135 | int read_extent_buffer_pages(struct extent_map_tree *tree, | ||
136 | struct extent_buffer *eb, int wait); | ||
137 | |||
138 | static inline void extent_buffer_get(struct extent_buffer *eb) | ||
139 | { | ||
140 | atomic_inc(&eb->refs); | ||
141 | } | ||
142 | |||
143 | static inline u64 extent_buffer_blocknr(struct extent_buffer *eb) | ||
144 | { | ||
145 | return eb->start / 4096; | ||
146 | } | ||
147 | |||
148 | int memcmp_extent_buffer(struct extent_buffer *eb, const void *ptrv, | ||
149 | unsigned long start, | ||
150 | unsigned long len); | ||
151 | void read_extent_buffer(struct extent_buffer *eb, void *dst, | ||
152 | unsigned long start, | ||
153 | unsigned long len); | ||
154 | void write_extent_buffer(struct extent_buffer *eb, const void *src, | ||
155 | unsigned long start, unsigned long len); | ||
156 | void copy_extent_buffer(struct extent_buffer *dst, struct extent_buffer *src, | ||
157 | unsigned long dst_offset, unsigned long src_offset, | ||
158 | unsigned long len); | ||
159 | void memcpy_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset, | ||
160 | unsigned long src_offset, unsigned long len); | ||
161 | void memmove_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset, | ||
162 | unsigned long src_offset, unsigned long len); | ||
163 | void memset_extent_buffer(struct extent_buffer *eb, char c, | ||
164 | unsigned long start, unsigned long len); | ||
165 | int wait_on_extent_buffer_writeback(struct extent_map_tree *tree, | ||
166 | struct extent_buffer *eb); | ||
167 | int clear_extent_buffer_dirty(struct extent_map_tree *tree, | ||
168 | struct extent_buffer *eb); | ||
169 | int set_extent_buffer_dirty(struct extent_map_tree *tree, | ||
170 | struct extent_buffer *eb); | ||
171 | int set_extent_buffer_uptodate(struct extent_map_tree *tree, | ||
172 | struct extent_buffer *eb); | ||
173 | int extent_buffer_uptodate(struct extent_map_tree *tree, | ||
174 | struct extent_buffer *eb); | ||
175 | int map_extent_buffer(struct extent_buffer *eb, unsigned long offset, | ||
176 | char **token, char **map, | ||
177 | unsigned long *map_start, | ||
178 | unsigned long *map_len, int km); | ||
179 | void unmap_extent_buffer(struct extent_buffer *eb, char *token, int km); | ||
109 | #endif | 180 | #endif |