2002-02-11 23:50:53 +03:00
/*
2004-03-30 23:35:44 +04:00
* Copyright ( C ) 2001 - 2004 Sistina Software , Inc . All rights reserved .
2009-02-23 00:14:37 +03:00
* Copyright ( C ) 2004 - 2009 Red Hat , Inc . All rights reserved .
2002-02-11 23:50:53 +03:00
*
2004-03-30 23:35:44 +04:00
* This file is part of LVM2 .
2002-02-11 23:50:53 +03: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 ,
* Inc . , 59 Temple Place , Suite 330 , Boston , MA 02111 - 1307 USA
2002-02-11 23:50:53 +03:00
*/
# ifndef _LVM_TOOLCONTEXT_H
# define _LVM_TOOLCONTEXT_H
# include "dev-cache.h"
2013-06-12 14:08:56 +04:00
# include "dev-type.h"
2002-02-11 23:50:53 +03:00
2002-11-18 17:01:16 +03:00
# include <limits.h>
/*
* Config options that can be changed while commands are processed
*/
struct config_info {
int debug ;
2013-01-08 02:25:19 +04:00
int debug_classes ;
2002-11-18 17:01:16 +03:00
int verbose ;
config: add silent mode
Accept -q as the short form of --quiet.
Suppress non-essential standard output if -q is given twice.
Treat log/silent in lvm.conf as equivalent to -qq.
Review all log_print messages and change some to
log_print_unless_silent.
When silent, the following commands still produce output:
dumpconfig, lvdisplay, lvmdiskscan, lvs, pvck, pvdisplay,
pvs, version, vgcfgrestore -l, vgdisplay, vgs.
[Needs checking.]
Non-essential messages are shifted from log level 4 to log level 5
for syslog and lvm2_log_fn purposes.
2012-08-25 23:35:48 +04:00
int silent ;
2002-11-18 17:01:16 +03:00
int test ;
int syslog ;
int activation ;
2002-12-12 23:55:49 +03:00
int suffix ;
2002-11-18 17:01:16 +03:00
int archive ; /* should we archive ? */
int backup ; /* should we backup ? */
2007-11-09 19:51:54 +03:00
int read_ahead ; /* DM_READ_AHEAD_NONE or _AUTO */
2010-01-07 22:54:21 +03:00
int udev_rules ;
2009-08-04 19:36:13 +04:00
int udev_sync ;
2011-06-17 18:50:53 +04:00
int udev_fallback ;
2008-04-03 01:23:39 +04:00
int cache_vgmetadata ;
2005-04-06 17:47:41 +04:00
const char * msg_prefix ;
2010-04-29 05:38:12 +04:00
const char * fmt_name ;
2005-04-06 17:47:41 +04:00
uint64_t unit_factor ;
int cmd_name ; /* Show command name? */
2002-11-18 17:01:16 +03:00
mode_t umask ;
2005-04-06 17:47:41 +04:00
char unit_type ;
char _padding [ 1 ] ;
2002-11-18 17:01:16 +03:00
} ;
2011-08-30 18:55:15 +04:00
struct dm_config_tree ;
2013-06-25 14:27:04 +04:00
struct profile_params ;
2005-05-17 17:46:38 +04:00
struct archive_params ;
struct backup_params ;
2010-11-11 20:29:05 +03:00
struct arg_values ;
2004-05-04 22:28:15 +04:00
2011-08-30 18:55:15 +04:00
struct config_tree_list {
struct dm_list list ;
struct dm_config_tree * cft ;
} ;
2002-11-18 17:01:16 +03:00
/* FIXME Split into tool & library contexts */
2002-02-11 23:50:53 +03:00
/* command-instance-related variables needed by library */
struct cmd_context {
2005-10-17 03:03:59 +04:00
struct dm_pool * libmem ; /* For permanent config data */
struct dm_pool * mem ; /* Transient: Cleared between each command */
2002-02-11 23:50:53 +03:00
2002-12-20 02:25:55 +03:00
const struct format_type * fmt ; /* Current format to use by default */
2002-11-18 17:01:16 +03:00
struct format_type * fmt_backup ; /* Format to use for backups */
2002-04-24 22:20:51 +04:00
2008-11-04 01:14:30 +03:00
struct dm_list formats ; /* Available formats */
struct dm_list segtypes ; /* Available segment types */
2014-10-24 21:29:04 +04:00
const char * system_id ;
2004-03-08 20:25:59 +03:00
const char * hostname ;
2004-04-08 19:23:23 +04:00
const char * kernel_vsn ;
2002-02-11 23:50:53 +03:00
2008-12-07 07:27:56 +03:00
unsigned rand_seed ;
2011-05-07 17:50:11 +04:00
char * linebuffer ;
2009-07-13 23:49:48 +04:00
const char * cmd_line ;
2002-02-11 23:50:53 +03:00
struct command * command ;
2003-05-06 16:00:51 +04:00
char * * argv ;
2010-11-11 20:29:05 +03:00
struct arg_values * arg_values ;
struct dm_list arg_value_groups ;
2008-09-19 10:42:00 +04:00
unsigned is_long_lived : 1 ; /* Optimises persistent_filter handling */
unsigned handles_missing_pvs : 1 ;
2009-10-16 21:41:49 +04:00
unsigned handles_unknown_segments : 1 ;
2011-11-29 00:37:51 +04:00
unsigned use_linear_target : 1 ;
2008-09-19 11:12:45 +04:00
unsigned partial_activation : 1 ;
activation: Add "degraded" activation mode
Currently, we have two modes of activation, an unnamed nominal mode
(which I will refer to as "complete") and "partial" mode. The
"complete" mode requires that a volume group be 'complete' - that
is, no missing PVs. If there are any missing PVs, no affected LVs
are allowed to activate - even RAID LVs which might be able to
tolerate a failure. The "partial" mode allows anything to be
activated (or at least attempted). If a non-redundant LV is
missing a portion of its addressable space due to a device failure,
it will be replaced with an error target. RAID LVs will either
activate or fail to activate depending on how badly their
redundancy is compromised.
This patch adds a third option, "degraded" mode. This mode can
be selected via the '--activationmode {complete|degraded|partial}'
option to lvchange/vgchange. It can also be set in lvm.conf.
The "degraded" activation mode allows RAID LVs with a sufficient
level of redundancy to activate (e.g. a RAID5 LV with one device
failure, a RAID6 with two device failures, or RAID1 with n-1
failures). RAID LVs with too many device failures are not allowed
to activate - nor are any non-redundant LVs that may have been
affected. This patch also makes the "degraded" mode the default
activation mode.
The degraded activation mode does not yet work in a cluster. A
new cluster lock flag (LCK_DEGRADED_MODE) will need to be created
to make that work. Currently, there is limited space for this
extra flag and I am looking for possible solutions. One possible
solution is to usurp LCK_CONVERT, as it is not used. When the
locking_type is 3, the degraded mode flag simply gets dropped and
the old ("complete") behavior is exhibited.
2014-07-10 07:56:11 +04:00
unsigned degraded_activation : 1 ;
2013-07-12 11:27:17 +04:00
unsigned auto_set_activation_skip : 1 ;
2009-09-28 20:23:44 +04:00
unsigned si_unit_consistency : 1 ;
2014-07-02 15:16:32 +04:00
unsigned report_binary_values_as_numeric : 1 ;
2010-10-25 15:20:54 +04:00
unsigned metadata_read_only : 1 ;
2013-10-02 00:20:10 +04:00
unsigned ignore_clustered_vgs : 1 ;
2011-12-09 01:24:08 +04:00
unsigned threaded : 1 ; /* Set if running within a thread e.g. clvmd */
2002-11-18 17:01:16 +03:00
2010-12-11 01:39:52 +03:00
unsigned independent_metadata_areas : 1 ; /* Active formats have MDAs outside PVs */
2014-10-24 21:29:04 +04:00
unsigned unknown_system_id : 1 ;
unsigned include_foreign_vgs : 1 ;
2015-02-25 20:33:11 +03:00
unsigned include_active_foreign_vgs : 1 ;
2015-02-25 19:44:42 +03:00
unsigned error_foreign_vgs : 1 ;
2010-12-11 01:39:52 +03:00
2013-06-12 14:08:56 +04:00
struct dev_types * dev_types ;
2014-10-02 14:00:57 +04:00
/*
* Use of filters depends on whether lvmetad is used or not :
*
* - if lvmetad is used :
* - cmd - > lvmetad_filter used when scanning devices for lvmetad
* - cmd - > filter used when processing lvmetad responses
* - cmd - > full_filter used for remaining situations
*
* - if lvmetad is not used :
* - cmd - > lvmetad_filter is NULL
* - cmd - > filter = = cmd - > full_filter used for all situations
*
*/
2012-08-13 21:44:10 +04:00
struct dev_filter * lvmetad_filter ;
2014-10-02 14:00:57 +04:00
struct dev_filter * filter ;
struct dev_filter * full_filter ;
2002-11-18 17:01:16 +03:00
int dump_filter ; /* Dump filter when exiting? */
2013-06-26 14:29:19 +04:00
struct dm_list config_files ; /* master lvm config + any existing tag configs */
struct profile_params * profile_params ; /* profile handling params including loaded profile configs */
struct dm_config_tree * cft ; /* the whole cascade: CONFIG_STRING -> CONFIG_PROFILE -> CONFIG_FILE/CONFIG_MERGED_FILES */
int config_initialized ; /* used to reinitialize config if previous init was not successful */
2013-06-26 16:53:57 +04:00
2013-06-26 14:29:19 +04:00
struct dm_hash_table * cft_def_hash ; /* config definition hash used for validity check (item type + item recognized) */
/* selected settings with original default/configured value which can be changed during cmd processing */
2002-11-18 17:01:16 +03:00
struct config_info default_settings ;
2013-06-26 14:29:19 +04:00
/* may contain changed values compared to default_settings */
2002-11-18 17:01:16 +03:00
struct config_info current_settings ;
2013-06-25 14:27:04 +04:00
2005-05-17 17:46:38 +04:00
struct archive_params * archive_params ;
struct backup_params * backup_params ;
2008-09-19 10:42:00 +04:00
const char * stripe_filler ;
2005-05-17 17:46:38 +04:00
2004-03-08 21:13:22 +03:00
/* List of defined tags */
2008-11-04 01:14:30 +03:00
struct dm_list tags ;
2014-07-10 18:18:45 +04:00
const char * report_list_item_separator ;
2004-05-04 22:28:15 +04:00
int hosttags ;
2004-03-08 21:13:22 +03:00
2013-12-06 19:35:54 +04:00
const char * lib_dir ; /* Cache value global/library_dir */
2009-02-23 00:14:37 +03:00
char system_dir [ PATH_MAX ] ;
2002-11-18 17:01:16 +03:00
char dev_dir [ PATH_MAX ] ;
char proc_dir [ PATH_MAX ] ;
2002-02-11 23:50:53 +03:00
} ;
2009-02-23 00:14:37 +03:00
/*
* system_dir may be NULL to use the default value .
* The environment variable LVM_SYSTEM_DIR always takes precedence .
*/
struct cmd_context * create_toolcontext ( unsigned is_long_lived ,
2011-05-07 17:50:11 +04:00
const char * system_dir ,
2011-12-09 01:24:08 +04:00
unsigned set_buffering ,
unsigned threaded ) ;
2002-11-18 17:01:16 +03:00
void destroy_toolcontext ( struct cmd_context * cmd ) ;
2004-03-08 21:13:22 +03:00
int refresh_toolcontext ( struct cmd_context * cmd ) ;
2009-11-24 19:10:25 +03:00
int refresh_filters ( struct cmd_context * cmd ) ;
2014-03-17 19:03:53 +04:00
int process_profilable_config ( struct cmd_context * cmd ) ;
2004-05-04 22:28:15 +04:00
int config_files_changed ( struct cmd_context * cmd ) ;
2008-04-08 16:49:21 +04:00
int init_lvmcache_orphans ( struct cmd_context * cmd ) ;
2002-11-18 17:01:16 +03:00
2010-04-29 05:38:12 +04:00
struct format_type * get_format_by_name ( struct cmd_context * cmd , const char * format ) ;
2015-02-24 02:03:52 +03:00
const char * system_id_from_string ( struct cmd_context * cmd , const char * str ) ;
2014-10-24 21:29:04 +04:00
2002-02-11 23:50:53 +03:00
# endif