2011-05-13 12:17:26 +04:00
/*
2012-02-28 22:35:04 +04:00
* Copyright ( C ) 2011 - 2012 Red Hat , Inc .
2011-05-13 12:17:26 +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 Lesser General Public License v .2 .1 .
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program ; if not , write to the Free Software Foundation ,
2016-01-21 13:49:46 +03:00
* Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 USA
2011-05-13 12:17:26 +04:00
*/
# ifndef _LVM_LVMETAD_CLIENT_H
# define _LVM_LVMETAD_CLIENT_H
# include "daemon-client.h"
2012-02-28 22:35:04 +04:00
2013-11-26 17:51:23 +04:00
# define LVMETAD_SOCKET DEFAULT_RUN_DIR " / lvmetad.socket"
2016-05-20 00:19:38 +03:00
# define LVMETAD_TOKEN_UPDATE_IN_PROGRESS "update in progress"
2016-04-19 18:51:11 +03:00
# define LVMETAD_DISABLE_REASON_DIRECT "DIRECT"
# define LVMETAD_DISABLE_REASON_LVM1 "LVM1"
# define LVMETAD_DISABLE_REASON_DUPLICATES "DUPLICATES"
2016-06-18 00:37:30 +03:00
# define LVMETAD_DISABLE_REASON_VGRESTORE "VGRESTORE"
2016-04-19 18:51:11 +03:00
2012-02-28 22:35:04 +04:00
struct volume_group ;
2011-05-13 12:17:26 +04:00
/* Different types of replies we may get from lvmetad. */
typedef struct {
daemon_reply r ;
const char * * uuids ; /* NULL terminated array */
} lvmetad_uuidlist ;
typedef struct {
daemon_reply r ;
2011-08-30 19:44:01 +04:00
struct dm_config_tree * cft ;
2011-05-13 12:17:26 +04:00
} lvmetad_vg ;
/* Get a list of VG UUIDs that match a given VG name. */
lvmetad_uuidlist lvmetad_lookup_vgname ( daemon_handle h , const char * name ) ;
/* Get the metadata of a single VG, identified by UUID. */
lvmetad_vg lvmetad_get_vg ( daemon_handle h , const char * uuid ) ;
/*
* Add and remove PVs on demand . Udev - driven systems will use this interface
* instead of scanning .
*/
daemon_reply lvmetad_add_pv ( daemon_handle h , const char * pv_uuid , const char * mda_content ) ;
daemon_reply lvmetad_remove_pv ( daemon_handle h , const char * pv_uuid ) ;
/* Trigger a full disk scan, throwing away all caches. XXX do we eventually want
2012-02-28 22:35:04 +04:00
* this ? Probably not yet , anyway .
2011-05-13 12:17:26 +04:00
* daemon_reply lvmetad_rescan ( daemon_handle h ) ;
*/
/*
* Update the version of metadata of a volume group . The VG has to be locked for
* writing for this , and the VG metadata here has to match whatever has been
* written to the disk ( under this lock ) . This initially avoids the requirement
* for lvmetad to write to disk ( in later revisions , lvmetad_supersede_vg may
* also do the writing , or we probably add another function to do that ) .
*/
daemon_reply lvmetad_supersede_vg ( daemon_handle h , struct volume_group * vg ) ;
2012-02-28 22:35:04 +04:00
/* Wrappers to open/close connection */
2011-05-13 12:17:26 +04:00
2012-01-16 12:25:32 +04:00
static inline daemon_handle lvmetad_open ( const char * socket )
2011-05-13 12:17:26 +04:00
{
daemon_info lvmetad_info = {
. path = " lvmetad " ,
2013-11-26 17:51:23 +04:00
. socket = socket ? : LVMETAD_SOCKET ,
2012-02-24 03:52:11 +04:00
. protocol = " lvmetad " ,
. protocol_version = 1 ,
2012-02-23 17:11:07 +04:00
. autostart = 0
2011-05-13 12:17:26 +04:00
} ;
return daemon_open ( lvmetad_info ) ;
}
static inline void lvmetad_close ( daemon_handle h )
{
return daemon_close ( h ) ;
}
# endif