2001-09-25 16:49:28 +04:00
/*
* Copyright ( C ) 2001 Sistina Software
*
2001-09-28 17:15:30 +04:00
* This file is released under the GPL .
2001-09-25 16:49:28 +04:00
*
2001-09-28 17:15:30 +04:00
* This is the in core representation of a volume group and it ' s
* associated physical and logical volumes .
2001-09-25 16:49:28 +04:00
*/
2001-09-28 17:15:30 +04:00
# ifndef METADATA_H
# define METADATA_H
2001-09-25 16:49:28 +04:00
2001-09-28 17:15:30 +04:00
# define ID_LEN 32
2001-09-25 16:49:28 +04:00
2001-09-28 17:15:30 +04:00
struct id {
uint8_t chars [ ID_LEN ] ;
} ;
2001-09-25 16:49:28 +04:00
2001-09-28 17:15:30 +04:00
struct logical_volume ;
2001-09-25 16:49:28 +04:00
2001-09-28 17:15:30 +04:00
struct physical_volume {
struct id * id ;
struct device * dev ;
char * vg_name ;
2001-09-25 16:49:28 +04:00
2001-09-28 17:15:30 +04:00
uint32_t status ;
uint64_t size ;
2001-09-25 16:49:28 +04:00
2001-09-28 17:15:30 +04:00
/* physical extents */
uint64_t pe_size ;
uint64_t pe_start ;
uint32_t pe_count ;
uint32_t pe_allocated ;
} ;
2001-09-25 16:49:28 +04:00
2001-09-28 17:15:30 +04:00
struct pe_specifier {
struct physical_volume * pv ;
uint32_t pe ;
} ;
2001-09-25 16:49:28 +04:00
2001-09-28 17:15:30 +04:00
struct logical_volume {
/* disk */
struct id * id ;
char * name ;
2001-09-25 16:49:28 +04:00
2001-09-28 17:15:30 +04:00
uint32_t access ;
uint32_t status ;
uint32_t open ;
2001-09-25 16:49:28 +04:00
2001-09-28 17:15:30 +04:00
uint64_t size ;
uint32_t le_count ;
2001-09-25 16:49:28 +04:00
2001-09-28 17:15:30 +04:00
/* le -> pe mapping array */
struct pe_specifier * map ;
} ;
2001-09-25 16:49:28 +04:00
2001-09-28 17:15:30 +04:00
struct volume_group {
struct id * id ;
char * name ;
2001-09-25 16:49:28 +04:00
2001-09-28 17:15:30 +04:00
uint64_t extent_size ;
uint32_t extent_count ;
uint32_t free_count ;
2001-09-25 16:49:28 +04:00
2001-09-28 17:15:30 +04:00
/* physical volumes */
uint32_t pv_count ;
struct physical_volume * * pv ;
2001-09-25 16:49:28 +04:00
2001-09-28 17:15:30 +04:00
/* logical volumes */
uint32_t lv_count ;
struct logical_volume * * lv ;
} ;
2001-09-25 16:49:28 +04:00
2001-09-28 17:15:30 +04:00
/* ownership of returned objects passes */
struct io_space {
struct str_list * ( * get_vgs ) ( struct io_space * is ) ;
struct dev_list * ( * get_pvs ) ( struct io_space * is ) ;
2001-09-25 16:49:28 +04:00
2001-09-28 17:15:30 +04:00
struct physical_volume * read_pv ( struct io_space * is ,
struct device * dev ) ;
int write_pv ( struct io_space * is , struct physical_volume * pv ) ;
2001-09-25 16:49:28 +04:00
2001-09-28 17:15:30 +04:00
struct volume_group * ( * read_vg ) ( struct io_space * is ,
const char * vg_name ) ;
int ( * write_vg ) ( struct io_space * is , struct volume_group * vg ) ;
void ( * destructor ) ( struct io_space * is ) ;
2001-09-25 16:49:28 +04:00
2001-09-28 17:15:30 +04:00
struct device_manager * mgr ;
void * private ;
} ;
2001-09-25 16:49:28 +04:00
2001-09-28 17:15:30 +04:00
struct io_space * create_text_format ( struct device_manager * mgr ,
const char * text_file ) ;
struct io_space * create_lvm1_format ( struct device_manager * mgr ) ;
2001-09-25 16:49:28 +04:00
2001-09-28 17:15:30 +04:00
inline struct volume_group * read_vg ( struct io_space * f )
{
struct dev_list * pvs = f - > get_pvs ( ) ;
return f - > read_vg ( pvs ) ;
}
2001-09-25 16:49:28 +04:00
2001-09-28 17:15:30 +04:00
inline int write_vg ( struct io_object * f , struct volume_group * vg )
{
return f - > write_vg ( vg ) ;
}
2001-09-25 16:49:28 +04:00
2001-09-28 17:15:30 +04:00
inline int write_backup ( struct io_format * orig , struct io_format * text )
{
2001-09-25 16:49:28 +04:00
2001-09-28 17:15:30 +04:00
}
2001-09-25 16:49:28 +04:00
2001-09-28 17:15:30 +04:00
int id_eq ( struct id * op1 , struct id * op2 ) ;
struct volume_group * create_vg ( ) ;
int destroy_vg ( struct volume_group * vg ) ;
int add_pv ( struct volume_group * vg , struct physical_volume * pv ) ;
struct physical_volume * find_pv ( struct volume_group * vg ,
struct physical_volume * pv ) ;
2001-09-25 16:49:28 +04:00
2001-09-28 17:15:30 +04:00
int add_lv ( struct volume_group * vg , struct logical_volume * lv ) ;
struct logical_volume * find_lv ( struct volume_group * vg ,
struct logical_volume * lv ) ;
struct io_handler {
struct volume_group * read_vg ( ) ;
int write_vg ( struct volume_group * vg ) ;
} ;
# endif