2001-09-25 16:49:28 +04:00
/*
2004-03-30 23:35:44 +04:00
* Copyright ( C ) 2001 - 2004 Sistina Software , Inc . All rights reserved .
2013-02-21 13:25:44 +04:00
* Copyright ( C ) 2004 - 2013 Red Hat , Inc . All rights reserved .
2001-09-25 16:49:28 +04:00
*
2004-03-30 23:35:44 +04:00
* This file is part of LVM2 .
2001-09-25 16:49:28 +04:00
*
2004-03-30 23:35:44 +04:00
* This copyrighted material is made available to anyone wishing to use ,
* modify , copy , or redistribute it subject to the terms and conditions
2007-08-21 00:55:30 +04:00
* of the GNU Lesser General Public License v .2 .1 .
2004-03-30 23:35:44 +04:00
*
2007-08-21 00:55:30 +04:00
* You should have received a copy of the GNU Lesser General Public License
2004-03-30 23:35:44 +04:00
* 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
2004-03-30 23:35:44 +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
2002-11-18 17:04:08 +03:00
# include "ctype.h"
2001-10-01 20:21:21 +04:00
# include "dev-cache.h"
2006-04-19 19:33:07 +04:00
# include "lvm-string.h"
2007-07-18 19:38:58 +04:00
# include "metadata-exported.h"
2002-12-20 02:25:55 +03:00
2007-07-18 19:38:58 +04:00
//#define MAX_STRIPES 128U
//#define SECTOR_SHIFT 9L
2010-02-14 06:21:06 +03:00
//#define SECTOR_SIZE ( 1L << SECTOR_SHIFT )
2007-07-18 19:38:58 +04:00
//#define STRIPE_SIZE_MIN ( (unsigned) lvm_getpagesize() >> SECTOR_SHIFT) /* PAGESIZE in sectors */
//#define STRIPE_SIZE_MAX ( 512L * 1024L >> SECTOR_SHIFT) /* 512 KB in sectors */
//#define STRIPE_SIZE_LIMIT ((UINT_MAX >> 2) + 1)
//#define MAX_RESTRICTED_LVS 255 /* Used by FMT_RESTRICTED_LVIDS */
2014-10-14 21:12:15 +04:00
# define MIN_PE_SIZE (8192L >> SECTOR_SHIFT) /* 8 KB in sectors - format1 only */
# define MAX_PE_SIZE (16L * 1024L * (1024L >> SECTOR_SHIFT) * 1024L) /* format1 only */
2008-12-19 18:24:52 +03:00
# define MIRROR_LOG_OFFSET 2 /* sectors */
2009-04-10 13:59:18 +04:00
# define VG_MEMPOOL_CHUNK 10240 /* in bytes, hint only */
2008-12-19 18:24:52 +03:00
/*
* Ceiling ( n / sz )
*/
# define dm_div_up(n, sz) (((n) + (sz) - 1) / (sz))
/*
* Ceiling ( n / size ) * size
*/
# define dm_round_up(n, sz) (dm_div_up((n), (sz)) * (sz))
2001-10-02 02:12:10 +04:00
/* Various flags */
2011-09-06 22:49:31 +04:00
/* See metadata-exported.h for the complete list. */
2001-10-02 02:12:10 +04:00
/* Note that the bits no longer necessarily correspond to LVM1 disk format */
2002-11-18 17:04:08 +03:00
/* May any free extents on this PV be used or must they be left free? */
2008-09-19 10:42:00 +04:00
2011-09-06 22:49:31 +04:00
# define SPINDOWN_LV UINT64_C(0x00000010) /* LV */
# define BADBLOCK_ON UINT64_C(0x00000020) /* LV */
2014-09-18 02:00:41 +04:00
//#define VIRTUAL UINT64_C(0x00010000) /* LV - internal use only */
2011-09-06 22:49:31 +04:00
# define PRECOMMITTED UINT64_C(0x00200000) /* VG - internal use only */
# define POSTORDER_FLAG UINT64_C(0x02000000) /* Not real flags, reserved for */
# define POSTORDER_OPEN_FLAG UINT64_C(0x04000000) /* temporary use inside vg_read_internal. */
2006-05-10 01:23:51 +04:00
2011-09-06 22:49:31 +04:00
# define SHARED UINT64_C(0x00000800) /* VG */
2001-10-02 02:12:10 +04:00
2002-11-18 17:04:08 +03:00
/* Format features flags */
2006-05-10 01:23:51 +04:00
# define FMT_PRECOMMIT 0x00000040U /* Supports pre-commit? */
2002-11-18 17:04:08 +03:00
2011-08-30 18:55:15 +04:00
struct dm_config_tree ;
2002-11-18 17:04:08 +03:00
struct metadata_area ;
2011-10-22 20:44:23 +04:00
struct alloc_handle ;
2012-02-23 17:11:07 +04:00
struct lvmcache_info ;
2015-03-19 02:43:02 +03:00
struct cached_vg_fmtdata ;
2002-11-18 17:04:08 +03:00
/* Per-format per-metadata area operations */
struct metadata_area_ops {
2012-02-23 17:11:07 +04:00
struct dm_list list ;
2002-11-18 17:04:08 +03:00
struct volume_group * ( * vg_read ) ( struct format_instance * fi ,
const char * vg_name ,
2012-02-29 06:35:35 +04:00
struct metadata_area * mda ,
2015-03-19 02:43:02 +03:00
struct cached_vg_fmtdata * * vg_fmtdata ,
unsigned * use_previous_vg ,
2012-02-29 06:35:35 +04:00
int single_device ) ;
2005-04-06 22:59:55 +04:00
struct volume_group * ( * vg_read_precommit ) ( struct format_instance * fi ,
const char * vg_name ,
2015-03-19 02:43:02 +03:00
struct metadata_area * mda ,
struct cached_vg_fmtdata * * vg_fmtdata ,
unsigned * use_previous_vg ) ;
2002-11-18 17:04:08 +03:00
/*
* Write out complete VG metadata . You must ensure internal
* consistency before calling . eg . PEs can ' t refer to PVs not
* part of the VG .
*
* It is also the responsibility of the caller to ensure external
* consistency , eg by calling pv_write ( ) if removing PVs from
* a VG or calling vg_write ( ) a second time if splitting a VG
* into two .
*
* vg_write ( ) should not read or write from any PVs not included
* in the volume_group structure it is handed .
* ( format1 currently breaks this rule . )
*/
int ( * vg_write ) ( struct format_instance * fid , struct volume_group * vg ,
struct metadata_area * mda ) ;
2005-04-06 22:59:55 +04:00
int ( * vg_precommit ) ( struct format_instance * fid ,
struct volume_group * vg ,
struct metadata_area * mda ) ;
2002-11-18 17:04:08 +03:00
int ( * vg_commit ) ( struct format_instance * fid ,
struct volume_group * vg , struct metadata_area * mda ) ;
2003-07-05 02:34:56 +04:00
int ( * vg_revert ) ( struct format_instance * fid ,
struct volume_group * vg , struct metadata_area * mda ) ;
2002-11-18 17:04:08 +03:00
int ( * vg_remove ) ( struct format_instance * fi , struct volume_group * vg ,
struct metadata_area * mda ) ;
2007-11-05 20:17:55 +03:00
2010-06-29 00:31:59 +04:00
/*
* Per location copy constructor .
*/
void * ( * mda_metadata_locn_copy ) ( struct dm_pool * mem , void * metadata_locn ) ;
2010-06-30 17:51:11 +04:00
2010-06-30 02:37:32 +04:00
/*
2010-06-30 17:51:11 +04:00
* Per location description for logging .
2010-06-30 02:37:32 +04:00
*/
2010-06-30 17:51:11 +04:00
const char * ( * mda_metadata_locn_name ) ( void * metadata_locn ) ;
2010-08-26 16:08:19 +04:00
uint64_t ( * mda_metadata_locn_offset ) ( void * metadata_locn ) ;
2010-06-29 00:31:59 +04:00
2007-11-05 20:17:55 +03:00
/*
* Returns number of free sectors in given metadata area .
*/
uint64_t ( * mda_free_sectors ) ( struct metadata_area * mda ) ;
2009-01-10 01:44:33 +03:00
/*
* Returns number of total sectors in given metadata area .
*/
uint64_t ( * mda_total_sectors ) ( struct metadata_area * mda ) ;
2007-03-23 15:43:17 +03:00
/*
* Check if metadata area belongs to vg
*/
int ( * mda_in_vg ) ( struct format_instance * fi ,
struct volume_group * vg , struct metadata_area * mda ) ;
2007-04-26 01:10:55 +04:00
/*
* Analyze a metadata area on a PV .
*/
int ( * pv_analyze_mda ) ( const struct format_type * fmt ,
struct metadata_area * mda ) ;
2010-06-29 00:31:38 +04:00
/*
2010-06-29 00:32:44 +04:00
* Do these two metadata_area structures match with respect to
* their underlying location ?
2010-06-29 00:31:38 +04:00
*/
unsigned ( * mda_locns_match ) ( struct metadata_area * mda1 ,
struct metadata_area * mda2 ) ;
2011-06-15 21:45:02 +04:00
struct device * ( * mda_get_device ) ( struct metadata_area * mda ) ;
2012-08-11 12:37:28 +04:00
int ( * mda_export_text ) ( struct metadata_area * mda , struct dm_config_tree * cft ,
struct dm_config_node * parent ) ;
2012-02-23 17:11:07 +04:00
int ( * mda_import_text ) ( struct lvmcache_info * info , const struct dm_config_node * cn ) ;
2002-11-18 17:04:08 +03:00
} ;
2011-06-15 21:45:02 +04:00
# define MDA_IGNORED 0x00000001
# define MDA_INCONSISTENT 0x00000002
2014-05-26 16:23:33 +04:00
# define MDA_FAILED 0x00000004
2010-06-29 00:30:14 +04:00
2002-04-24 22:20:51 +04:00
struct metadata_area {
2008-11-04 01:14:30 +03:00
struct dm_list list ;
2002-11-18 17:04:08 +03:00
struct metadata_area_ops * ops ;
2002-04-24 22:20:51 +04:00
void * metadata_locn ;
2010-10-05 21:34:05 +04:00
uint32_t status ;
2002-04-24 22:20:51 +04:00
} ;
2010-06-29 00:31:59 +04:00
struct metadata_area * mda_copy ( struct dm_pool * mem ,
struct metadata_area * mda ) ;
2002-04-24 22:20:51 +04:00
2010-06-29 00:30:14 +04:00
unsigned mda_is_ignored ( struct metadata_area * mda ) ;
2010-06-30 02:25:58 +04:00
void mda_set_ignored ( struct metadata_area * mda , unsigned ignored ) ;
2010-06-29 00:31:38 +04:00
unsigned mda_locns_match ( struct metadata_area * mda1 , struct metadata_area * mda2 ) ;
2011-06-15 21:45:02 +04:00
struct device * mda_get_device ( struct metadata_area * mda ) ;
2011-03-11 17:30:27 +03:00
struct format_instance_ctx {
uint32_t type ;
union {
const char * pv_id ;
struct {
const char * vg_name ;
const char * vg_id ;
} vg_ref ;
void * private ;
} context ;
} ;
struct format_instance * alloc_fid ( const struct format_type * fmt ,
const struct format_instance_ctx * fic ) ;
2011-03-11 17:50:13 +03:00
/*
* Format instance must always be set using pv_set_fid or vg_set_fid
* ( NULL value as well ) , never asign it directly ! This is essential
* for proper reference counting for the format instance .
*/
void pv_set_fid ( struct physical_volume * pv , struct format_instance * fid ) ;
2011-02-21 15:10:58 +03:00
void vg_set_fid ( struct volume_group * vg , struct format_instance * fid ) ;
2011-03-11 17:50:13 +03:00
2011-02-28 16:19:02 +03:00
/* FIXME: Add generic interface for mda counts based on given key. */
2011-02-21 15:05:49 +03:00
int fid_add_mda ( struct format_instance * fid , struct metadata_area * mda ,
const char * key , size_t key_len , const unsigned sub_key ) ;
int fid_add_mdas ( struct format_instance * fid , struct dm_list * mdas ,
const char * key , size_t key_len ) ;
int fid_remove_mda ( struct format_instance * fid , struct metadata_area * mda ,
const char * key , size_t key_len , const unsigned sub_key ) ;
struct metadata_area * fid_get_mda_indexed ( struct format_instance * fid ,
const char * key , size_t key_len , const unsigned sub_key ) ;
2010-06-29 00:34:40 +04:00
int mdas_empty_or_ignored ( struct dm_list * mdas ) ;
2010-06-29 00:30:14 +04:00
2005-10-18 17:43:40 +04:00
# define seg_pvseg(seg, s) (seg)->areas[(s)].u.pv.pvseg
# define seg_dev(seg, s) (seg)->areas[(s)].u.pv.pvseg->pv->dev
# define seg_pe(seg, s) (seg)->areas[(s)].u.pv.pvseg->pe
# define seg_le(seg, s) (seg)->areas[(s)].u.lv.le
2011-08-03 02:07:20 +04:00
# define seg_metale(seg, s) (seg)->meta_areas[(s)].u.lv.le
2005-06-01 20:51:55 +04:00
2001-10-05 02:53:37 +04:00
struct name_list {
2008-11-04 01:14:30 +03:00
struct dm_list list ;
2001-10-08 20:08:16 +04:00
char * name ;
2001-10-02 21:09:05 +04:00
} ;
2002-11-18 17:04:08 +03:00
struct mda_list {
2008-11-04 01:14:30 +03:00
struct dm_list list ;
2002-11-18 17:04:08 +03:00
struct device_area mda ;
} ;
2001-11-12 15:16:57 +03:00
2005-04-20 00:52:35 +04:00
struct peg_list {
2008-11-04 01:14:30 +03:00
struct dm_list list ;
2005-04-20 00:52:35 +04:00
struct pv_segment * peg ;
} ;
2008-01-16 22:00:59 +03:00
struct seg_list {
2008-11-04 01:14:30 +03:00
struct dm_list list ;
2008-01-16 22:00:59 +03:00
unsigned count ;
struct lv_segment * seg ;
} ;
2001-10-10 13:25:04 +04:00
/*
* Ownership of objects passes to caller .
*/
2001-11-12 15:16:57 +03:00
struct format_handler {
2001-10-10 13:25:04 +04:00
/*
2002-11-18 17:04:08 +03:00
* Scan any metadata areas that aren ' t referenced in PV labels
2001-10-10 13:25:04 +04:00
*/
2010-12-11 01:39:52 +03:00
int ( * scan ) ( const struct format_type * fmt , const char * vgname ) ;
2001-09-25 16:49:28 +04:00
2001-10-10 13:25:04 +04:00
/*
* Return PV with given path .
*/
2002-12-20 02:25:55 +03:00
int ( * pv_read ) ( const struct format_type * fmt , const char * pv_name ,
2011-02-21 15:15:59 +03:00
struct physical_volume * pv , int scan_label_only ) ;
2001-10-05 02:53:37 +04:00
2011-02-21 15:20:18 +03:00
/*
* Initialise a new PV .
*/
int ( * pv_initialise ) ( const struct format_type * fmt ,
2016-02-19 00:31:27 +03:00
struct pv_create_args * pva ,
2011-02-21 15:20:18 +03:00
struct physical_volume * pv ) ;
2001-10-10 13:25:04 +04:00
/*
2001-11-12 15:16:57 +03:00
* Tweak an already filled out a pv ready for importing into a
* vg . eg . pe_count is format specific .
2001-10-10 13:25:04 +04:00
*/
2002-12-20 02:25:55 +03:00
int ( * pv_setup ) ( const struct format_type * fmt ,
2011-02-21 15:24:15 +03:00
struct physical_volume * pv ,
struct volume_group * vg ) ;
2001-10-10 13:25:04 +04:00
2011-02-21 15:17:26 +03:00
/*
* Add metadata area to a PV . Changes will take effect on pv_write .
*/
int ( * pv_add_metadata_area ) ( const struct format_type * fmt ,
struct physical_volume * pv ,
int pe_start_locked ,
unsigned metadata_index ,
uint64_t metadata_size ,
unsigned metadata_ignored ) ;
2011-02-21 15:17:54 +03:00
/*
* Remove metadata area from a PV . Changes will take effect on pv_write .
*/
int ( * pv_remove_metadata_area ) ( const struct format_type * fmt ,
struct physical_volume * pv ,
unsigned metadata_index ) ;
2011-02-21 15:27:26 +03:00
/*
* Recalculate the PV size taking into account any existing metadata areas .
*/
int ( * pv_resize ) ( const struct format_type * fmt ,
struct physical_volume * pv ,
struct volume_group * vg ,
uint64_t size ) ;
2001-10-10 13:25:04 +04:00
/*
2001-11-12 15:16:57 +03:00
* Write a PV structure to disk . Fails if the PV is in a VG ie
2007-11-02 16:06:42 +03:00
* pv - > vg_name must be a valid orphan VG name
2001-10-10 13:25:04 +04:00
*/
2002-12-20 02:25:55 +03:00
int ( * pv_write ) ( const struct format_type * fmt ,
2011-02-21 15:26:27 +03:00
struct physical_volume * pv ) ;
2001-09-25 16:49:28 +04:00
2016-02-12 15:53:06 +03:00
/*
* Check if PV needs rewriting . This is used to check whether there are any
* format - specific changes before actually writing the PV ( by calling pv_write ) .
* With this , we can call pv_write conditionally only if it ' s really needed .
*/
int ( * pv_needs_rewrite ) ( const struct format_type * fmt ,
struct physical_volume * pv ,
int * needs_rewrite ) ;
2002-01-24 20:15:49 +03:00
/*
* Tweak an already filled out a lv eg , check there
* aren ' t too many extents .
*/
2002-11-18 17:04:08 +03:00
int ( * lv_setup ) ( struct format_instance * fi ,
struct logical_volume * lv ) ;
2002-01-24 20:15:49 +03:00
2001-10-12 18:25:53 +04:00
/*
2001-11-12 15:16:57 +03:00
* Tweak an already filled out vg . eg , max_pv is format
* specific .
2001-10-12 18:25:53 +04:00
*/
2002-11-18 17:04:08 +03:00
int ( * vg_setup ) ( struct format_instance * fi , struct volume_group * vg ) ;
2001-10-05 02:53:37 +04:00
2004-09-14 17:56:18 +04:00
/*
* Check whether particular segment type is supported .
*/
int ( * segtype_supported ) ( struct format_instance * fid ,
2006-05-10 01:23:51 +04:00
const struct segment_type * segtype ) ;
2004-09-14 17:56:18 +04:00
2002-04-24 22:20:51 +04:00
/*
* Create format instance with a particular metadata area
*/
2011-02-21 15:05:49 +03:00
struct format_instance * ( * create_instance ) ( const struct format_type * fmt ,
const struct format_instance_ctx * fic ) ;
2002-04-24 22:20:51 +04:00
/*
* Destructor for format instance
*/
2002-11-18 17:04:08 +03:00
void ( * destroy_instance ) ( struct format_instance * fid ) ;
2001-10-05 02:53:37 +04:00
2001-10-10 13:25:04 +04:00
/*
2002-04-24 22:20:51 +04:00
* Destructor for format type
2001-10-10 13:25:04 +04:00
*/
2010-12-20 16:32:49 +03:00
void ( * destroy ) ( struct format_type * fmt ) ;
2001-09-28 17:15:30 +04:00
} ;
2001-09-25 16:49:28 +04:00
2001-10-12 14:32:06 +04:00
/*
* Utility functions
*/
2009-02-22 22:00:26 +03:00
unsigned long set_pe_align ( struct physical_volume * pv , unsigned long data_alignment ) ;
2009-07-30 21:45:28 +04:00
unsigned long set_pe_align_offset ( struct physical_volume * pv ,
unsigned long data_alignment_offset ) ;
2007-07-18 19:38:58 +04:00
2007-02-07 16:29:52 +03:00
int pv_write_orphan ( struct cmd_context * cmd , struct physical_volume * pv ) ;
2001-11-12 22:28:50 +03:00
2013-07-09 05:37:56 +04:00
struct physical_volume * pvcreate_vol ( struct cmd_context * cmd , const char * pv_name ,
struct pvcreate_params * pp , int write_now ) ;
2013-04-04 01:53:21 +04:00
2013-12-12 14:26:35 +04:00
int check_dev_block_size_for_vg ( struct device * dev , const struct volume_group * vg ,
unsigned int * max_phys_block_size_found ) ;
2001-10-05 02:53:37 +04:00
/* Manipulate PV structures */
2001-10-02 02:12:10 +04:00
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 ) ;
2002-11-18 17:04:08 +03:00
struct physical_volume * pv_find ( struct volume_group * vg , const char * pv_name ) ;
2001-10-05 02:53:37 +04:00
2001-10-29 16:52:23 +03:00
/* Find a PV within a given VG */
2005-04-18 03:57:44 +04:00
int get_pv_from_vg_by_id ( const struct format_type * fmt , const char * vg_name ,
2006-04-13 01:23:04 +04:00
const char * vgid , const char * pvid ,
struct physical_volume * pv ) ;
2001-10-05 02:53:37 +04:00
2015-11-22 01:31:44 +03:00
struct logical_volume * find_lv_in_vg_by_lvid ( struct volume_group * vg ,
const union lvid * lvid ) ;
2001-10-29 16:52:23 +03:00
2008-11-04 01:14:30 +03:00
struct lv_list * find_lv_in_lv_list ( const struct dm_list * ll ,
2008-03-28 22:08:23 +03:00
const struct logical_volume * lv ) ;
2001-10-29 16:52:23 +03:00
/* Return the VG that contains a given LV (based on path given in lv_name) */
/* or environment var */
struct volume_group * find_vg_with_lv ( const char * lv_name ) ;
2002-11-18 17:04:08 +03:00
/* Find LV with given lvid (used during activation) */
struct logical_volume * lv_from_lvid ( struct cmd_context * cmd ,
2005-10-31 23:15:28 +03:00
const char * lvid_s ,
2008-03-17 19:51:31 +03:00
unsigned precommitted ) ;
2001-10-29 16:52:23 +03:00
/* FIXME Merge these functions with ones above */
2001-11-27 19:37:33 +03:00
struct physical_volume * find_pv ( struct volume_group * vg , struct device * dev ) ;
2001-09-28 17:15:30 +04:00
2008-11-04 01:14:30 +03:00
struct pv_list * find_pv_in_pv_list ( const struct dm_list * pl ,
2008-03-28 22:08:23 +03:00
const struct physical_volume * pv ) ;
2003-04-25 02:23:24 +04:00
/* Find LV segment containing given LE */
2007-12-20 21:55:46 +03:00
struct lv_segment * find_seg_by_le ( const struct logical_volume * lv , uint32_t le ) ;
2003-04-25 02:23:24 +04:00
2011-09-08 20:41:18 +04:00
/* Find pool LV segment given a thin pool data or metadata segment. */
2011-09-09 05:15:18 +04:00
struct lv_segment * find_pool_seg ( const struct lv_segment * seg ) ;
2011-09-08 20:41:18 +04:00
2011-10-03 22:39:17 +04:00
/* Find some unused device_id for thin pool LV segment. */
uint32_t get_free_pool_device_id ( struct lv_segment * thin_pool_seg ) ;
2014-11-04 17:06:55 +03:00
/* Check if the new thin-pool could be used for lvm2 thin volumes */
int check_new_thin_pool ( const struct logical_volume * pool_lv ) ;
2001-11-12 15:16:57 +03:00
/*
2001-11-14 16:52:38 +03:00
* Remove a dev_dir if present .
2001-11-12 15:16:57 +03:00
*/
const char * strip_dir ( const char * vg_name , const char * dir ) ;
2001-10-15 22:39:40 +04:00
2009-09-28 21:46:15 +04:00
struct logical_volume * alloc_lv ( struct dm_pool * mem ) ;
2002-01-10 14:18:08 +03:00
/*
* Checks that an lv has no gaps or overlapping segments .
2005-10-28 01:51:28 +04:00
* Set complete_vg to perform additional VG level checks .
2002-01-10 14:18:08 +03:00
*/
2005-10-28 01:51:28 +04:00
int check_lv_segments ( struct logical_volume * lv , int complete_vg ) ;
2002-01-10 14:18:08 +03:00
2016-06-29 01:44:15 +03:00
/*
* Does every LV segment have the same number of stripes ?
*/
int lv_has_constant_stripes ( struct logical_volume * lv ) ;
2010-05-21 16:43:02 +04:00
/*
* Checks that a replicator segment is correct .
*/
int check_replicator_segment ( const struct lv_segment * replicator_seg ) ;
2002-01-10 14:18:08 +03:00
/*
* Sometimes ( eg , after an lvextend ) , it is possible to merge two
* adjacent segments into a single segment . This function trys
* to merge as many segments as possible .
*/
int lv_merge_segments ( struct logical_volume * lv ) ;
2003-09-15 22:22:50 +04:00
/*
* Ensure there ' s a segment boundary at a given LE , splitting if necessary
*/
int lv_split_segment ( struct logical_volume * lv , uint32_t le ) ;
2008-01-16 22:00:59 +03:00
/*
* Add / remove upward link from underlying LV to the segment using it
* FIXME : ridiculously long name
*/
int add_seg_to_segs_using_this_lv ( struct logical_volume * lv , struct lv_segment * seg ) ;
int remove_seg_from_segs_using_this_lv ( struct logical_volume * lv , struct lv_segment * seg ) ;
2016-03-01 17:19:57 +03:00
int add_glv_to_indirect_glvs ( struct dm_pool * mem ,
struct generic_logical_volume * origin_glv ,
struct generic_logical_volume * user_glv ) ;
int remove_glv_from_indirect_glvs ( struct generic_logical_volume * glv ,
struct generic_logical_volume * user_glv ) ;
2015-01-30 14:27:49 +03:00
int for_each_sub_lv_except_pools ( struct logical_volume * lv ,
int ( * fn ) ( struct logical_volume * lv , void * data ) ,
void * data ) ;
2014-03-27 13:35:07 +04:00
int for_each_sub_lv ( struct logical_volume * lv ,
2015-01-30 14:27:16 +03:00
int ( * fn ) ( struct logical_volume * lv , void * data ) ,
void * data ) ;
2011-10-22 20:42:10 +04:00
int move_lv_segments ( struct logical_volume * lv_to ,
struct logical_volume * lv_from ,
uint64_t set_status , uint64_t reset_status ) ;
2011-06-30 22:25:18 +04:00
2009-05-20 15:09:49 +04:00
/*
* Calculate readahead from underlying PV devices
*/
2009-06-01 16:43:31 +04:00
void lv_calculate_readahead ( const struct logical_volume * lv , uint32_t * read_ahead ) ;
2009-05-20 15:09:49 +04:00
2008-04-02 02:40:13 +04:00
/*
* For internal metadata caching .
*/
2011-09-01 14:25:22 +04:00
size_t export_vg_to_buffer ( struct volume_group * vg , char * * buf ) ;
2013-03-17 19:25:12 +04:00
struct dm_config_tree * export_vg_to_config_tree ( struct volume_group * vg ) ;
2010-12-20 16:19:13 +03:00
struct volume_group * import_vg_from_buffer ( const char * buf ,
2008-04-02 02:40:13 +04:00
struct format_instance * fid ) ;
2011-08-30 18:55:15 +04:00
struct volume_group * import_vg_from_config_tree ( const struct dm_config_tree * cft ,
2011-01-10 16:13:42 +03:00
struct format_instance * fid ) ;
2015-06-10 17:25:57 +03:00
struct volume_group * import_vg_from_lvmetad_config_tree ( const struct dm_config_tree * cft ,
struct format_instance * fid ) ;
2008-04-02 02:40:13 +04:00
2003-04-30 19:23:43 +04:00
/*
* Mirroring functions
*/
2005-11-29 21:20:23 +03:00
2005-10-27 23:58:22 +04:00
/*
* Given mirror image or mirror log segment , find corresponding mirror segment
*/
2005-10-28 01:51:28 +04:00
int fixup_imported_mirrors ( struct volume_group * vg ) ;
2005-06-14 22:22:31 +04:00
2011-09-06 23:25:42 +04:00
/*
* From thin_manip . c
*/
2011-11-07 15:03:47 +04:00
int attach_pool_lv ( struct lv_segment * seg , struct logical_volume * pool_lv ,
2016-03-01 17:21:36 +03:00
struct logical_volume * origin_lv ,
struct generic_logical_volume * indirect_origin ,
struct logical_volume * merge_lv ) ;
2011-09-08 20:41:18 +04:00
int detach_pool_lv ( struct lv_segment * seg ) ;
2012-01-25 12:55:19 +04:00
int attach_pool_message ( struct lv_segment * pool_seg , dm_thin_message_t type ,
2011-10-19 20:39:09 +04:00
struct logical_volume * lv , uint32_t delete_id ,
2012-01-25 12:55:19 +04:00
int auto_increment ) ;
2013-11-29 18:51:28 +04:00
int lv_is_merging_thin_snapshot ( const struct logical_volume * lv ) ;
2012-01-25 12:55:19 +04:00
int pool_has_message ( const struct lv_segment * seg ,
const struct logical_volume * lv , uint32_t device_id ) ;
2016-09-16 22:50:14 +03:00
int pool_metadata_min_threshold ( const struct lv_segment * pool_seg ) ;
2012-02-08 17:05:38 +04:00
int pool_below_threshold ( const struct lv_segment * pool_seg ) ;
2015-07-03 16:31:31 +03:00
int pool_check_overprovisioning ( const struct logical_volume * lv ) ;
2013-07-23 16:33:14 +04:00
int create_pool ( struct logical_volume * lv , const struct segment_type * segtype ,
2011-10-29 00:32:54 +04:00
struct alloc_handle * ah , uint32_t stripes , uint32_t stripe_size ) ;
2011-09-06 23:25:42 +04:00
2007-06-13 01:20:20 +04:00
/*
2007-07-12 03:33:12 +04:00
* Begin skeleton for external LVM library
2007-06-13 01:20:20 +04:00
*/
2009-07-29 17:26:01 +04:00
struct id pv_id ( const struct physical_volume * pv ) ;
const struct format_type * pv_format_type ( const struct physical_volume * pv ) ;
struct id pv_vgid ( const struct physical_volume * pv ) ;
2007-06-19 08:23:32 +04:00
2010-08-20 16:43:49 +04:00
uint64_t find_min_mda_size ( struct dm_list * mdas ) ;
2014-01-31 01:09:28 +04:00
char * tags_format_and_copy ( struct dm_pool * mem , const struct dm_list * tagsl ) ;
2010-08-20 16:43:49 +04:00
2001-09-28 17:15:30 +04:00
# endif