master - config: refer to config nodes using assigned IDs
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=386886f71c3da0945f47edf1a7063a04ba9b56d1 Commit: 386886f71c3da0945f47edf1a7063a04ba9b56d1 Parent: a3d891a29042e51a0f43ed02273a6dce194d6569 Author: Peter Rajnoha <[email protected]> AuthorDate: Tue Mar 5 17:00:43 2013 +0100 Committer: Peter Rajnoha <[email protected]> CommitterDate: Wed Mar 6 10:14:33 2013 +0100
config: refer to config nodes using assigned IDs
For example, the old call and reference:
find_config_tree_str(cmd, "devices/dir", DEFAULT_DEV_DIR)
...now becomes:
find_config_tree_str(cmd, devices_dir_CFG)
So we're referring to the named configuration ID instead of passing the configuration path and the default value is taken from central config definition in config_settings.h automatically.
--- daemons/clvmd/lvm-functions.c | 7 +- lib/activate/activate.c | 18 +++-- lib/activate/dev_manager.c | 6 +- lib/commands/toolcontext.c | 175 ++++++++++++++++------------------------ lib/commands/toolcontext.h | 1 + lib/config/config.c | 71 ++++++++++++----- lib/config/config.h | 21 ++--- lib/config/defaults.h | 1 - lib/device/dev-cache.c | 2 +- lib/display/display.c | 3 +- lib/format_text/format-text.c | 8 +- lib/locking/external_locking.c | 4 +- lib/locking/file_locking.c | 6 +- lib/locking/locking.c | 13 +-- lib/metadata/lv_manip.c | 17 ++--- lib/metadata/metadata.c | 15 +--- lib/metadata/mirror.c | 15 ++-- lib/metadata/pv_manip.c | 3 +- lib/metadata/thin_manip.c | 4 +- lib/mirror/mirrored.c | 3 +- lib/misc/sharedlib.c | 2 +- lib/mm/memlock.c | 15 +--- lib/raid/raid.c | 3 +- lib/snapshot/snapshot.c | 3 +- lib/thin/thin.c | 5 +- liblvm/lvm_base.c | 4 +- tools/lvconvert.c | 13 +-- tools/lvcreate.c | 8 +- tools/lvm.c | 3 +- tools/lvmcmdline.c | 3 +- tools/lvresize.c | 16 +--- tools/polldaemon.c | 6 +- tools/pvcreate.c | 4 +- tools/pvscan.c | 4 +- tools/reporter.c | 76 +++++------------ tools/toollib.c | 46 +++------- tools/vgconvert.c | 8 +-- 37 files changed, 246 insertions(+), 366 deletions(-)
daemons/clvmd/lvm-functions.c +3 -4
@@ -808,7 +808,7 @@ static void check_config(void) {int locking_type; - locking_type =find_config_tree_int (cmd,"global/locking_type" ,1 ); + locking_type =find_config_tree_int (cmd, global_locking_type_CFG);if (locking_type ==3 )/* compiled-in cluster support */ return ;
@@ -816,9 +816,8 @@ static void check_config(void)if (locking_type ==2 ) {/* External library, check name */ const char *libname; - libname =find_config_tree_str (cmd,"global/locking_library" , -"" ); -if (strstr (libname,"liblvm2clusterlock.so" )) + libname =find_config_tree_str (cmd, global_locking_library_CFG); +if (libname &&strstr (libname,"liblvm2clusterlock.so" ))return ;log_error ("Incorrect LVM locking library specified in lvm.conf, cluster operations may not work." );
lib/activate/activate.c +10 -8
@@ -333,12 +333,14 @@ int activation(void) }static int _lv_passes_volumes_filter (struct cmd_context *cmd,struct logical_volume *lv, -const struct dm_config_node *cn,const char *config_path) +const struct dm_config_node *cn,const int cfg_id) {const struct dm_config_value *cv;const char *str; +static char config_path[PATH_MAX ];static char path[PATH_MAX ]; +config_def_get_path (config_path,sizeof (config_path), cfg_id);log_verbose ("%s configuration setting defined: " "Checking the list to match %s/%s" , config_path, lv->vg->name, lv->name);
@@ -413,7 +415,7 @@ static int _passes_activation_filter(struct cmd_context *cmd, {const struct dm_config_node *cn; -if (!(cn =find_config_tree_node (cmd,"activation/volume_list" ))) { +if (!(cn =find_config_tree_node (cmd, activation_volume_list_CFG))) {log_verbose ("activation/volume_list configuration setting " "not defined: Checking only host tags for %s/%s" , lv->vg->name, lv->name);
@@ -434,7 +436,7 @@ static int _passes_activation_filter(struct cmd_context *cmd,return 0 ; } -return _lv_passes_volumes_filter (cmd, lv, cn,"activation/volume_list" ); +return _lv_passes_volumes_filter (cmd, lv, cn, activation_volume_list_CFG); } static int _passes_readonly_filter(struct cmd_context *cmd,
@@ -442,10 +444,10 @@ static int _passes_readonly_filter(struct cmd_context *cmd, {const struct dm_config_node *cn; -if (!(cn =find_config_tree_node (cmd,"activation/read_only_volume_list" ))) +if (!(cn =find_config_tree_node (cmd, activation_read_only_volume_list_CFG)))return 0 ; -return _lv_passes_volumes_filter (cmd, lv, cn,"activation/read_only_volume_list" ); +return _lv_passes_volumes_filter (cmd, lv, cn, activation_read_only_volume_list_CFG); }
@@ -453,13 +455,13 @@ int lv_passes_auto_activation_filter(struct cmd_context *cmd, struct logical_vol {const struct dm_config_node *cn; -if (!(cn =find_config_tree_node (cmd,"activation/auto_activation_volume_list" ))) { +if (!(cn =find_config_tree_node (cmd, activation_auto_activation_volume_list_CFG))) {log_verbose ("activation/auto_activation_volume_list configuration setting " "not defined: All logical volumes will be auto-activated." );return 1 ; } -return _lv_passes_volumes_filter (cmd, lv, cn,"activation/auto_activation_volume_list" ); +return _lv_passes_volumes_filter (cmd, lv, cn, activation_auto_activation_volume_list_CFG); }int library_version (char *version,size_t size)
@@ -1152,7 +1154,7 @@ static struct dm_event_handler *_create_dm_event_handler(struct cmd_context *cmdif (!(dmevh =dm_event_handler_create ())) return_NULL; -if (dm_event_handler_set_dmeventd_path (dmevh,find_config_tree_str (cmd,"dmeventd/executable" ,NULL ))) +if (dm_event_handler_set_dmeventd_path (dmevh,find_config_tree_str (cmd, dmeventd_executable_CFG))) goto_bad;if (dm_event_handler_set_dso (dmevh, dso))
lib/activate/dev_manager.c +2 -4
@@ -1450,9 +1450,7 @@ static int _thin_pool_callback(struct dm_tree_node *node,const struct dm_config_node *cn;const struct dm_config_value *cv;const char *thin_check = -find_config_tree_str_allow_empty (data->pool_lv->vg->cmd, -"global/thin_check_executable" , -THIN_CHECK_CMD ); +find_config_tree_str_allow_empty (data->pool_lv->vg->cmd, global_thin_check_executable_CFG);const struct logical_volume *mlv =first_seg (data->pool_lv)->metadata_lv;size_t len =strlen (dmdir) +2 * (strlen (mlv->vg->name) +strlen (mlv->name)) +3 ;char meta_path[len];
@@ -1470,7 +1468,7 @@ static int _thin_pool_callback(struct dm_tree_node *node,return 0 ; } -if ((cn =find_config_tree_node (mlv->vg->cmd,"global/thin_check_options" ))) { +if ((cn =find_config_tree_node (mlv->vg->cmd, global_thin_check_options_CFG))) {for (cv = cn->v; cv && args <16 ; cv = cv->next) {if (cv->type !=DM_CFG_STRING ) { log_error("Invalid string in config file: "
lib/commands/toolcontext.c +68 -107
449 lines not on this page · raw message
lib/commands/toolcontext.h +1 -0
@@ -100,6 +100,7 @@ struct cmd_context {struct dm_config_tree *cft;struct config_info default_settings;struct config_info current_settings; +struct dm_hash_table *cft_def_hash;/* cft definition hash used for validity check */ struct archive_params *archive_params;struct backup_params *backup_params;
lib/config/config.c +52 -19
96 lines not on this page · raw message
lib/config/config.h +7 -14
@@ -113,19 +113,12 @@ int merge_config_tree(struct cmd_context *cmd, struct dm_config_tree *cft,/* * These versions check an override tree, if present, first. */ -const struct dm_config_node *find_config_tree_node (struct cmd_context *cmd, -const char *path); -const char *find_config_tree_str (struct cmd_context *cmd, -const char *path,const char *fail); -const char *find_config_tree_str_allow_empty (struct cmd_context *cmd, -const char *path,const char *fail); -int find_config_tree_int (struct cmd_context *cmd,const char *path, -int fail); -int64_t find_config_tree_int64 (struct cmd_context *cmd,const char *path, -int64_t fail); -float find_config_tree_float (struct cmd_context *cmd,const char *path, -float fail); - -int find_config_tree_bool (struct cmd_context *cmd,const char *path,int fail); +const struct dm_config_node *find_config_tree_node (struct cmd_context *cmd,int id); +const char *find_config_tree_str (struct cmd_context *cmd,int id); +const char *find_config_tree_str_allow_empty (struct cmd_context *cmd,int id); +int find_config_tree_int (struct cmd_context *cmd,int id); +int64_t find_config_tree_int64 (struct cmd_context *cmd,int id); +float find_config_tree_float (struct cmd_context *cmd,int id); +int find_config_tree_bool (struct cmd_context *cmd,int id);#endif
lib/config/defaults.h +0 -1
@@ -86,7 +86,6 @@#define DEFAULT_STRIPESIZE 64/* KB */ #define DEFAULT_PVMETADATAIGNORE 0 -#define DEFAULT_PVMETADATAIGNORE_STR "n"#define DEFAULT_PVMETADATASIZE 255#define DEFAULT_PVMETADATACOPIES 1#define DEFAULT_VGMETADATACOPIES 0
lib/device/dev-cache.c +1 -1
@@ -675,7 +675,7 @@ static int _init_preferred_names(struct cmd_context *cmd) _cache.preferred_names_matcher =NULL ; -if (!(cn =find_config_tree_node (cmd,"devices/preferred_names" )) || +if (!(cn =find_config_tree_node (cmd, devices_preferred_names_CFG)) || cn->v->type ==DM_CFG_EMPTY_ARRAY ) {log_very_verbose ("devices/preferred_names not found in config file: " "using built-in preferences" );
lib/display/display.c +1 -2
@@ -526,8 +526,7 @@ int lvdisplay_full(struct cmd_context *cmd,log_print ("--- Logical volume ---" ); - lvm1compat =find_config_tree_int (cmd,"global/lvdisplay_shows_full_device_path" , -DEFAULT_LVDISPLAY_SHOWS_FULL_DEVICE_PATH ); + lvm1compat =find_config_tree_bool (cmd, global_lvdisplay_shows_full_device_path_CFG);if (lvm1compat)/* /dev/vgname/lvname doen't actually exist for internal devices */
lib/format_text/format-text.c +3 -5
@@ -1477,9 +1477,7 @@ static int _text_pv_initialise(const struct format_type *fmt,unsigned long adjustment, final_alignment =0 ;if (!data_alignment) - data_alignment =find_config_tree_int (pv->fmt->cmd, -"devices/data_alignment" , -0 ) *2 ; + data_alignment =find_config_tree_int (pv->fmt->cmd, devices_data_alignment_CFG) *2 ;if (set_pe_align (pv, data_alignment) != data_alignment && data_alignment) {
@@ -2443,7 +2441,7 @@ struct format_type *create_text_format(struct cmd_context *cmd) goto bad; } -if ((cn =find_config_tree_node (cmd,"metadata/dirs" ))) { +if ((cn =find_config_tree_node (cmd, metadata_dirs_CFG))) {for (cv = cn->v; cv; cv = cv->next) {if (cv->type !=DM_CFG_STRING ) { log_error("Invalid string in config file: "
@@ -2460,7 +2458,7 @@ struct format_type *create_text_format(struct cmd_context *cmd) } } -if ((cn =find_config_tree_node (cmd,"metadata/disk_areas" ))) { +if ((cn =find_config_tree_node (cmd, metadata_disk_areas_CFG))) {for (cn = cn->child; cn; cn = cn->sib) {if (!_get_config_disk_area (cmd, cn, &mda_lists->raws)) goto_bad;
lib/locking/external_locking.c +2 -2
@@ -80,8 +80,8 @@ int init_external_locking(struct locking_type *locking, struct cmd_context *cmd, locking->reset_locking = _reset_external_locking; locking->flags =0 ; - libname =find_config_tree_str (cmd,"global/locking_library" , -DEFAULT_LOCKING_LIB ); +if (!(libname =find_config_tree_str (cmd, global_locking_library_CFG))) + libname =DEFAULT_LOCKING_LIB ;if (!(_locking_lib =load_shared_library (cmd, libname,"locking" ,1 ))) return_0;
lib/locking/file_locking.c +2 -4
@@ -346,8 +346,7 @@ int init_file_locking(struct locking_type *locking, struct cmd_context *cmd, locking->flags =0 ;/* Get lockfile directory from config file */ - locking_dir =find_config_tree_str (cmd,"global/locking_dir" , -DEFAULT_LOCK_DIR ); + locking_dir =find_config_tree_str (cmd, global_locking_dir_CFG);if (strlen (locking_dir) >=sizeof (_lock_dir)) {log_error ("Path for locking_dir %s is invalid." , locking_dir);return 0 ;
@@ -356,8 +355,7 @@ int init_file_locking(struct locking_type *locking, struct cmd_context *cmd,strcpy (_lock_dir, locking_dir); _prioritise_write_locks = -find_config_tree_bool (cmd,"global/prioritise_write_locks" , -DEFAULT_PRIORITISE_WRITE_LOCKS ); +find_config_tree_bool (cmd, global_prioritise_write_locks_CFG); (void )dm_prepare_selinux_context (_lock_dir,S_IFDIR ); r =dm_create_dir (_lock_dir);
lib/locking/locking.c +4 -9
@@ -225,10 +225,9 @@ int init_locking(int type, struct cmd_context *cmd, int suppress_messages) suppress_messages =1 ;if (type <0 ) - type =find_config_tree_int (cmd,"global/locking_type" ,1 ); + type =find_config_tree_int (cmd, global_locking_type_CFG); - _blocking_supported =find_config_tree_int (cmd, -"global/wait_for_locks" ,DEFAULT_WAIT_FOR_LOCKS ); + _blocking_supported =find_config_tree_bool (cmd, global_wait_for_locks_CFG);switch (type) {case 0 :
@@ -255,9 +254,7 @@ int init_locking(int type, struct cmd_context *cmd, int suppress_messages)if (init_external_locking (&_locking, cmd, suppress_messages))return 1 ; } -if (!find_config_tree_int (cmd,"locking/fallback_to_clustered_locking" , -find_config_tree_int (cmd,"global/fallback_to_clustered_locking" , -DEFAULT_FALLBACK_TO_CLUSTERED_LOCKING ))) { +if (!find_config_tree_bool (cmd, global_fallback_to_clustered_locking_CFG)) {log_error_suppress (suppress_messages,"External locking initialisation failed." );break ; }
@@ -290,9 +287,7 @@ int init_locking(int type, struct cmd_context *cmd, int suppress_messages) }if ((type ==2 || type ==3 ) && -find_config_tree_int (cmd,"locking/fallback_to_local_locking" , -find_config_tree_int (cmd,"global/fallback_to_local_locking" , -DEFAULT_FALLBACK_TO_LOCAL_LOCKING ))) { +find_config_tree_bool (cmd, global_fallback_to_local_locking_CFG)) {log_warn_suppress (suppress_messages,"WARNING: Falling back to local file-based locking." );log_warn_suppress (suppress_messages, "Volume Groups with the clustered attribute will "
lib/metadata/lv_manip.c +7 -10
@@ -95,8 +95,8 @@ int get_default_region_size(struct cmd_context *cmd)* 'mirror_region_size' is the old setting. It is overridden * by the new setting, 'raid_region_size'. */ - mrs =2 *find_config_tree_int (cmd,"activation/mirror_region_size" ,0 ); - rrs =2 *find_config_tree_int (cmd,"activation/raid_region_size" ,0 ); + mrs =2 *find_config_tree_int (cmd, activation_mirror_region_size_CFG); + rrs =2 *find_config_tree_int (cmd, activation_raid_region_size_CFG);if (!mrs && !rrs)return DEFAULT_RAID_REGION_SIZE *2 ;
@@ -921,8 +921,7 @@ static struct alloc_handle *_alloc_init(struct cmd_context *cmd,* a correct area_multiple. */ ah->area_multiple =_calc_area_multiple (segtype, area_count + parity_count, stripes); - ah->mirror_logs_separate =find_config_tree_bool (cmd,"allocation/mirror_logs_require_separate_pvs" , -DEFAULT_MIRROR_LOGS_REQUIRE_SEPARATE_PVS ); + ah->mirror_logs_separate =find_config_tree_bool (cmd, allocation_mirror_logs_require_separate_pvs_CFG);if (segtype_is_raid (segtype)) {if (metadata_area_count) {
@@ -949,8 +948,7 @@ static struct alloc_handle *_alloc_init(struct cmd_context *cmd, ah->log_len = ah->region_size; ah->region_size =0 ; ah->mirror_logs_separate = -find_config_tree_bool (cmd,"allocation/thin_pool_metadata_require_separate_pvs" , -DEFAULT_THIN_POOL_METADATA_REQUIRE_SEPARATE_PVS ); +find_config_tree_bool (cmd, allocation_thin_pool_metadata_require_separate_pvs_CFG); }else { ah->log_area_count = metadata_area_count; ah->log_len = !metadata_area_count ? 0 :
@@ -963,9 +961,9 @@ static struct alloc_handle *_alloc_init(struct cmd_context *cmd, ah->parallel_areas = parallel_areas; - ah->cling_tag_list_cn =find_config_tree_node (cmd,"allocation/cling_tag_list" ); + ah->cling_tag_list_cn =find_config_tree_node (cmd, allocation_cling_tag_list_CFG); - ah->maximise_cling =find_config_tree_bool (cmd,"allocation/maximise_cling" ,DEFAULT_MAXIMISE_CLING ); + ah->maximise_cling =find_config_tree_bool (cmd, allocation_maximise_cling_CFG);return ah; }
@@ -3389,8 +3387,7 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv, }/* FIXME Ensure not referred to by another existing LVs */ - ask_discard =find_config_tree_bool (cmd, -"devices/issue_discards" ,DEFAULT_ISSUE_DISCARDS ); + ask_discard =find_config_tree_bool (cmd, devices_issue_discards_CFG);if (lv_info (cmd, lv,0 , &info,1 ,0 )) {if (!lv_check_not_in_use (cmd, lv, &info))
lib/metadata/metadata.c +4 -11
@@ -74,9 +74,7 @@ unsigned long set_pe_align(struct physical_volume *pv, unsigned long data_alignm goto out; } - default_pe_align =find_config_tree_int (pv->fmt->cmd, -"devices/default_data_alignment" , -DEFAULT_DATA_ALIGNMENT ); + default_pe_align =find_config_tree_int (pv->fmt->cmd, devices_default_data_alignment_CFG);if (default_pe_align)/* align on 1 MiB multiple */
@@ -94,8 +92,7 @@ unsigned long set_pe_align(struct physical_volume *pv, unsigned long data_alignm/* * Align to stripe-width of underlying md device if present */ -if (find_config_tree_bool (pv->fmt->cmd,"devices/md_chunk_alignment" , -DEFAULT_MD_CHUNK_ALIGNMENT )) { +if (find_config_tree_bool (pv->fmt->cmd, devices_md_chunk_alignment_CFG)) { temp_pe_align =dev_md_stripe_width (pv->fmt->cmd->sysfs_dir, pv->dev);if (_alignment_overrides_default (temp_pe_align, default_pe_align)) pv->pe_align =MAX (pv->pe_align, temp_pe_align);
@@ -108,9 +105,7 @@ unsigned long set_pe_align(struct physical_volume *pv, unsigned long data_alignm* - optimal_io_size - the device's preferred unit of receiving I/O * (e.g. MD's stripe width) */ -if (find_config_tree_bool (pv->fmt->cmd, -"devices/data_alignment_detection" , -DEFAULT_DATA_ALIGNMENT_DETECTION )) { +if (find_config_tree_bool (pv->fmt->cmd, devices_data_alignment_detection_CFG)) { temp_pe_align =dev_minimum_io_size (pv->fmt->cmd->sysfs_dir, pv->dev);if (_alignment_overrides_default (temp_pe_align, default_pe_align)) pv->pe_align =MAX (pv->pe_align, temp_pe_align);
@@ -142,9 +137,7 @@ unsigned long set_pe_align_offset(struct physical_volume *pv,if (!pv->dev) goto out; -if (find_config_tree_bool (pv->fmt->cmd, -"devices/data_alignment_offset_detection" , -DEFAULT_DATA_ALIGNMENT_OFFSET_DETECTION )) { +if (find_config_tree_bool (pv->fmt->cmd, devices_data_alignment_offset_detection_CFG)) {int align_offset =dev_alignment_offset (pv->fmt->cmd->sysfs_dir, pv->dev);/* must handle a -1 alignment_offset; means dev is misaligned */
lib/metadata/mirror.c +6 -9
@@ -1230,19 +1230,16 @@ int collapse_mirrored_lv(struct logical_volume *lv)static int _get_mirror_fault_policy (struct cmd_context *cmd __attribute__((unused)),int log_policy) { -const char *policy; - +const char *policy =NULL ; +/* if (log_policy) - policy =dm_config_find_str (NULL ,"activation/mirror_log_fault_policy" , -DEFAULT_MIRROR_LOG_FAULT_POLICY ); +policy = find_config_tree_str(cmd, activation_mirror_log_fault_policy_CFG); else { - policy =dm_config_find_str (NULL ,"activation/mirror_image_fault_policy" , -NULL ); +policy = find_config_tree_str(cmd, activation_mirror_image_fault_policy_CFG); if (!policy) - policy =dm_config_find_str (NULL ,"activation/mirror_device_fault_policy" , -DEFAULT_MIRROR_IMAGE_FAULT_POLICY ); +policy = find_config_tree_str(cmd, activation_mirror_device_fault_policy_CFG); } - +*/ if (!strcmp (policy,"remove" ))return MIRROR_REMOVE ;else if (!strcmp (policy,"allocate" ))
lib/metadata/pv_manip.c +1 -2
@@ -203,8 +203,7 @@ int discard_pv_segment(struct pv_segment *peg, uint32_t discard_area_reduction)* Only issue discards if enabled in lvm.conf and both * the device and kernel (>= 2.6.35) supports discards. */ -if (!find_config_tree_bool (peg->pv->fmt->cmd, -"devices/issue_discards" ,DEFAULT_ISSUE_DISCARDS )) +if (!find_config_tree_bool (peg->pv->fmt->cmd, devices_issue_discards_CFG))return 1 ;/* Missing PV? */
lib/metadata/thin_manip.c +1 -3
@@ -312,9 +312,7 @@ int pool_below_threshold(const struct lv_segment *pool_seg) {percent_t percent;int threshold =PERCENT_1 * -find_config_tree_int (pool_seg->lv->vg->cmd, -"activation/thin_pool_autoextend_threshold" , -DEFAULT_THIN_POOL_AUTOEXTEND_THRESHOLD ); +find_config_tree_int (pool_seg->lv->vg->cmd, activation_thin_pool_autoextend_threshold_CFG);/* Data */ if (!lv_thin_pool_percent (pool_seg->lv,0 , &percent))
lib/mirror/mirrored.c +1 -2
@@ -540,8 +540,7 @@ static int _mirrored_target_present(struct cmd_context *cmd,#ifdef DMEVENTD static const char *_get_mirror_dso_path (struct cmd_context *cmd) { -return get_monitor_dso_path (cmd,find_config_tree_str (cmd,"dmeventd/mirror_library" , -DEFAULT_DMEVENTD_MIRROR_LIB )); +return get_monitor_dso_path (cmd,find_config_tree_str (cmd, dmeventd_mirror_library_CFG)); }/* FIXME Cache this */
lib/misc/sharedlib.c +1 -1
@@ -30,7 +30,7 @@ void get_shared_library_path(struct cmd_context *cmd, const char *libname,/* If libname doesn't begin with '/' then use lib_dir/libname, * if present */ if (libname[0 ] =='/' || - !(lib_dir =find_config_tree_str (cmd,"global/library_dir" ,0 )) || + !(lib_dir =find_config_tree_str (cmd, global_library_dir_CFG)) || (dm_snprintf (path, path_len,"%s/%s" , lib_dir, libname) ==-1 ) ||stat (path, &info) ==-1 ) {strncpy (path, libname, path_len -1 );
lib/mm/memlock.c +5 -10
@@ -290,7 +290,7 @@ static int _memlock_maps(struct cmd_context *cmd, lvmlock_t lock, size_t *mstats } line = _maps_buffer; - cn =find_config_tree_node (cmd,"activation/mlock_filter" ); + cn =find_config_tree_node (cmd, activation_mlock_filter_CFG);while ((line_end =strchr (line,'\n' ))) { *line_end ='\0' ;/* remove \n */
@@ -317,7 +317,7 @@ static void _lock_mem(struct cmd_context *cmd)* Note: assuming _memlock_count_daemon is updated before _memlock_count */ _use_mlockall = _memlock_count_daemon ?1 : -find_config_tree_bool (cmd,"activation/use_mlockall" ,DEFAULT_USE_MLOCKALL ); +find_config_tree_bool (cmd, activation_use_mlockall_CFG);if (!_use_mlockall) { if (!*_procselfmaps &&
@@ -453,14 +453,9 @@ void memlock_init(struct cmd_context *cmd) {/* When threaded, caller already limited stack size so just use the default. */ _size_stack =1024ULL * (cmd->threaded ?DEFAULT_RESERVED_STACK : -find_config_tree_int (cmd,"activation/reserved_stack" , -DEFAULT_RESERVED_STACK )); - _size_malloc_tmp =find_config_tree_int (cmd, -"activation/reserved_memory" , -DEFAULT_RESERVED_MEMORY ) *1024ULL ; - _default_priority =find_config_tree_int (cmd, -"activation/process_priority" , -DEFAULT_PROCESS_PRIORITY ); +find_config_tree_int (cmd, activation_reserved_stack_CFG)); + _size_malloc_tmp =find_config_tree_int (cmd, activation_reserved_memory_CFG) *1024ULL ; + _default_priority =find_config_tree_int (cmd, activation_process_priority_CFG); }void memlock_reset (void )
lib/raid/raid.c +1 -2
@@ -282,8 +282,7 @@ static void _raid_destroy(struct segment_type *segtype)#ifdef DMEVENTD static const char *_get_raid_dso_path (struct cmd_context *cmd) { -const char *config_str =find_config_tree_str (cmd,"dmeventd/raid_library" , -DEFAULT_DMEVENTD_RAID_LIB ); +const char *config_str =find_config_tree_str (cmd, dmeventd_raid_library_CFG);return get_monitor_dso_path (cmd, config_str); }
lib/snapshot/snapshot.c +1 -2
@@ -175,8 +175,7 @@ static int _snap_target_present(struct cmd_context *cmd,static const char *_get_snapshot_dso_path (struct cmd_context *cmd) { -return get_monitor_dso_path (cmd,find_config_tree_str (cmd,"dmeventd/snapshot_library" , -DEFAULT_DMEVENTD_SNAPSHOT_LIB )); +return get_monitor_dso_path (cmd,find_config_tree_str (cmd, dmeventd_snapshot_library_CFG)); }/* FIXME Cache this */
lib/thin/thin.c +2 -3
@@ -379,8 +379,7 @@ static int _thin_pool_target_percent(void **target_state __attribute__((unused))# ifdef DMEVENTD static const char *_get_thin_dso_path (struct cmd_context *cmd) { -return get_monitor_dso_path (cmd,find_config_tree_str (cmd,"dmeventd/thin_library" , -DEFAULT_DMEVENTD_THIN_LIB )); +return get_monitor_dso_path (cmd,find_config_tree_str (cmd, dmeventd_thin_library_CFG)); }/* FIXME Cache this */
@@ -596,7 +595,7 @@ static int _thin_target_present(struct cmd_context *cmd,if (attributes) {if (!_feature_mask) {/* Support runtime lvm.conf changes, N.B. avoid 32 feature */ -if ((cn =find_config_tree_node (cmd, _lvmconf))) { +if ((cn =find_config_tree_node (cmd, global_thin_disabled_features_CFG))) {for (cv = cn->v; cv; cv = cv->next) {if (cv->type !=DM_CFG_STRING ) { log_error("Ignoring invalid string in config file %s.",
liblvm/lvm_base.c +3 -1
@@ -96,7 +96,9 @@ int lvm_config_override(lvm_t libh, const char *config_settings)int lvm_config_find_bool (lvm_t libh,const char *config_path,int fail) { -return find_config_tree_bool ((struct cmd_context *)libh, config_path, fail); +struct cmd_context *cmd = (struct cmd_context *)libh; + +return dm_config_tree_find_bool (cmd->cft, config_path, fail); }int lvm_errno (lvm_t libh)
tools/lvconvert.c +4 -9
@@ -837,15 +837,10 @@ static void _lvconvert_mirrors_repair_ask(struct cmd_context *cmd, *replace_log = *replace_mirrors =1 ;if (arg_count (cmd, use_policies_ARG)) { - leg_policy =find_config_tree_str (cmd, -"activation/mirror_image_fault_policy" ,NULL ); + leg_policy =find_config_tree_str (cmd, activation_mirror_image_fault_policy_CFG);if (!leg_policy) - leg_policy =find_config_tree_str (cmd, -"activation/mirror_device_fault_policy" , -DEFAULT_MIRROR_DEVICE_FAULT_POLICY ); - log_policy =find_config_tree_str (cmd, -"activation/mirror_log_fault_policy" , -DEFAULT_MIRROR_LOG_FAULT_POLICY ); + leg_policy =find_config_tree_str (cmd, activation_mirror_device_fault_policy_CFG); + log_policy =find_config_tree_str (cmd, activation_mirror_log_fault_policy_CFG); *replace_mirrors =strcmp (leg_policy,"remove" ); *replace_log =strcmp (log_policy,"remove" );return ;
@@ -1571,7 +1566,7 @@ static void _lvconvert_raid_repair_ask(struct cmd_context *cmd, int *replace_dev *replace_dev =1 ;if (arg_count (cmd, use_policies_ARG)) { - dev_policy =find_config_tree_str (cmd,"activation/raid_fault_policy" ,DEFAULT_RAID_FAULT_POLICY ); + dev_policy =find_config_tree_str (cmd, activation_raid_fault_policy_CFG);if (!strcmp (dev_policy,"allocate" ) || !strcmp (dev_policy,"replace" ))
tools/lvcreate.c +3 -5
@@ -506,9 +506,7 @@ static int _read_raid_params(struct lvcreate_params *lp, }/* No stripe argument was given - default to 2 */ lp->stripes =2 ; - lp->stripe_size =find_config_tree_int (cmd, -"metadata/stripesize" , -DEFAULT_STRIPESIZE ) *2 ; + lp->stripe_size =find_config_tree_int (cmd, metadata_stripesize_CFG) *2 ; }/*
@@ -675,9 +673,9 @@ static int _lvcreate_params(struct lvcreate_params *lp,if (arg_count (cmd, mirrors_ARG))if (arg_uint_value (cmd,arg_count (cmd, stripes_long_ARG) ? stripes_long_ARG : stripes_ARG,1 ) >1 ) { - segtype_str =find_config_tree_str (cmd,"global/raid10_segtype_default" ,DEFAULT_RAID10_SEGTYPE ); + segtype_str =find_config_tree_str (cmd, global_raid10_segtype_default_CFG);; }else { - segtype_str =find_config_tree_str (cmd,"global/mirror_segtype_default" ,DEFAULT_MIRROR_SEGTYPE ); + segtype_str =find_config_tree_str (cmd, global_mirror_segtype_default_CFG); }else if (arg_count (cmd, thin_ARG) ||arg_count (cmd, thinpool_ARG)) segtype_str ="thin" ;
tools/lvm.c +1 -2
@@ -158,8 +158,7 @@ static void _read_history(struct cmd_context *cmd)if (read_history (hist_file))log_very_verbose ("Couldn't read history from %s." , hist_file); -stifle_history (find_config_tree_int (cmd,"shell/history_size" , -DEFAULT_MAX_HISTORY )); +stifle_history (find_config_tree_int (cmd, shell_history_size_CFG)); }static void _write_history (void )
tools/lvmcmdline.c +1 -2
@@ -1443,8 +1443,7 @@ static int _lvm1_fallback(struct cmd_context *cmd)char vsn[80 ];int dm_present; -if (!find_config_tree_int (cmd,"global/fallback_to_lvm1" , -DEFAULT_FALLBACK_TO_LVM1 ) || +if (!find_config_tree_bool (cmd, global_fallback_to_lvm1_CFG) ||strncmp (cmd->kernel_vsn,"2.4." ,4 ))return 0 ;
tools/lvresize.c +5 -11
@@ -288,20 +288,16 @@ static int _adjust_policy_params(struct cmd_context *cmd,if (lv_is_thin_pool (lv)) { policy_threshold = -find_config_tree_int (cmd,"activation/thin_pool_autoextend_threshold" , -DEFAULT_THIN_POOL_AUTOEXTEND_THRESHOLD ) *PERCENT_1 ; +find_config_tree_int (cmd, activation_thin_pool_autoextend_threshold_CFG) *PERCENT_1 ; policy_amount = -find_config_tree_int (cmd,"activation/thin_pool_autoextend_percent" , -DEFAULT_THIN_POOL_AUTOEXTEND_PERCENT ); +find_config_tree_int (cmd, activation_thin_pool_autoextend_percent_CFG);if (!policy_amount && policy_threshold <PERCENT_100 )return 0 ; }else { policy_threshold = -find_config_tree_int (cmd,"activation/snapshot_autoextend_threshold" , -DEFAULT_SNAPSHOT_AUTOEXTEND_THRESHOLD ) *PERCENT_1 ; +find_config_tree_int (cmd, activation_snapshot_autoextend_threshold_CFG) *PERCENT_1 ; policy_amount = -find_config_tree_int (cmd,"activation/snapshot_autoextend_percent" , -DEFAULT_SNAPSHOT_AUTOEXTEND_PERCENT ); +find_config_tree_int (cmd, activation_snapshot_autoextend_percent_CFG); }if (policy_threshold >=PERCENT_100 )
@@ -652,9 +648,7 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg, lp->stripe_size = seg_stripesize; }else { lp->stripe_size = -find_config_tree_int (cmd, -"metadata/stripesize" , -DEFAULT_STRIPESIZE ) *2 ; +find_config_tree_int (cmd, metadata_stripesize_CFG) *2 ;log_print_unless_silent ("Using default stripesize %s" ,display_size (cmd, (uint64_t ) lp->stripe_size)); }
tools/polldaemon.c +2 -4
@@ -319,8 +319,7 @@ int poll_daemon(struct cmd_context *cmd, const char *name, const char *uuid,if (interval_sign ==SIGN_MINUS )log_error ("Argument to --interval cannot be negative" ); parms.interval =arg_uint_value (cmd, interval_ARG, -find_config_tree_int (cmd,"activation/polling_interval" , -DEFAULT_INTERVAL )); +find_config_tree_int (cmd, activation_polling_interval_CFG)); parms.wait_before_testing = (interval_sign ==SIGN_PLUS ); parms.progress_display =1 ; parms.progress_title = progress_title;
@@ -337,8 +336,7 @@ int poll_daemon(struct cmd_context *cmd, const char *name, const char *uuid,/* FIXME Disabled multiple-copy wait_event */ if (!name) - parms.interval =find_config_tree_int (cmd,"activation/polling_interval" , -DEFAULT_INTERVAL ); + parms.interval =find_config_tree_int (cmd, activation_polling_interval_CFG); }if (parms.background) {
tools/pvcreate.c +1 -3
@@ -38,9 +38,7 @@ static int pvcreate_restore_params_validate(struct cmd_context *cmd,if (!arg_count (cmd, restorefile_ARG) &&arg_count (cmd, uuidstr_ARG)) {if (!arg_count (cmd, norestorefile_ARG) && -find_config_tree_bool (cmd, -"devices/require_restorefile_with_uuid" , -DEFAULT_REQUIRE_RESTOREFILE_WITH_UUID )) { +find_config_tree_bool (cmd, devices_require_restorefile_with_uuid_CFG)) {log_error ("--restorefile is required with --uuid" );return 0 ; }
tools/pvscan.c +2 -2
@@ -146,8 +146,8 @@ static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv)* and to prevent hangs in clustered environment. */ /* TODO: Remove this once lvmetad + cluster supported! */ -if (find_config_tree_int (cmd,"global/locking_type" ,1 ) ==3 || - !find_config_tree_int (cmd,"global/use_lvmetad" ,0 )) { +if (find_config_tree_int (cmd, global_locking_type_CFG) ==3 || + !find_config_tree_bool (cmd, global_use_lvmetad_CFG)) {log_debug_lvmetad ("_pvscan_lvmetad: immediate return" );return ret; }
tools/reporter.c +22 -54
107 lines not on this page · raw message
tools/toollib.c +14 -32
97 lines not on this page · raw message
tools/vgconvert.c +2 -6
@@ -51,16 +51,12 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name, UINT64_C(0));if (!pvmetadatasize) pvmetadatasize = -find_config_tree_int (cmd, -"metadata/pvmetadatasize" , -DEFAULT_PVMETADATASIZE ); +find_config_tree_int (cmd, metadata_pvmetadatasize_CFG); pvmetadatacopies =arg_int_value (cmd, pvmetadatacopies_ARG,-1 );if (pvmetadatacopies <0 ) pvmetadatacopies = -find_config_tree_int (cmd, -"metadata/pvmetadatacopies" , -DEFAULT_PVMETADATACOPIES ); +find_config_tree_int (cmd, metadata_pvmetadatacopies_CFG); }if (cmd->fmt->features &FMT_EAS ) {