2002-11-18 16:53:58 +03:00
/*
* Copyright ( C ) 2001 Sistina Software ( UK ) Limited .
*
* This file is released under the LGPL .
*
*/
# ifndef _LVM_CACHE_H
# define _LVM_CACHE_H
# include "dev-cache.h"
# include "uuid.h"
# include "label.h"
# include "metadata.h"
# define ORPHAN ""
2003-07-05 02:34:56 +04:00
# define CACHE_INVALID 0x00000001
# define CACHE_LOCKED 0x00000002
2002-11-18 16:53:58 +03:00
/* LVM specific per-volume info */
/* Eventual replacement for struct physical_volume perhaps? */
2003-07-05 02:34:56 +04:00
struct lvmcache_vginfo {
2002-11-18 16:53:58 +03:00
struct list list ; /* Join these vginfos together */
2003-07-05 02:34:56 +04:00
struct list infos ; /* List head for lvmcache_infos */
2002-11-18 16:53:58 +03:00
char * vgname ; /* "" == orphan */
char vgid [ ID_LEN + 1 ] ;
2002-12-20 02:25:55 +03:00
const struct format_type * fmt ;
2002-11-18 16:53:58 +03:00
} ;
2003-07-05 02:34:56 +04:00
struct lvmcache_info {
2002-11-18 16:53:58 +03:00
struct list list ; /* Join VG members together */
struct list mdas ; /* list head for metadata areas */
struct list das ; /* list head for data areas */
2003-07-05 02:34:56 +04:00
struct lvmcache_vginfo * vginfo ; /* NULL == unknown */
2002-11-18 16:53:58 +03:00
struct label * label ;
2002-12-20 02:25:55 +03:00
const struct format_type * fmt ;
2002-11-18 16:53:58 +03:00
struct device * dev ;
uint64_t device_size ; /* Bytes */
uint32_t status ;
} ;
2003-07-05 02:34:56 +04:00
int lvmcache_init ( void ) ;
void lvmcache_destroy ( void ) ;
2002-11-18 16:53:58 +03:00
/* Set full_scan to 1 to reread every filtered device label */
2003-07-05 02:34:56 +04:00
int lvmcache_label_scan ( struct cmd_context * cmd , int full_scan ) ;
2002-11-18 16:53:58 +03:00
/* Add/delete a device */
2003-07-05 02:34:56 +04:00
struct lvmcache_info * lvmcache_add ( struct labeller * labeller , const char * pvid ,
struct device * dev ,
const char * vgname , const char * vgid ) ;
void lvmcache_del ( struct lvmcache_info * info ) ;
2002-11-18 16:53:58 +03:00
/* Update things */
2003-07-05 02:34:56 +04:00
int lvmcache_update_vgname ( struct lvmcache_info * info , const char * vgname ) ;
int lvmcache_update_vg ( struct volume_group * vg ) ;
void lvmcache_lock_vgname ( const char * vgname , int read_only ) ;
void lvmcache_unlock_vgname ( const char * vgname ) ;
2002-11-18 16:53:58 +03:00
/* Queries */
2002-12-20 02:25:55 +03:00
const struct format_type * fmt_from_vgname ( const char * vgname ) ;
2003-07-05 02:34:56 +04:00
struct lvmcache_vginfo * vginfo_from_vgname ( const char * vgname ) ;
struct lvmcache_vginfo * vginfo_from_vgid ( const char * vgid ) ;
struct lvmcache_info * info_from_pvid ( const char * pvid ) ;
2002-11-18 16:53:58 +03:00
struct device * device_from_pvid ( struct cmd_context * cmd , struct id * pvid ) ;
2003-07-05 02:34:56 +04:00
int vgs_locked ( void ) ;
2002-11-18 16:53:58 +03:00
/* Returns list of struct str_lists containing pool-allocated copy of vgnames */
/* Set full_scan to 1 to reread every filtered device label */
2003-07-05 02:34:56 +04:00
struct list * lvmcache_get_vgnames ( struct cmd_context * cmd , int full_scan ) ;
2002-11-18 16:53:58 +03:00
# endif