2002-11-18 16:53:58 +03:00
/*
2004-03-30 23:35:44 +04:00
* Copyright ( C ) 2001 - 2004 Sistina Software , Inc . All rights reserved .
* Copyright ( C ) 2004 Red Hat , Inc . All rights reserved .
2002-11-18 16:53:58 +03:00
*
2004-03-30 23:35:44 +04:00
* This file is part of LVM2 .
*
* This copyrighted material is made available to anyone wishing to use ,
* modify , copy , or redistribute it subject to the terms and conditions
* of the GNU General Public License v .2 .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software Foundation ,
* Inc . , 59 Temple Place , Suite 330 , Boston , MA 02111 - 1307 USA
2002-11-18 16:53:58 +03:00
*
*/
# ifndef _LVM_CACHE_H
# define _LVM_CACHE_H
# include "dev-cache.h"
# include "uuid.h"
# include "label.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? */
2004-05-05 01:25:57 +04:00
struct cmd_context ;
struct format_type ;
struct volume_group ;
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 */
2005-04-06 17:47:41 +04:00
const struct format_type * fmt ;
2002-11-18 16:53:58 +03:00
char * vgname ; /* "" == orphan */
char vgid [ ID_LEN + 1 ] ;
2005-04-06 17:47:41 +04:00
char _padding [ 7 ] ;
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
2005-03-08 16:46:17 +03:00
/* Set full_scan to 1 to reread every filtered device label or
* 2 to rescan / dev for new devices */
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