2001-08-20 12:03:02 +04:00
/*
* dm . h
*
* Copyright ( C ) 2001 Sistina Software
*
* This software is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation ; either version 2 , or ( at
* your option ) any later version .
*
* This software is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with GNU CC ; see the file COPYING . If not , write to
* the Free Software Foundation , 59 Temple Place - Suite 330 ,
* Boston , MA 02111 - 1307 , USA .
*/
/*
* Internal header file for device mapper
*
* Changelog
*
* 16 / 08 / 2001 - First version [ Joe Thornber ]
*/
# ifndef DM_INTERNAL_H
# define DM_INTERNAL_H
2001-08-21 18:47:42 +04:00
# include <linux/version.h>
# include <linux/major.h>
# include <linux/iobuf.h>
# include <linux/module.h>
# include <linux/fs.h>
# include <linux/slab.h>
# include <linux/vmalloc.h>
# include <linux/compatmac.h>
# include <linux/cache.h>
# include <linux/devfs_fs_kernel.h>
# include <linux/device-mapper.h>
2001-08-20 12:03:02 +04:00
# define MAX_DEPTH 16
# define NODE_SIZE L1_CACHE_BYTES
# define KEYS_PER_NODE (NODE_SIZE / sizeof(offset_t))
2001-08-21 18:28:00 +04:00
# define DM_NAME_LEN 64
2001-08-20 12:03:02 +04:00
enum {
2001-08-21 18:28:00 +04:00
DM_LOADED = 0 ,
2001-08-20 12:03:02 +04:00
DM_LOADING ,
DM_ACTIVE ,
} ;
2001-08-20 20:12:22 +04:00
struct dev_list {
kdev_t dev ;
2001-08-21 18:28:00 +04:00
struct block_device * bd ;
2001-08-20 20:12:22 +04:00
struct dev_list * next ;
} ;
2001-08-20 12:03:02 +04:00
struct mapped_device {
kdev_t dev ;
char name [ DM_NAME_LEN ] ;
2001-08-21 18:28:00 +04:00
int use_count ;
2001-08-20 12:03:02 +04:00
int state ;
atomic_t pending ;
/* btree table */
int depth ;
int counts [ MAX_DEPTH ] ; /* in nodes */
offset_t * index [ MAX_DEPTH ] ;
int num_targets ;
int num_allocated ;
2001-08-20 19:22:44 +04:00
offset_t * highs ;
2001-08-20 12:03:02 +04:00
dm_map_fn * targets ;
void * * contexts ;
/* used by dm-fs.c */
devfs_handle_t devfs_entry ;
2001-08-22 19:01:09 +04:00
struct proc_dir_entry * pde ;
2001-08-20 20:12:22 +04:00
/* a list of devices used by this md */
struct dev_list * devices ;
2001-08-20 12:03:02 +04:00
} ;
struct target {
char * name ;
dm_ctr_fn ctr ;
dm_dtr_fn dtr ;
dm_map_fn map ;
struct target * next ;
} ;
2001-08-21 18:28:00 +04:00
/* dm-target.c */
2001-08-20 12:03:02 +04:00
struct target * dm_get_target ( const char * name ) ;
int dm_std_targets ( void ) ;
/* dm.c */
2001-08-20 17:45:43 +04:00
struct mapped_device * dm_find_name ( const char * name ) ;
struct mapped_device * dm_find_minor ( int minor ) ;
2001-08-20 12:03:02 +04:00
2001-08-21 19:24:02 +04:00
int dm_create ( const char * name , int minor ) ;
int dm_remove ( const char * name ) ;
2001-08-21 18:28:00 +04:00
int dm_activate ( struct mapped_device * md ) ;
2001-08-20 20:12:22 +04:00
void dm_suspend ( struct mapped_device * md ) ;
2001-08-20 12:03:02 +04:00
/* dm-table.c */
2001-08-20 17:45:43 +04:00
int dm_start_table ( struct mapped_device * md ) ;
int dm_add_entry ( struct mapped_device * md , offset_t high ,
dm_map_fn target , void * context ) ;
int dm_complete_table ( struct mapped_device * md ) ;
2001-08-21 18:47:42 +04:00
void dm_free_table ( struct mapped_device * md ) ;
2001-08-20 17:45:43 +04:00
2001-08-20 12:03:02 +04:00
/* dm-fs.c */
int dm_init_fs ( void ) ;
2001-08-21 19:24:02 +04:00
void dm_fin_fs ( void ) ;
2001-08-20 12:03:02 +04:00
2001-08-22 19:01:09 +04:00
int dm_fs_add ( struct mapped_device * md ) ;
int dm_fs_remove ( struct mapped_device * md ) ;
2001-08-21 18:51:41 +04:00
# define WARN(f, x...) printk(KERN_WARNING "device-mapper: " f "\n" , ## x)
2001-08-21 18:47:42 +04:00
static inline int is_active ( struct mapped_device * md )
2001-08-21 18:28:00 +04:00
{
return test_bit ( DM_ACTIVE , & md - > state ) ;
}
2001-08-21 18:47:42 +04:00
static inline void set_active ( struct mapped_device * md , int set )
2001-08-21 18:28:00 +04:00
{
if ( set )
set_bit ( DM_ACTIVE , & md - > state ) ;
else
clear_bit ( DM_ACTIVE , & md - > state ) ;
}
2001-08-20 12:03:02 +04:00
# endif