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-10-02 02:12:10 +04:00
* This is the in core representation of a volume group and its
2001-09-28 17:15:30 +04:00
* associated physical and logical volumes .
2001-09-25 16:49:28 +04:00
*/
2001-10-01 19:14:39 +04:00
# ifndef _LVM_METADATA_H
# define _LVM_METADATA_H
2001-09-25 16:49:28 +04:00
2001-10-02 02:12:10 +04:00
# include <sys/types.h>
2001-10-01 20:21:21 +04:00
# include "dev-cache.h"
2001-10-02 21:09:05 +04:00
# include "list.h"
2001-10-01 20:21:21 +04:00
2001-09-28 17:15:30 +04:00
# define ID_LEN 32
2001-10-02 21:09:05 +04:00
# define NAME_LEN 128
2001-10-02 02:12:10 +04:00
/* Various flags */
/* Note that the bits no longer necessarily correspond to LVM1 disk format */
# define STATUS_ACTIVE 0x01 /* PV VG LV */
# define STATUS_EXPORTED 0x02 /* VG */
# define STATUS_EXTENDABLE 0x04 /* VG */
# define STATUS_ALLOCATED 0x02 /* PV */
# define STATUS_SPINDOWN 0x02 /* LV */
# define STATUS_BADBLOCK_ON 0x04 /* LV */
# define STATUS_ALLOC_STRICT 0x08 /* LV */
# define STATUS_ALLOC_CONTIGUOUS 0x10 /* LV */
# define ACCESS_READ 0x01 /* LV VG */
# define ACCESS_WRITE 0x02 /* LV VG */
# define ACCESS_SNAPSHOT 0x04 /* LV */
# define ACCESS_SNAPSHOT_ORG 0x08 /* LV */
# define ACCESS_CLUSTERED 0x04 /* VG */
# define ACCESS_SHARED 0x08 /* VG */
2001-10-02 21:09:05 +04:00
# define EXPORTED_TAG "PV_EXP" /* Identifier of exported PV */
# define IMPORTED_TAG "PV_IMP" /* Identifier of imported PV */
2001-09-28 17:15:30 +04:00
struct id {
2001-10-02 21:09:05 +04:00
__uint8_t uuid [ ID_LEN ] ;
2001-09-28 17:15:30 +04:00
} ;
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-10-02 21:09:05 +04:00
char * exported ;
2001-09-25 16:49:28 +04:00
2001-10-02 02:12:10 +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 */
2001-10-02 02:12:10 +04:00
__uint64_t pe_size ;
__uint64_t pe_start ;
__uint32_t pe_count ;
__uint32_t pe_allocated ;
2001-09-28 17:15:30 +04:00
} ;
2001-09-25 16:49:28 +04:00
2001-09-28 17:15:30 +04:00
struct pe_specifier {
struct physical_volume * pv ;
2001-10-02 02:12:10 +04:00
__uint32_t pe ;
2001-09-28 17:15:30 +04:00
} ;
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-10-02 02:12:10 +04:00
__uint32_t access ;
__uint32_t status ;
__uint32_t open ;
2001-09-25 16:49:28 +04:00
2001-10-02 02:12:10 +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-10-03 16:34:08 +04:00
__uint32_t status ;
__uint32_t access ;
2001-10-02 02:12:10 +04:00
__uint64_t extent_size ;
__uint32_t extent_count ;
__uint32_t free_count ;
2001-09-25 16:49:28 +04:00
2001-10-04 00:38:07 +04:00
__uint32_t max_lv ;
__uint32_t max_pv ;
2001-09-28 17:15:30 +04:00
/* physical volumes */
2001-10-02 02:12:10 +04:00
__uint32_t pv_count ;
2001-09-28 17:15:30 +04:00
struct physical_volume * * pv ;
2001-09-25 16:49:28 +04:00
2001-09-28 17:15:30 +04:00
/* logical volumes */
2001-10-02 02:12:10 +04:00
__uint32_t lv_count ;
2001-09-28 17:15:30 +04:00
struct logical_volume * * lv ;
} ;
2001-09-25 16:49:28 +04:00
2001-10-02 21:09:05 +04:00
struct string_list {
struct list_head list ;
char * string ;
} ;
struct pv_list {
struct list_head list ;
struct physical_volume pv ;
} ;
2001-10-02 02:12:10 +04:00
2001-09-28 17:15:30 +04:00
/* ownership of returned objects passes */
struct io_space {
2001-10-02 21:09:05 +04:00
struct string_list * ( * get_vgs ) ( struct io_space * is ) ;
struct pv_list * ( * get_pvs ) ( struct io_space * is ) ;
2001-09-25 16:49:28 +04:00
2001-10-02 02:12:10 +04:00
struct physical_volume * ( * pv_read ) ( struct io_space * is ,
2001-09-28 17:15:30 +04:00
struct device * dev ) ;
2001-10-02 02:12:10 +04:00
int ( * pv_write ) ( struct io_space * is , struct physical_volume * pv ) ;
2001-09-25 16:49:28 +04:00
2001-10-01 20:21:21 +04:00
struct volume_group * ( * vg_read ) ( struct io_space * is ,
2001-09-28 17:15:30 +04:00
const char * vg_name ) ;
2001-10-01 20:21:21 +04:00
int ( * vg_write ) ( struct io_space * is , struct volume_group * vg ) ;
2001-10-02 02:12:10 +04:00
void ( * destroy ) ( struct io_space * is ) ;
2001-09-25 16:49:28 +04:00
2001-10-01 20:21:21 +04:00
struct dev_filter * filter ;
2001-09-28 17:15:30 +04:00
void * private ;
} ;
2001-09-25 16:49:28 +04:00
2001-10-02 02:12:10 +04:00
/* FIXME: Move to other files */
struct io_space * create_text_format ( struct dev_filter * filter ,
2001-09-28 17:15:30 +04:00
const char * text_file ) ;
2001-10-02 02:12:10 +04:00
struct io_space * create_lvm_v1_format ( struct dev_filter * filter ) ;
2001-09-25 16:49:28 +04:00
2001-10-02 02:12:10 +04:00
inline int write_backup ( struct io_space * orig , struct io_space * text )
2001-09-28 17:15:30 +04:00
{
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 ) ;
2001-10-02 02:12:10 +04:00
struct volume_group * vg_create ( ) ;
struct physical_volume * pv_create ( ) ;
2001-09-28 17:15:30 +04:00
2001-10-02 02:12:10 +04:00
int vg_destroy ( struct volume_group * vg ) ;
int pv_add ( struct volume_group * vg , struct physical_volume * pv ) ;
2001-10-03 16:34:08 +04:00
int pv_remove ( struct volume_group * vg , struct physical_volume * pv ) ;
2001-10-02 02:12:10 +04:00
struct physical_volume * pv_find ( struct volume_group * vg ,
2001-10-03 16:34:08 +04:00
const char * pv_name ) ;
2001-09-25 16:49:28 +04:00
2001-10-02 02:12:10 +04:00
int lv_add ( struct volume_group * vg , struct logical_volume * lv ) ;
2001-10-03 16:34:08 +04:00
int lv_remove ( struct volume_group * vg , struct logical_volume * lv ) ;
2001-10-02 02:12:10 +04:00
struct logical_volume * lv_find ( struct volume_group * vg ,
2001-10-03 16:34:08 +04:00
const char * lv_name ) ;
2001-09-28 17:15:30 +04:00
# endif