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