2007-08-27 16:49:44 -04:00
|
|
|
#ifndef __EXTENTMAP__
|
|
|
|
#define __EXTENTMAP__
|
|
|
|
|
|
|
|
#include <linux/rbtree.h>
|
|
|
|
|
2008-01-24 16:13:08 -05:00
|
|
|
#define EXTENT_MAP_LAST_BYTE (u64)-4
|
2007-10-15 16:14:19 -04:00
|
|
|
#define EXTENT_MAP_HOLE (u64)-3
|
2007-08-27 16:49:44 -04:00
|
|
|
#define EXTENT_MAP_INLINE (u64)-2
|
|
|
|
#define EXTENT_MAP_DELALLOC (u64)-1
|
|
|
|
|
|
|
|
struct extent_map {
|
|
|
|
struct rb_node rb_node;
|
2008-01-24 16:13:08 -05:00
|
|
|
|
|
|
|
/* all of these are in bytes */
|
|
|
|
u64 start;
|
|
|
|
u64 len;
|
2007-08-27 16:49:44 -04:00
|
|
|
u64 block_start;
|
2008-01-24 16:13:08 -05:00
|
|
|
unsigned long flags;
|
2007-08-27 16:49:44 -04:00
|
|
|
struct block_device *bdev;
|
|
|
|
atomic_t refs;
|
|
|
|
int in_tree;
|
|
|
|
};
|
|
|
|
|
2008-01-24 16:13:08 -05:00
|
|
|
struct extent_map_tree {
|
|
|
|
struct rb_root map;
|
|
|
|
struct extent_map *last;
|
|
|
|
spinlock_t lock;
|
2007-08-27 16:49:44 -04:00
|
|
|
};
|
|
|
|
|
2008-01-24 16:13:08 -05:00
|
|
|
static inline u64 extent_map_end(struct extent_map *em)
|
|
|
|
{
|
|
|
|
if (em->start + em->len < em->start)
|
|
|
|
return (u64)-1;
|
|
|
|
return em->start + em->len;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline u64 extent_map_block_end(struct extent_map *em)
|
|
|
|
{
|
|
|
|
if (em->block_start + em->len < em->block_start)
|
|
|
|
return (u64)-1;
|
|
|
|
return em->block_start + em->len;
|
|
|
|
}
|
2007-08-27 16:49:44 -04:00
|
|
|
|
2008-01-24 16:13:08 -05:00
|
|
|
void extent_map_tree_init(struct extent_map_tree *tree, gfp_t mask);
|
2007-08-27 16:49:44 -04:00
|
|
|
struct extent_map *lookup_extent_mapping(struct extent_map_tree *tree,
|
2008-01-24 16:13:08 -05:00
|
|
|
u64 start, u64 len);
|
2007-08-27 16:49:44 -04:00
|
|
|
int add_extent_mapping(struct extent_map_tree *tree,
|
|
|
|
struct extent_map *em);
|
|
|
|
int remove_extent_mapping(struct extent_map_tree *tree, struct extent_map *em);
|
2008-01-24 16:13:08 -05:00
|
|
|
|
2007-08-27 16:49:44 -04:00
|
|
|
struct extent_map *alloc_extent_map(gfp_t mask);
|
|
|
|
void free_extent_map(struct extent_map *em);
|
2007-11-19 10:22:33 -05:00
|
|
|
int __init extent_map_init(void);
|
2007-12-11 09:25:06 -05:00
|
|
|
void extent_map_exit(void);
|
2007-08-27 16:49:44 -04:00
|
|
|
#endif
|