aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent_map.h
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-10-16 10:12:58 -0400
committerChris Mason <chris.mason@oracle.com>2008-10-16 10:12:58 -0400
commit26ce34a9c47334ff7984769e4661b2f1883594ff (patch)
treefbc1da082a0b9f4adc7a2560811bbd6e6c47e420 /fs/btrfs/extent_map.h
parent3fa8749e584b55f1180411ab1b51117190bac1e5 (diff)
parent37d3cdddf5378606f6eab99982ca16819745d8f4 (diff)
Merge branch 'master' of ssh://mason@master.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable
Diffstat (limited to 'fs/btrfs/extent_map.h')
-rw-r--r--fs/btrfs/extent_map.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/fs/btrfs/extent_map.h b/fs/btrfs/extent_map.h
new file mode 100644
index 000000000000..26ac6fe0b268
--- /dev/null
+++ b/fs/btrfs/extent_map.h
@@ -0,0 +1,57 @@
1#ifndef __EXTENTMAP__
2#define __EXTENTMAP__
3
4#include <linux/rbtree.h>
5
6#define EXTENT_MAP_LAST_BYTE (u64)-4
7#define EXTENT_MAP_HOLE (u64)-3
8#define EXTENT_MAP_INLINE (u64)-2
9#define EXTENT_MAP_DELALLOC (u64)-1
10
11/* bits for the flags field */
12#define EXTENT_FLAG_PINNED 0 /* this entry not yet on disk, don't free it */
13
14struct extent_map {
15 struct rb_node rb_node;
16
17 /* all of these are in bytes */
18 u64 start;
19 u64 len;
20 u64 block_start;
21 unsigned long flags;
22 struct block_device *bdev;
23 atomic_t refs;
24 int in_tree;
25};
26
27struct extent_map_tree {
28 struct rb_root map;
29 spinlock_t lock;
30};
31
32static inline u64 extent_map_end(struct extent_map *em)
33{
34 if (em->start + em->len < em->start)
35 return (u64)-1;
36 return em->start + em->len;
37}
38
39static inline u64 extent_map_block_end(struct extent_map *em)
40{
41 if (em->block_start + em->len < em->block_start)
42 return (u64)-1;
43 return em->block_start + em->len;
44}
45
46void extent_map_tree_init(struct extent_map_tree *tree, gfp_t mask);
47struct extent_map *lookup_extent_mapping(struct extent_map_tree *tree,
48 u64 start, u64 len);
49int add_extent_mapping(struct extent_map_tree *tree,
50 struct extent_map *em);
51int remove_extent_mapping(struct extent_map_tree *tree, struct extent_map *em);
52
53struct extent_map *alloc_extent_map(gfp_t mask);
54void free_extent_map(struct extent_map *em);
55int __init extent_map_init(void);
56void extent_map_exit(void);
57#endif