aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent_map.h
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-10-15 16:14:19 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:03:56 -0400
commit5f39d397dfbe140a14edecd4e73c34ce23c4f9ee (patch)
tree280561e4b68d573590557dd27df656869eed8023 /fs/btrfs/extent_map.h
parent50b78c24d594e6985f36a9a8d8e2fb74e1664e90 (diff)
Btrfs: Create extent_buffer interface for large blocksizes
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/extent_map.h')
-rw-r--r--fs/btrfs/extent_map.h75
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
9struct extent_map_ops { 20struct 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 *))
54struct extent_buffer { 67struct 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);
88int set_extent_dirty(struct extent_map_tree *tree, u64 start, u64 end, 102int set_extent_dirty(struct extent_map_tree *tree, u64 start, u64 end,
89 gfp_t mask); 103 gfp_t mask);
104int clear_extent_dirty(struct extent_map_tree *tree, u64 start, u64 end,
105 gfp_t mask);
90int set_extent_delalloc(struct extent_map_tree *tree, u64 start, u64 end, 106int set_extent_delalloc(struct extent_map_tree *tree, u64 start, u64 end,
91 gfp_t mask); 107 gfp_t mask);
108int find_first_extent_bit(struct extent_map_tree *tree, u64 start,
109 u64 *start_ret, u64 *end_ret, int bits);
92int extent_invalidatepage(struct extent_map_tree *tree, 110int extent_invalidatepage(struct extent_map_tree *tree,
93 struct page *page, unsigned long offset); 111 struct page *page, unsigned long offset);
94int extent_write_full_page(struct extent_map_tree *tree, struct page *page, 112int 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);
106int set_state_private(struct extent_map_tree *tree, u64 start, u64 private); 124int set_state_private(struct extent_map_tree *tree, u64 start, u64 private);
107int get_state_private(struct extent_map_tree *tree, u64 start, u64 *private); 125int get_state_private(struct extent_map_tree *tree, u64 start, u64 *private);
108void set_page_extent_mapped(struct page *page); 126void set_page_extent_mapped(struct page *page);
127
128struct extent_buffer *alloc_extent_buffer(struct extent_map_tree *tree,
129 u64 start, unsigned long len,
130 gfp_t mask);
131struct extent_buffer *find_extent_buffer(struct extent_map_tree *tree,
132 u64 start, unsigned long len,
133 gfp_t mask);
134void free_extent_buffer(struct extent_buffer *eb);
135int read_extent_buffer_pages(struct extent_map_tree *tree,
136 struct extent_buffer *eb, int wait);
137
138static inline void extent_buffer_get(struct extent_buffer *eb)
139{
140 atomic_inc(&eb->refs);
141}
142
143static inline u64 extent_buffer_blocknr(struct extent_buffer *eb)
144{
145 return eb->start / 4096;
146}
147
148int memcmp_extent_buffer(struct extent_buffer *eb, const void *ptrv,
149 unsigned long start,
150 unsigned long len);
151void read_extent_buffer(struct extent_buffer *eb, void *dst,
152 unsigned long start,
153 unsigned long len);
154void write_extent_buffer(struct extent_buffer *eb, const void *src,
155 unsigned long start, unsigned long len);
156void copy_extent_buffer(struct extent_buffer *dst, struct extent_buffer *src,
157 unsigned long dst_offset, unsigned long src_offset,
158 unsigned long len);
159void memcpy_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset,
160 unsigned long src_offset, unsigned long len);
161void memmove_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset,
162 unsigned long src_offset, unsigned long len);
163void memset_extent_buffer(struct extent_buffer *eb, char c,
164 unsigned long start, unsigned long len);
165int wait_on_extent_buffer_writeback(struct extent_map_tree *tree,
166 struct extent_buffer *eb);
167int clear_extent_buffer_dirty(struct extent_map_tree *tree,
168 struct extent_buffer *eb);
169int set_extent_buffer_dirty(struct extent_map_tree *tree,
170 struct extent_buffer *eb);
171int set_extent_buffer_uptodate(struct extent_map_tree *tree,
172 struct extent_buffer *eb);
173int extent_buffer_uptodate(struct extent_map_tree *tree,
174 struct extent_buffer *eb);
175int 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);
179void unmap_extent_buffer(struct extent_buffer *eb, char *token, int km);
109#endif 180#endif