2007-08-27 20:49:44 +00:00
|
|
|
#ifndef __EXTENTMAP__
|
|
|
|
#define __EXTENTMAP__
|
|
|
|
|
|
|
|
#include <linux/rbtree.h>
|
|
|
|
|
2008-01-24 21:13:08 +00:00
|
|
|
#define EXTENT_MAP_LAST_BYTE (u64)-4
|
2007-10-15 20:14:19 +00:00
|
|
|
#define EXTENT_MAP_HOLE (u64)-3
|
2007-08-27 20:49:44 +00:00
|
|
|
#define EXTENT_MAP_INLINE (u64)-2
|
|
|
|
#define EXTENT_MAP_DELALLOC (u64)-1
|
|
|
|
|
2008-07-18 16:01:11 +00:00
|
|
|
/* bits for the flags field */
|
|
|
|
#define EXTENT_FLAG_PINNED 0 /* this entry not yet on disk, don't free it */
|
|
|
|
|
2007-08-27 20:49:44 +00:00
|
|
|
struct extent_map {
|
|
|
|
struct rb_node rb_node;
|
2008-01-24 21:13:08 +00:00
|
|
|
|
|
|
|
/* all of these are in bytes */
|
|
|
|
u64 start;
|
|
|
|
u64 len;
|
2007-08-27 20:49:44 +00:00
|
|
|
u64 block_start;
|
2008-01-24 21:13:08 +00:00
|
|
|
unsigned long flags;
|
2007-08-27 20:49:44 +00:00
|
|
|
struct block_device *bdev;
|
|
|
|
atomic_t refs;
|
|
|
|
int in_tree;
|
|
|
|
};
|
|
|
|
|
2008-01-24 21:13:08 +00:00
|
|
|
struct extent_map_tree {
|
|
|
|
struct rb_root map;
|
|
|
|
spinlock_t lock;
|
2007-08-27 20:49:44 +00:00
|
|
|
};
|
|
|
|
|
2008-01-24 21:13:08 +00: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 20:49:44 +00:00
|
|
|
|
2008-01-24 21:13:08 +00:00
|
|
|
void extent_map_tree_init(struct extent_map_tree *tree, gfp_t mask);
|
2007-08-27 20:49:44 +00:00
|
|
|
struct extent_map *lookup_extent_mapping(struct extent_map_tree *tree,
|
2008-01-24 21:13:08 +00:00
|
|
|
u64 start, u64 len);
|
2007-08-27 20:49:44 +00: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 21:13:08 +00:00
|
|
|
|
2007-08-27 20:49:44 +00:00
|
|
|
struct extent_map *alloc_extent_map(gfp_t mask);
|
|
|
|
void free_extent_map(struct extent_map *em);
|
2007-11-19 15:22:33 +00:00
|
|
|
int __init extent_map_init(void);
|
2007-12-11 14:25:06 +00:00
|
|
|
void extent_map_exit(void);
|
2007-08-27 20:49:44 +00:00
|
|
|
#endif
|