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