aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent_io.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/extent_io.h')
-rw-r--r--fs/btrfs/extent_io.h62
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
56struct extent_state; 60struct extent_state;
61struct btrfs_root;
57 62
58typedef int (extent_submit_bio_hook_t)(struct inode *inode, int rw, 63typedef 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)
122struct extent_buffer { 128struct 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
157static inline void extent_set_compress_type(unsigned long *bio_flags, 169static inline void extent_set_compress_type(unsigned long *bio_flags,
@@ -178,18 +190,17 @@ void extent_io_tree_init(struct extent_io_tree *tree,
178int try_release_extent_mapping(struct extent_map_tree *map, 190int 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);
181int try_release_extent_buffer(struct extent_io_tree *tree, struct page *page); 193int try_release_extent_buffer(struct page *page, gfp_t mask);
182int try_release_extent_state(struct extent_map_tree *map, 194int 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);
185int lock_extent(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask); 197int lock_extent(struct extent_io_tree *tree, u64 start, u64 end);
186int lock_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, 198int 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);
188int unlock_extent(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask); 200int unlock_extent(struct extent_io_tree *tree, u64 start, u64 end);
189int unlock_extent_cached(struct extent_io_tree *tree, u64 start, u64 end, 201int 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);
191int try_lock_extent(struct extent_io_tree *tree, u64 start, u64 end, 203int try_lock_extent(struct extent_io_tree *tree, u64 start, u64 end);
192 gfp_t mask);
193int extent_read_full_page(struct extent_io_tree *tree, struct page *page, 204int 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);
195int __init extent_io_init(void); 206int __init extent_io_init(void);
@@ -210,7 +221,7 @@ int clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
210int set_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, 221int set_extent_bits(struct extent_io_tree *tree, u64 start, u64 end,
211 int bits, gfp_t mask); 222 int bits, gfp_t mask);
212int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, 223int 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);
215int set_extent_uptodate(struct extent_io_tree *tree, u64 start, u64 end, 226int 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);
254int btree_write_cache_pages(struct address_space *mapping,
255 struct writeback_control *wbc);
243int extent_readpages(struct extent_io_tree *tree, 256int 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);
251void set_page_extent_mapped(struct page *page); 264void set_page_extent_mapped(struct page *page);
252 265
253struct extent_buffer *alloc_extent_buffer(struct extent_io_tree *tree, 266struct 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);
256struct extent_buffer *find_extent_buffer(struct extent_io_tree *tree, 268struct extent_buffer *find_extent_buffer(struct extent_io_tree *tree,
257 u64 start, unsigned long len); 269 u64 start, unsigned long len);
258void free_extent_buffer(struct extent_buffer *eb); 270void free_extent_buffer(struct extent_buffer *eb);
271void 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);
288void memset_extent_buffer(struct extent_buffer *eb, char c, 301void memset_extent_buffer(struct extent_buffer *eb, char c,
289 unsigned long start, unsigned long len); 302 unsigned long start, unsigned long len);
290int wait_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits); 303void wait_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits);
291int clear_extent_buffer_dirty(struct extent_io_tree *tree, 304void clear_extent_buffer_dirty(struct extent_buffer *eb);
292 struct extent_buffer *eb); 305int set_extent_buffer_dirty(struct extent_buffer *eb);
293int set_extent_buffer_dirty(struct extent_io_tree *tree, 306int set_extent_buffer_uptodate(struct extent_buffer *eb);
294 struct extent_buffer *eb); 307int clear_extent_buffer_uptodate(struct extent_buffer *eb);
295int set_extent_buffer_uptodate(struct extent_io_tree *tree, 308int extent_buffer_uptodate(struct extent_buffer *eb);
296 struct extent_buffer *eb);
297int clear_extent_buffer_uptodate(struct extent_io_tree *tree,
298 struct extent_buffer *eb,
299 struct extent_state **cached_state);
300int extent_buffer_uptodate(struct extent_io_tree *tree,
301 struct extent_buffer *eb,
302 struct extent_state *cached_state);
303int map_private_extent_buffer(struct extent_buffer *eb, unsigned long offset, 309int 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);
322int end_extent_writepage(struct page *page, int err, u64 start, u64 end); 328int end_extent_writepage(struct page *page, int err, u64 start, u64 end);
329int repair_eb_io_failure(struct btrfs_root *root, struct extent_buffer *eb,
330 int mirror_num);
323#endif 331#endif