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