diff options
Diffstat (limited to 'fs/btrfs/extent_io.h')
-rw-r--r-- | fs/btrfs/extent_io.h | 62 |
1 files changed, 35 insertions, 27 deletions
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h index cecc3518c121..faf10eb57f75 100644 --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h | |||
@@ -35,6 +35,10 @@ | |||
35 | #define EXTENT_BUFFER_DIRTY 2 | 35 | #define EXTENT_BUFFER_DIRTY 2 |
36 | #define EXTENT_BUFFER_CORRUPT 3 | 36 | #define EXTENT_BUFFER_CORRUPT 3 |
37 | #define EXTENT_BUFFER_READAHEAD 4 /* this got triggered by readahead */ | 37 | #define EXTENT_BUFFER_READAHEAD 4 /* this got triggered by readahead */ |
38 | #define EXTENT_BUFFER_TREE_REF 5 | ||
39 | #define EXTENT_BUFFER_STALE 6 | ||
40 | #define EXTENT_BUFFER_WRITEBACK 7 | ||
41 | #define EXTENT_BUFFER_IOERR 8 | ||
38 | 42 | ||
39 | /* these are flags for extent_clear_unlock_delalloc */ | 43 | /* these are flags for extent_clear_unlock_delalloc */ |
40 | #define EXTENT_CLEAR_UNLOCK_PAGE 0x1 | 44 | #define EXTENT_CLEAR_UNLOCK_PAGE 0x1 |
@@ -54,6 +58,7 @@ | |||
54 | #define EXTENT_PAGE_PRIVATE_FIRST_PAGE 3 | 58 | #define EXTENT_PAGE_PRIVATE_FIRST_PAGE 3 |
55 | 59 | ||
56 | struct extent_state; | 60 | struct extent_state; |
61 | struct btrfs_root; | ||
57 | 62 | ||
58 | typedef int (extent_submit_bio_hook_t)(struct inode *inode, int rw, | 63 | typedef int (extent_submit_bio_hook_t)(struct inode *inode, int rw, |
59 | struct bio *bio, int mirror_num, | 64 | struct bio *bio, int mirror_num, |
@@ -69,9 +74,7 @@ struct extent_io_ops { | |||
69 | size_t size, struct bio *bio, | 74 | size_t size, struct bio *bio, |
70 | unsigned long bio_flags); | 75 | unsigned long bio_flags); |
71 | int (*readpage_io_hook)(struct page *page, u64 start, u64 end); | 76 | int (*readpage_io_hook)(struct page *page, u64 start, u64 end); |
72 | int (*readpage_io_failed_hook)(struct bio *bio, struct page *page, | 77 | int (*readpage_io_failed_hook)(struct page *page, int failed_mirror); |
73 | u64 start, u64 end, int failed_mirror, | ||
74 | struct extent_state *state); | ||
75 | int (*writepage_io_failed_hook)(struct bio *bio, struct page *page, | 78 | int (*writepage_io_failed_hook)(struct bio *bio, struct page *page, |
76 | u64 start, u64 end, | 79 | u64 start, u64 end, |
77 | struct extent_state *state); | 80 | struct extent_state *state); |
@@ -97,6 +100,7 @@ struct extent_io_tree { | |||
97 | struct radix_tree_root buffer; | 100 | struct radix_tree_root buffer; |
98 | struct address_space *mapping; | 101 | struct address_space *mapping; |
99 | u64 dirty_bytes; | 102 | u64 dirty_bytes; |
103 | int track_uptodate; | ||
100 | spinlock_t lock; | 104 | spinlock_t lock; |
101 | spinlock_t buffer_lock; | 105 | spinlock_t buffer_lock; |
102 | struct extent_io_ops *ops; | 106 | struct extent_io_ops *ops; |
@@ -119,16 +123,21 @@ struct extent_state { | |||
119 | struct list_head leak_list; | 123 | struct list_head leak_list; |
120 | }; | 124 | }; |
121 | 125 | ||
126 | #define INLINE_EXTENT_BUFFER_PAGES 16 | ||
127 | #define MAX_INLINE_EXTENT_BUFFER_SIZE (INLINE_EXTENT_BUFFER_PAGES * PAGE_CACHE_SIZE) | ||
122 | struct extent_buffer { | 128 | struct extent_buffer { |
123 | u64 start; | 129 | u64 start; |
124 | unsigned long len; | 130 | unsigned long len; |
125 | unsigned long map_start; | 131 | unsigned long map_start; |
126 | unsigned long map_len; | 132 | unsigned long map_len; |
127 | struct page *first_page; | ||
128 | unsigned long bflags; | 133 | unsigned long bflags; |
134 | struct extent_io_tree *tree; | ||
135 | spinlock_t refs_lock; | ||
136 | atomic_t refs; | ||
137 | atomic_t io_pages; | ||
138 | int failed_mirror; | ||
129 | struct list_head leak_list; | 139 | struct list_head leak_list; |
130 | struct rcu_head rcu_head; | 140 | struct rcu_head rcu_head; |
131 | atomic_t refs; | ||
132 | pid_t lock_owner; | 141 | pid_t lock_owner; |
133 | 142 | ||
134 | /* count of read lock holders on the extent buffer */ | 143 | /* count of read lock holders on the extent buffer */ |
@@ -152,6 +161,9 @@ struct extent_buffer { | |||
152 | * to unlock | 161 | * to unlock |
153 | */ | 162 | */ |
154 | wait_queue_head_t read_lock_wq; | 163 | wait_queue_head_t read_lock_wq; |
164 | wait_queue_head_t lock_wq; | ||
165 | struct page *inline_pages[INLINE_EXTENT_BUFFER_PAGES]; | ||
166 | struct page **pages; | ||
155 | }; | 167 | }; |
156 | 168 | ||
157 | static inline void extent_set_compress_type(unsigned long *bio_flags, | 169 | static inline void extent_set_compress_type(unsigned long *bio_flags, |
@@ -178,18 +190,17 @@ void extent_io_tree_init(struct extent_io_tree *tree, | |||
178 | int try_release_extent_mapping(struct extent_map_tree *map, | 190 | int try_release_extent_mapping(struct extent_map_tree *map, |
179 | struct extent_io_tree *tree, struct page *page, | 191 | struct extent_io_tree *tree, struct page *page, |
180 | gfp_t mask); | 192 | gfp_t mask); |
181 | int try_release_extent_buffer(struct extent_io_tree *tree, struct page *page); | 193 | int try_release_extent_buffer(struct page *page, gfp_t mask); |
182 | int try_release_extent_state(struct extent_map_tree *map, | 194 | int try_release_extent_state(struct extent_map_tree *map, |
183 | struct extent_io_tree *tree, struct page *page, | 195 | struct extent_io_tree *tree, struct page *page, |
184 | gfp_t mask); | 196 | gfp_t mask); |
185 | int lock_extent(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask); | 197 | int lock_extent(struct extent_io_tree *tree, u64 start, u64 end); |
186 | int lock_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, | 198 | int lock_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, |
187 | int bits, struct extent_state **cached, gfp_t mask); | 199 | int bits, struct extent_state **cached); |
188 | int unlock_extent(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask); | 200 | int unlock_extent(struct extent_io_tree *tree, u64 start, u64 end); |
189 | int unlock_extent_cached(struct extent_io_tree *tree, u64 start, u64 end, | 201 | int unlock_extent_cached(struct extent_io_tree *tree, u64 start, u64 end, |
190 | struct extent_state **cached, gfp_t mask); | 202 | struct extent_state **cached, gfp_t mask); |
191 | int try_lock_extent(struct extent_io_tree *tree, u64 start, u64 end, | 203 | int try_lock_extent(struct extent_io_tree *tree, u64 start, u64 end); |
192 | gfp_t mask); | ||
193 | int extent_read_full_page(struct extent_io_tree *tree, struct page *page, | 204 | int extent_read_full_page(struct extent_io_tree *tree, struct page *page, |
194 | get_extent_t *get_extent, int mirror_num); | 205 | get_extent_t *get_extent, int mirror_num); |
195 | int __init extent_io_init(void); | 206 | int __init extent_io_init(void); |
@@ -210,7 +221,7 @@ int clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, | |||
210 | int set_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, | 221 | int set_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, |
211 | int bits, gfp_t mask); | 222 | int bits, gfp_t mask); |
212 | int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, | 223 | int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, |
213 | int bits, int exclusive_bits, u64 *failed_start, | 224 | int bits, u64 *failed_start, |
214 | struct extent_state **cached_state, gfp_t mask); | 225 | struct extent_state **cached_state, gfp_t mask); |
215 | int set_extent_uptodate(struct extent_io_tree *tree, u64 start, u64 end, | 226 | int set_extent_uptodate(struct extent_io_tree *tree, u64 start, u64 end, |
216 | struct extent_state **cached_state, gfp_t mask); | 227 | struct extent_state **cached_state, gfp_t mask); |
@@ -240,6 +251,8 @@ int extent_writepages(struct extent_io_tree *tree, | |||
240 | struct address_space *mapping, | 251 | struct address_space *mapping, |
241 | get_extent_t *get_extent, | 252 | get_extent_t *get_extent, |
242 | struct writeback_control *wbc); | 253 | struct writeback_control *wbc); |
254 | int btree_write_cache_pages(struct address_space *mapping, | ||
255 | struct writeback_control *wbc); | ||
243 | int extent_readpages(struct extent_io_tree *tree, | 256 | int extent_readpages(struct extent_io_tree *tree, |
244 | struct address_space *mapping, | 257 | struct address_space *mapping, |
245 | struct list_head *pages, unsigned nr_pages, | 258 | struct list_head *pages, unsigned nr_pages, |
@@ -251,11 +264,11 @@ int get_state_private(struct extent_io_tree *tree, u64 start, u64 *private); | |||
251 | void set_page_extent_mapped(struct page *page); | 264 | void set_page_extent_mapped(struct page *page); |
252 | 265 | ||
253 | struct extent_buffer *alloc_extent_buffer(struct extent_io_tree *tree, | 266 | struct extent_buffer *alloc_extent_buffer(struct extent_io_tree *tree, |
254 | u64 start, unsigned long len, | 267 | u64 start, unsigned long len); |
255 | struct page *page0); | ||
256 | struct extent_buffer *find_extent_buffer(struct extent_io_tree *tree, | 268 | struct extent_buffer *find_extent_buffer(struct extent_io_tree *tree, |
257 | u64 start, unsigned long len); | 269 | u64 start, unsigned long len); |
258 | void free_extent_buffer(struct extent_buffer *eb); | 270 | void free_extent_buffer(struct extent_buffer *eb); |
271 | void free_extent_buffer_stale(struct extent_buffer *eb); | ||
259 | #define WAIT_NONE 0 | 272 | #define WAIT_NONE 0 |
260 | #define WAIT_COMPLETE 1 | 273 | #define WAIT_COMPLETE 1 |
261 | #define WAIT_PAGE_LOCK 2 | 274 | #define WAIT_PAGE_LOCK 2 |
@@ -287,19 +300,12 @@ void memmove_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset, | |||
287 | unsigned long src_offset, unsigned long len); | 300 | unsigned long src_offset, unsigned long len); |
288 | void memset_extent_buffer(struct extent_buffer *eb, char c, | 301 | void memset_extent_buffer(struct extent_buffer *eb, char c, |
289 | unsigned long start, unsigned long len); | 302 | unsigned long start, unsigned long len); |
290 | int wait_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits); | 303 | void wait_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits); |
291 | int clear_extent_buffer_dirty(struct extent_io_tree *tree, | 304 | void clear_extent_buffer_dirty(struct extent_buffer *eb); |
292 | struct extent_buffer *eb); | 305 | int set_extent_buffer_dirty(struct extent_buffer *eb); |
293 | int set_extent_buffer_dirty(struct extent_io_tree *tree, | 306 | int set_extent_buffer_uptodate(struct extent_buffer *eb); |
294 | struct extent_buffer *eb); | 307 | int clear_extent_buffer_uptodate(struct extent_buffer *eb); |
295 | int set_extent_buffer_uptodate(struct extent_io_tree *tree, | 308 | int extent_buffer_uptodate(struct extent_buffer *eb); |
296 | struct extent_buffer *eb); | ||
297 | int clear_extent_buffer_uptodate(struct extent_io_tree *tree, | ||
298 | struct extent_buffer *eb, | ||
299 | struct extent_state **cached_state); | ||
300 | int extent_buffer_uptodate(struct extent_io_tree *tree, | ||
301 | struct extent_buffer *eb, | ||
302 | struct extent_state *cached_state); | ||
303 | int map_private_extent_buffer(struct extent_buffer *eb, unsigned long offset, | 309 | int map_private_extent_buffer(struct extent_buffer *eb, unsigned long offset, |
304 | unsigned long min_len, char **map, | 310 | unsigned long min_len, char **map, |
305 | unsigned long *map_start, | 311 | unsigned long *map_start, |
@@ -320,4 +326,6 @@ int repair_io_failure(struct btrfs_mapping_tree *map_tree, u64 start, | |||
320 | u64 length, u64 logical, struct page *page, | 326 | u64 length, u64 logical, struct page *page, |
321 | int mirror_num); | 327 | int mirror_num); |
322 | int end_extent_writepage(struct page *page, int err, u64 start, u64 end); | 328 | int end_extent_writepage(struct page *page, int err, u64 start, u64 end); |
329 | int repair_eb_io_failure(struct btrfs_root *root, struct extent_buffer *eb, | ||
330 | int mirror_num); | ||
323 | #endif | 331 | #endif |