diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-08-27 16:49:44 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-08-27 16:49:44 -0400 |
commit | a52d9a8033c454cd9b4697cfafb467509fc1693f (patch) | |
tree | 83d8bbf2df29598ea9c60498fadf5990262a11c8 /fs/btrfs/extent_map.h | |
parent | 83df7c1d8b885e216c68c3f0469bec9b93666b74 (diff) |
Btrfs: Extent based page cache code. This uses an rbtree of extents and tests
instead of buffer heads.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/extent_map.h')
-rw-r--r-- | fs/btrfs/extent_map.h | 89 |
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 | |||
9 | struct 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 */ | ||
17 | struct 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 */ | ||
30 | struct 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 | |||
41 | struct extent_buffer { | ||
42 | u64 start; | ||
43 | u64 end; /* inclusive */ | ||
44 | char *addr; | ||
45 | struct page *pages[]; | ||
46 | }; | ||
47 | |||
48 | typedef 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 | |||
54 | void extent_map_tree_init(struct extent_map_tree *tree, | ||
55 | struct address_space *mapping, gfp_t mask); | ||
56 | struct extent_map *lookup_extent_mapping(struct extent_map_tree *tree, | ||
57 | u64 start, u64 end); | ||
58 | int add_extent_mapping(struct extent_map_tree *tree, | ||
59 | struct extent_map *em); | ||
60 | int remove_extent_mapping(struct extent_map_tree *tree, struct extent_map *em); | ||
61 | int try_release_extent_mapping(struct extent_map_tree *tree, struct page *page); | ||
62 | int lock_extent(struct extent_map_tree *tree, u64 start, u64 end, gfp_t mask); | ||
63 | int unlock_extent(struct extent_map_tree *tree, u64 start, u64 end, gfp_t mask); | ||
64 | struct extent_map *alloc_extent_map(gfp_t mask); | ||
65 | void free_extent_map(struct extent_map *em); | ||
66 | int extent_read_full_page(struct extent_map_tree *tree, struct page *page, | ||
67 | get_extent_t *get_extent); | ||
68 | void __init extent_map_init(void); | ||
69 | void __exit extent_map_exit(void); | ||
70 | int extent_clean_all_trees(struct extent_map_tree *tree); | ||
71 | int set_extent_uptodate(struct extent_map_tree *tree, u64 start, u64 end, | ||
72 | gfp_t mask); | ||
73 | int set_extent_new(struct extent_map_tree *tree, u64 start, u64 end, | ||
74 | gfp_t mask); | ||
75 | int set_extent_dirty(struct extent_map_tree *tree, u64 start, u64 end, | ||
76 | gfp_t mask); | ||
77 | int extent_invalidatepage(struct extent_map_tree *tree, | ||
78 | struct page *page, unsigned long offset); | ||
79 | int extent_write_full_page(struct extent_map_tree *tree, struct page *page, | ||
80 | get_extent_t *get_extent, | ||
81 | struct writeback_control *wbc); | ||
82 | int 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); | ||
85 | int extent_commit_write(struct extent_map_tree *tree, | ||
86 | struct inode *inode, struct page *page, | ||
87 | unsigned from, unsigned to); | ||
88 | int set_range_dirty(struct extent_map_tree *tree, u64 start, u64 end); | ||
89 | #endif | ||