Btrfs: do not hold the write_lock on the extent tree while logging
[deliverable/linux.git] / fs / btrfs / extent_map.h
CommitLineData
a52d9a80
CM
1#ifndef __EXTENTMAP__
2#define __EXTENTMAP__
3
4#include <linux/rbtree.h>
5
d1310b2e 6#define EXTENT_MAP_LAST_BYTE (u64)-4
5f39d397 7#define EXTENT_MAP_HOLE (u64)-3
a52d9a80
CM
8#define EXTENT_MAP_INLINE (u64)-2
9#define EXTENT_MAP_DELALLOC (u64)-1
10
7f3c74fb
CM
11/* bits for the flags field */
12#define EXTENT_FLAG_PINNED 0 /* this entry not yet on disk, don't free it */
c8b97818 13#define EXTENT_FLAG_COMPRESSED 1
9036c102 14#define EXTENT_FLAG_VACANCY 2 /* no file extent item found */
d899e052 15#define EXTENT_FLAG_PREALLOC 3 /* pre-allocated extent */
ff44c6e3 16#define EXTENT_FLAG_LOGGING 4 /* Logging this extent */
7f3c74fb 17
a52d9a80 18struct extent_map {
a52d9a80 19 struct rb_node rb_node;
d1310b2e
CM
20
21 /* all of these are in bytes */
22 u64 start;
23 u64 len;
4e2f84e6
LB
24 u64 mod_start;
25 u64 mod_len;
ff5b7ee3 26 u64 orig_start;
a52d9a80 27 u64 block_start;
c8b97818 28 u64 block_len;
5dc562c5 29 u64 generation;
d1310b2e 30 unsigned long flags;
a52d9a80
CM
31 struct block_device *bdev;
32 atomic_t refs;
c08782da
DS
33 unsigned int in_tree;
34 unsigned int compress_type;
5dc562c5 35 struct list_head list;
a52d9a80
CM
36};
37
d1310b2e
CM
38struct extent_map_tree {
39 struct rb_root map;
5dc562c5 40 struct list_head modified_extents;
890871be 41 rwlock_t lock;
a52d9a80
CM
42};
43
d1310b2e
CM
44static inline u64 extent_map_end(struct extent_map *em)
45{
46 if (em->start + em->len < em->start)
47 return (u64)-1;
48 return em->start + em->len;
49}
50
51static inline u64 extent_map_block_end(struct extent_map *em)
52{
c8b97818 53 if (em->block_start + em->block_len < em->block_start)
d1310b2e 54 return (u64)-1;
c8b97818 55 return em->block_start + em->block_len;
d1310b2e 56}
a52d9a80 57
a8067e02 58void extent_map_tree_init(struct extent_map_tree *tree);
a52d9a80 59struct extent_map *lookup_extent_mapping(struct extent_map_tree *tree,
d1310b2e 60 u64 start, u64 len);
a52d9a80
CM
61int add_extent_mapping(struct extent_map_tree *tree,
62 struct extent_map *em);
63int remove_extent_mapping(struct extent_map_tree *tree, struct extent_map *em);
d1310b2e 64
172ddd60 65struct extent_map *alloc_extent_map(void);
a52d9a80 66void free_extent_map(struct extent_map *em);
2f4cbe64 67int __init extent_map_init(void);
17636e03 68void extent_map_exit(void);
5dc562c5 69int unpin_extent_cache(struct extent_map_tree *tree, u64 start, u64 len, u64 gen);
b917b7c3
CM
70struct extent_map *search_extent_mapping(struct extent_map_tree *tree,
71 u64 start, u64 len);
a52d9a80 72#endif
This page took 0.211698 seconds and 5 git commands to generate.