2010-09-30 17:16:55 +04:00
/*
2010-10-01 00:47:18 +04:00
* Copyright ( C ) 2001 - 2004 Sistina Software , Inc . All rights reserved .
2013-04-29 16:04:38 +04:00
* Copyright ( C ) 2004 - 2012 Red Hat , Inc . All rights reserved .
2010-09-30 17:16:55 +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
2010-09-30 17:16:55 +04:00
*/
2010-10-25 16:01:59 +04:00
# ifndef _LVM_LV_H
# define _LVM_LV_H
2010-09-30 17:16:55 +04:00
2012-01-26 02:26:33 +04:00
# include "vg.h"
2010-09-30 17:16:55 +04:00
union lvid ;
struct lv_segment ;
struct replicator_device ;
2013-04-29 16:04:38 +04:00
enum activation_change ;
2010-09-30 17:16:55 +04:00
struct logical_volume {
union lvid lvid ;
2011-02-18 17:47:28 +03:00
const char * name ;
2010-09-30 17:16:55 +04:00
struct volume_group * vg ;
uint64_t status ;
alloc_policy_t alloc ;
2013-06-25 14:28:36 +04:00
struct profile * profile ;
2010-09-30 17:16:55 +04:00
uint32_t read_ahead ;
int32_t major ;
int32_t minor ;
2015-09-23 16:37:52 +03:00
uint64_t size ; /* Sectors visible */
uint32_t le_count ; /* Logical extents visible */
2010-09-30 17:16:55 +04:00
uint32_t origin_count ;
2013-02-21 13:25:44 +04:00
uint32_t external_count ;
2010-09-30 17:16:55 +04:00
struct dm_list snapshot_segs ;
struct lv_segment * snapshot ;
struct replicator_device * rdevice ; /* For replicator-devs, rimages, slogs - reference to rdevice */
struct dm_list rsites ; /* For replicators - all sites */
struct dm_list segments ;
struct dm_list tags ;
struct dm_list segs_using_this_lv ;
2016-03-01 17:18:42 +03:00
struct dm_list indirect_glvs ; /* For keeping track of historical LVs in ancestry chain */
/*
* this_glv variable is used as a helper for handling historical LVs .
* If this LVs has no role at all in keeping track of historical LVs ,
* the this_glv variable is NULL . See also comments for struct
* generic_logical_volume and struct historical_logical_volume below .
*/
struct generic_logical_volume * this_glv ;
2012-01-19 19:31:45 +04:00
uint64_t timestamp ;
2015-03-05 23:00:44 +03:00
unsigned new_lock_args : 1 ;
2012-01-19 19:31:45 +04:00
const char * hostname ;
2015-03-05 23:00:44 +03:00
const char * lock_args ;
2010-09-30 17:16:55 +04:00
} ;
2016-03-01 17:18:42 +03:00
/*
* With the introduction of tracking historical LVs , we need to make
* a difference between live LV ( struct logical_volume ) and historical LV
* ( struct historical_logical_volume ) . To minimize the impact of this change
* and to minimize the changes needed in the existing code , we use a
* little trick here - when processing LVs ( e . g . while reporting LV
* properties ) , each historical LV is represented as dummy LV which is
* an instance of struct logical_volume with all its properties set to
* blank ( hence " dummy LV " ) and with this_glv pointing to the struct
* historical_logical_volume . This way all the existing code working with
* struct logical_volume will see this historical LV as dummy live LV while
* the code that needs to recognize between live and historical LV will
* check this_glv first and then it will work either with the live
* or historical LV properties appropriately .
*/
struct generic_logical_volume ;
/*
* historical logical volume is an LV that has been removed already .
* This is used to keep track of LV history .
*/
struct historical_logical_volume {
union lvid lvid ;
const char * name ;
struct volume_group * vg ;
uint64_t timestamp ;
uint64_t timestamp_removed ;
struct generic_logical_volume * indirect_origin ;
struct dm_list indirect_glvs ; /* list of struct generic_logical_volume */
2016-04-21 21:54:54 +03:00
unsigned checked : 1 ; /* set if this historical LV has been checked for validity */
unsigned valid : 1 ; /* historical LV is valid if there's at least one live LV among ancestors */
2016-03-01 17:18:42 +03:00
} ;
struct generic_logical_volume {
int is_historical ;
union {
struct logical_volume * live ; /* is_historical=0 */
struct historical_logical_volume * historical ; /* is_historical=1 */
} ;
} ;
2015-01-20 15:14:16 +03:00
struct lv_with_info_and_seg_status ;
2016-01-12 13:45:17 +03:00
/* LV dependencies */
struct logical_volume * lv_parent ( const struct logical_volume * lv ) ;
struct logical_volume * lv_convert_lv ( const struct logical_volume * lv ) ;
struct logical_volume * lv_origin_lv ( const struct logical_volume * lv ) ;
struct logical_volume * lv_mirror_log_lv ( const struct logical_volume * lv ) ;
struct logical_volume * lv_data_lv ( const struct logical_volume * lv ) ;
struct logical_volume * lv_convert ( const struct logical_volume * lv ) ;
struct logical_volume * lv_origin ( const struct logical_volume * lv ) ;
struct logical_volume * lv_mirror_log ( const struct logical_volume * lv ) ;
struct logical_volume * lv_data ( const struct logical_volume * lv ) ;
struct logical_volume * lv_metadata_lv ( const struct logical_volume * lv ) ;
struct logical_volume * lv_pool_lv ( const struct logical_volume * lv ) ;
/* LV properties */
2010-09-30 17:16:55 +04:00
uint64_t lv_size ( const struct logical_volume * lv ) ;
2016-01-12 13:45:17 +03:00
uint64_t lvseg_size ( const struct lv_segment * seg ) ;
uint64_t lvseg_chunksize ( const struct lv_segment * seg ) ;
uint64_t lv_origin_size ( const struct logical_volume * lv ) ;
2012-01-19 19:34:32 +04:00
uint64_t lv_metadata_size ( const struct logical_volume * lv ) ;
2016-01-12 13:45:17 +03:00
struct profile * lv_config_profile ( const struct logical_volume * lv ) ;
const char * lv_layer ( const struct logical_volume * lv ) ;
const struct logical_volume * lv_lock_holder ( const struct logical_volume * lv ) ;
const struct logical_volume * lv_committed ( const struct logical_volume * lv ) ;
int lv_mirror_image_in_sync ( const struct logical_volume * lv ) ;
int lv_raid_image_in_sync ( const struct logical_volume * lv ) ;
int lv_raid_healthy ( const struct logical_volume * lv ) ;
const char * lvseg_name ( const struct lv_segment * seg ) ;
uint64_t lvseg_start ( const struct lv_segment * seg ) ;
2016-01-19 14:24:02 +03:00
struct dm_list * lvseg_devices ( struct dm_pool * mem , const struct lv_segment * seg ) ;
char * lvseg_devices_str ( struct dm_pool * mem , const struct lv_segment * seg ) ;
struct dm_list * lvseg_metadata_devices ( struct dm_pool * mem , const struct lv_segment * seg ) ;
char * lvseg_metadata_devices_str ( struct dm_pool * mem , const struct lv_segment * seg ) ;
struct dm_list * lvseg_seg_pe_ranges ( struct dm_pool * mem , const struct lv_segment * seg ) ;
char * lvseg_seg_pe_ranges_str ( struct dm_pool * mem , const struct lv_segment * seg ) ;
2016-01-19 15:51:11 +03:00
struct dm_list * lvseg_seg_le_ranges ( struct dm_pool * mem , const struct lv_segment * seg ) ;
char * lvseg_seg_le_ranges_str ( struct dm_pool * mem , const struct lv_segment * seg ) ;
2016-01-19 14:24:02 +03:00
struct dm_list * lvseg_seg_metadata_le_ranges ( struct dm_pool * mem , const struct lv_segment * seg ) ;
char * lvseg_seg_metadata_le_ranges_str ( struct dm_pool * mem , const struct lv_segment * seg ) ;
2016-01-12 13:45:17 +03:00
/* LV kernel properties */
int lv_kernel_major ( const struct logical_volume * lv ) ;
int lv_kernel_minor ( const struct logical_volume * lv ) ;
uint32_t lv_kernel_read_ahead ( const struct logical_volume * lv ) ;
2016-01-14 18:54:12 +03:00
char * lvseg_kernel_discards_dup ( struct dm_pool * mem , const struct lv_segment * seg ) ;
2016-01-12 13:45:17 +03:00
/* LV modification functions */
int lv_set_creation ( struct logical_volume * lv ,
const char * hostname , uint64_t timestamp ) ;
int lv_active_change ( struct cmd_context * cmd , struct logical_volume * lv ,
enum activation_change activate , int needs_exlusive ) ;
/* LV dup functions */
2015-01-20 15:14:16 +03:00
char * lv_attr_dup_with_info_and_seg_status ( struct dm_pool * mem , const struct lv_with_info_and_seg_status * lvdm ) ;
2010-09-30 17:52:55 +04:00
char * lv_attr_dup ( struct dm_pool * mem , const struct logical_volume * lv ) ;
2015-09-21 13:23:03 +03:00
char * lv_uuid_dup ( struct dm_pool * mem , const struct logical_volume * lv ) ;
2010-09-30 18:08:19 +04:00
char * lv_tags_dup ( const struct logical_volume * lv ) ;
2010-10-12 20:11:34 +04:00
char * lv_path_dup ( struct dm_pool * mem , const struct logical_volume * lv ) ;
2014-07-02 20:24:05 +04:00
char * lv_dmpath_dup ( struct dm_pool * mem , const struct logical_volume * lv ) ;
2010-10-12 20:12:02 +04:00
char * lv_move_pv_dup ( struct dm_pool * mem , const struct logical_volume * lv ) ;
2015-09-21 15:01:41 +03:00
char * lv_move_pv_uuid_dup ( struct dm_pool * mem , const struct logical_volume * lv ) ;
2010-10-12 20:12:18 +04:00
char * lv_convert_lv_dup ( struct dm_pool * mem , const struct logical_volume * lv ) ;
2015-09-21 15:10:21 +03:00
char * lv_convert_lv_uuid_dup ( struct dm_pool * mem , const struct logical_volume * lv ) ;
2010-10-12 20:12:50 +04:00
char * lv_mirror_log_dup ( struct dm_pool * mem , const struct logical_volume * lv ) ;
2015-09-21 14:16:48 +03:00
char * lv_mirror_log_uuid_dup ( struct dm_pool * mem , const struct logical_volume * lv ) ;
2012-01-19 19:34:32 +04:00
char * lv_data_lv_dup ( struct dm_pool * mem , const struct logical_volume * lv ) ;
2015-09-21 14:07:28 +03:00
char * lv_data_lv_uuid_dup ( struct dm_pool * mem , const struct logical_volume * lv ) ;
2012-01-19 19:34:32 +04:00
char * lv_metadata_lv_dup ( struct dm_pool * mem , const struct logical_volume * lv ) ;
2015-09-21 13:59:08 +03:00
char * lv_metadata_lv_uuid_dup ( struct dm_pool * mem , const struct logical_volume * lv ) ;
2011-09-09 04:54:49 +04:00
char * lv_pool_lv_dup ( struct dm_pool * mem , const struct logical_volume * lv ) ;
2015-09-21 13:28:58 +03:00
char * lv_pool_lv_uuid_dup ( struct dm_pool * mem , const struct logical_volume * lv ) ;
2010-10-12 20:13:06 +04:00
char * lv_modules_dup ( struct dm_pool * mem , const struct logical_volume * lv ) ;
2010-10-21 18:49:10 +04:00
char * lv_name_dup ( struct dm_pool * mem , const struct logical_volume * lv ) ;
2014-07-02 20:24:05 +04:00
char * lv_fullname_dup ( struct dm_pool * mem , const struct logical_volume * lv ) ;
2014-07-04 02:49:34 +04:00
char * lv_parent_dup ( struct dm_pool * mem , const struct logical_volume * lv ) ;
2010-10-21 18:49:20 +04:00
char * lv_origin_dup ( struct dm_pool * mem , const struct logical_volume * lv ) ;
2015-09-21 13:44:29 +03:00
char * lv_origin_uuid_dup ( struct dm_pool * mem , const struct logical_volume * lv ) ;
2011-03-05 15:14:00 +03:00
char * lvseg_segtype_dup ( struct dm_pool * mem , const struct lv_segment * seg ) ;
2012-11-27 14:02:49 +04:00
char * lvseg_discards_dup ( struct dm_pool * mem , const struct lv_segment * seg ) ;
2014-10-02 01:06:01 +04:00
char * lvseg_cachemode_dup ( struct dm_pool * mem , const struct lv_segment * seg ) ;
2013-04-25 14:07:57 +04:00
char * lvseg_monitor_dup ( struct dm_pool * mem , const struct lv_segment * seg ) ;
2010-11-17 23:08:14 +03:00
char * lvseg_tags_dup ( const struct lv_segment * seg ) ;
2016-03-01 17:23:23 +03:00
char * lv_creation_time_dup ( struct dm_pool * mem , const struct logical_volume * lv , int iso_mode ) ;
char * lv_removal_time_dup ( struct dm_pool * mem , const struct logical_volume * lv , int iso_mode ) ;
2012-01-19 19:31:45 +04:00
char * lv_host_dup ( struct dm_pool * mem , const struct logical_volume * lv ) ;
2013-04-25 14:12:05 +04:00
char * lv_active_dup ( struct dm_pool * mem , const struct logical_volume * lv ) ;
2013-07-02 16:34:52 +04:00
char * lv_profile_dup ( struct dm_pool * mem , const struct logical_volume * lv ) ;
2015-03-05 23:00:44 +03:00
char * lv_lock_args_dup ( struct dm_pool * mem , const struct logical_volume * lv ) ;
2016-01-14 18:54:12 +03:00
char * lvseg_kernel_discards_dup_with_info_and_seg_status ( struct dm_pool * mem , const struct lv_with_info_and_seg_status * lvdm ) ;
2016-03-01 17:23:23 +03:00
char * lv_time_dup ( struct dm_pool * mem , const struct logical_volume * lv , int iso_mode ) ;
2016-05-25 17:18:38 +03:00
typedef enum {
PERCENT_GET_DATA = 0 ,
PERCENT_GET_METADATA ,
PERCENT_GET_DIRTY
} percent_get_t ;
dm_percent_t lvseg_percent_with_info_and_seg_status ( const struct lv_with_info_and_seg_status * lvdm ,
percent_get_t type ) ;
2010-10-25 16:01:59 +04:00
# endif /* _LVM_LV_H */