2012-02-23 17:11:07 +04:00
/*
2012-02-28 22:22:52 +04:00
* Copyright ( C ) 2012 Red Hat , Inc .
2012-02-23 17:11:07 +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 ,
* Inc . , 59 Temple Place , Suite 330 , Boston , MA 02111 - 1307 USA
*/
# ifndef _LVM_METAD_H
# define _LVM_METAD_H
2012-09-26 16:44:03 +04:00
# include "config-util.h"
2012-08-11 12:37:28 +04:00
2012-02-23 17:11:07 +04:00
struct volume_group ;
struct cmd_context ;
struct dm_config_tree ;
2012-08-23 18:12:45 +04:00
enum activation_change ;
2012-02-23 17:11:07 +04:00
2012-12-12 15:51:28 +04:00
typedef int ( * activation_handler ) ( struct cmd_context * cmd ,
2014-03-14 15:07:41 +04:00
const char * vgname , const char * vgid ,
2014-03-14 13:44:14 +04:00
int partial , int changed ,
2012-08-23 18:12:45 +04:00
enum activation_change activate ) ;
2012-06-27 16:59:34 +04:00
2012-02-28 22:22:52 +04:00
# ifdef LVMETAD_SUPPORT
2012-02-23 17:11:07 +04:00
/*
2015-05-22 15:25:54 +03:00
* Sets up a global handle for our process .
2012-02-23 17:11:07 +04:00
*/
2012-08-13 21:44:10 +04:00
void lvmetad_init ( struct cmd_context * ) ;
2012-02-23 17:11:07 +04:00
/*
* Override the use of lvmetad for retrieving scan results and metadata .
*/
2014-09-30 18:08:05 +04:00
void lvmetad_set_active ( struct cmd_context * , int ) ;
2012-02-23 17:11:07 +04:00
2012-08-13 21:44:10 +04:00
/*
* Configure the socket that lvmetad_init will use to connect to the daemon .
*/
void lvmetad_set_socket ( const char * ) ;
2013-11-26 17:51:23 +04:00
/*
* Check whether lvmetad is used .
*/
int lvmetad_used ( void ) ;
/*
* Check if lvmetad socket is present ( either the one set by lvmetad_set_socket
* or the default one if not set ) . For example , this may be used before calling
* lvmetad_active ( ) check that does connect to the socket - this would produce
* various connection errors if the socket is not present .
*/
int lvmetad_socket_present ( void ) ;
2012-02-23 17:11:07 +04:00
/*
* Check whether lvmetad is active ( where active means both that it is running
2015-05-22 15:25:54 +03:00
* and that we have a working connection with it ) . It opens new connection
* with lvmetad in the process when lvmetad is supposed to be used and the
* connection is not open yet .
2012-02-23 17:11:07 +04:00
*/
int lvmetad_active ( void ) ;
2013-01-05 03:22:30 +04:00
/*
* Connect to lvmetad unless the connection is already open or lvmetad is
* not configured to be used . If we fail to connect , print a warning .
*/
void lvmetad_connect_or_warn ( void ) ;
2012-10-12 04:48:39 +04:00
2012-08-13 21:44:10 +04:00
/*
2015-05-22 15:25:54 +03:00
* Drop connection to lvmetad . A subsequent lvmetad_connect_or_warn or
* lvmetad_active will re - establish the connection ( possibly at a
* different socket path ) .
2012-08-13 21:44:10 +04:00
*/
void lvmetad_disconnect ( void ) ;
/*
* Set the " lvmetad validity token " ( currently only consists of the lvmetad
* filter . See lvm . conf .
*/
void lvmetad_set_token ( const struct dm_config_value * filter ) ;
2012-10-12 18:50:38 +04:00
/*
* Release allocated token .
*/
void lvmetad_release_token ( void ) ;
2013-01-05 07:07:43 +04:00
// FIXME What's described here doesn't appear to be implemented yet.
2012-02-23 17:11:07 +04:00
/*
* Send a new version of VG metadata to lvmetad . This is normally called after
* vg_write but before vg_commit . After vg_commit , lvmetad_vg_commit is called
* to seal the transaction . The result of lvmetad_vg_update is that the new
* metadata is stored tentatively in lvmetad , but it is not used until
* lvmetad_vg_commit . The request is validated immediately and lvmetad_vg_commit
* only constitutes a pointer update .
*/
int lvmetad_vg_update ( struct volume_group * vg ) ;
/*
* Inform lvmetad that a VG has been removed . This is not entirely safe , but is
* only needed during vgremove , which does not wipe PV labels and therefore
* cannot mark the PVs as gone .
*/
int lvmetad_vg_remove ( struct volume_group * vg ) ;
/*
* Notify lvmetad that a PV has been found . It is not an error if the PV is
* already marked as present in lvmetad . If a non - NULL vg pointer is supplied ,
* it is taken to represent the metadata read from the MDA ( s ) present on that
* PV . It * is * an error if : the VG is already known to lvmetad , the sequence
* number on the cached and on the discovered PV match but the metadata content
* does not .
*/
2013-01-05 03:45:22 +04:00
int lvmetad_pv_found ( const struct id * pvid , struct device * dev ,
2012-02-23 17:11:07 +04:00
const struct format_type * fmt , uint64_t label_sector ,
2012-06-27 16:59:34 +04:00
struct volume_group * vg , activation_handler handler ) ;
2012-02-23 17:11:07 +04:00
/*
2012-03-03 22:32:53 +04:00
* Inform the daemon that the device no longer exists .
2012-02-23 17:11:07 +04:00
*/
2012-06-27 16:59:34 +04:00
int lvmetad_pv_gone ( dev_t devno , const char * pv_name , activation_handler handler ) ;
int lvmetad_pv_gone_by_dev ( struct device * dev , activation_handler handler ) ;
2012-02-23 17:11:07 +04:00
/*
* Request a list of all PVs available to lvmetad . If requested , this will also
* read labels off all the PVs to populate lvmcache .
*/
int lvmetad_pv_list_to_lvmcache ( struct cmd_context * cmd ) ;
2012-03-03 00:46:36 +04:00
/*
* Lookup an individual PV .
* If found is not NULL , it is set according to whether or not the PV is found ,
* otherwise if the PV is not found an error is returned .
*/
int lvmetad_pv_lookup ( struct cmd_context * cmd , struct id pvid , int * found ) ;
int lvmetad_pv_lookup_by_dev ( struct cmd_context * cmd , struct device * dev , int * found ) ;
2012-02-23 17:11:07 +04:00
/*
* Request a list of all VGs available to lvmetad and use it to fill in
* lvmcache . .
*/
int lvmetad_vg_list_to_lvmcache ( struct cmd_context * cmd ) ;
2015-05-06 00:24:50 +03:00
/*
* Request a list of vgid / vgname pairs for all VGs known to lvmetad .
* Does not do vg_lookup ' s on each VG , and does not populate lvmcache .
*/
int lvmetad_get_vgnameids ( struct cmd_context * cmd , struct dm_list * vgnameids ) ;
2012-02-26 12:50:13 +04:00
/*
* Find a VG by its ID or its name in the lvmetad cache . Gives NULL if the VG is
* not found .
*/
struct volume_group * lvmetad_vg_lookup ( struct cmd_context * cmd ,
const char * vgname , const char * vgid ) ;
2012-02-23 17:11:07 +04:00
/*
2012-03-03 22:32:53 +04:00
* Scan a single device and update lvmetad with the result ( s ) .
2012-02-23 17:11:07 +04:00
*/
2012-09-10 00:05:59 +04:00
int lvmetad_pvscan_single ( struct cmd_context * cmd , struct device * dev ,
2015-03-10 21:56:25 +03:00
activation_handler handler , int ignore_obsolete ) ;
2012-02-23 17:11:07 +04:00
2012-09-10 00:05:59 +04:00
int lvmetad_pvscan_all_devs ( struct cmd_context * cmd , activation_handler handler ) ;
2015-02-23 20:03:03 +03:00
int lvmetad_pvscan_foreign_vgs ( struct cmd_context * cmd , activation_handler handler ) ;
2012-08-13 21:44:10 +04:00
2015-06-10 17:27:12 +03:00
int lvmetad_vg_clear_outdated_pvs ( struct volume_group * vg ) ;
2014-11-07 21:51:42 +03:00
void lvmetad_validate_global_cache ( struct cmd_context * cmd , int force ) ;
2015-06-10 17:27:12 +03:00
2015-11-30 20:54:56 +03:00
int lvmetad_vg_is_foreign ( struct cmd_context * cmd , const char * vgname , const char * vgid ) ;
2012-02-28 22:22:52 +04:00
# else /* LVMETAD_SUPPORT */
2012-08-13 21:44:10 +04:00
# define lvmetad_init(cmd) do { } while (0)
# define lvmetad_disconnect() do { } while (0)
2014-09-30 18:08:05 +04:00
# define lvmetad_set_active(cmd, a) do { } while (0)
2012-08-13 21:44:10 +04:00
# define lvmetad_set_socket(a) do { } while (0)
2013-11-26 17:51:23 +04:00
# define lvmetad_used() (0)
# define lvmetad_socket_present() (0)
2012-02-28 22:22:52 +04:00
# define lvmetad_active() (0)
2013-01-05 03:22:30 +04:00
# define lvmetad_connect_or_warn() do { } while (0)
2012-08-13 21:44:10 +04:00
# define lvmetad_set_token(a) do { } while (0)
2012-10-12 19:16:28 +04:00
# define lvmetad_release_token() do { } while (0)
2012-02-28 22:22:52 +04:00
# define lvmetad_vg_update(vg) (1)
# define lvmetad_vg_remove(vg) (1)
2013-01-05 03:45:22 +04:00
# define lvmetad_pv_found(pvid, dev, fmt, label_sector, vg, handler) (1)
2012-06-27 16:59:34 +04:00
# define lvmetad_pv_gone(devno, pv_name, handler) (1)
# define lvmetad_pv_gone_by_dev(dev, handler) (1)
2012-02-28 22:22:52 +04:00
# define lvmetad_pv_list_to_lvmcache(cmd) (1)
2012-03-03 00:46:36 +04:00
# define lvmetad_pv_lookup(cmd, pvid, found) (0)
# define lvmetad_pv_lookup_by_dev(cmd, dev, found) (0)
2012-02-28 22:22:52 +04:00
# define lvmetad_vg_list_to_lvmcache(cmd) (1)
2015-05-27 12:44:33 +03:00
# define lvmetad_get_vgnameids(cmd, vgnameids) do { } while (0)
2012-02-28 22:22:52 +04:00
# define lvmetad_vg_lookup(cmd, vgname, vgid) (NULL)
2015-03-10 21:56:25 +03:00
# define lvmetad_pvscan_single(cmd, dev, handler, ignore_obsolete) (0)
2012-09-10 00:05:59 +04:00
# define lvmetad_pvscan_all_devs(cmd, handler) (0)
2015-02-23 20:03:03 +03:00
# define lvmetad_pvscan_foreign_vgs(cmd, handler) (0)
2015-06-10 17:27:12 +03:00
# define lvmetad_vg_clear_outdated_pvs(vg) (1)
2014-11-07 21:51:42 +03:00
# define lvmetad_validate_global_cache(cmd, force) do { } while (0)
2015-11-30 20:54:56 +03:00
# define lvmetad_vg_is_foreign(cmd, vgname, vgid) (0)
2012-02-23 17:11:07 +04:00
2012-02-28 22:22:52 +04:00
# endif /* LVMETAD_SUPPORT */
# endif