master - config: fix use of last config check status if creating CFG_DEF_TREE_MISSING tree
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=661406a417e3cbf2170ba7c3debd767d50e99cae Commit: 661406a417e3cbf2170ba7c3debd767d50e99cae Parent: f5584d420356c8ca0b797952b07f5b5387957c17 Author: Peter Rajnoha <[email protected]> AuthorDate: Mon Jul 8 14:13:09 2013 +0200 Committer: Peter Rajnoha <[email protected]> CommitterDate: Mon Jul 8 15:57:49 2013 +0200
config: fix use of last config check status if creating CFG_DEF_TREE_MISSING tree
When CFG_DEF_TREE_MISSING is created, it needs to know the status of the check done on the tree used (the CFG_USED flag).
This bug was introduced with f1c292cc38f4ba2e8d9b7272bc1a1ce17bd729a5 "make it possible to run several instances of configuration check at once". This patch separated the CFG_USED and CFG_VALID flags in a separate 'status' field in struct cft_check_handle.
However, when creating some trees, like CFG_DEF_TREE_MISSING, we need this status to do a comparison with full config definition to determine which items are missing and for which default values were used. Otherwise, all items would be considered missing.
So, pass this status in a new field called 'check_status' in struct config_def_tree_spec that defines how the (dumpconfig) tree should be constructed (and this struct is passed to config_def_create_tree fn then).
--- lib/config/config.c | 15 +++++++++++---- lib/config/config.h | 1 + tools/dumpconfig.c | 47 +++++++++++++++++++++++++++++++++-------------- 3 files changed, 45 insertions(+), 18 deletions(-)
lib/config/config.c +11 -4
@@ -1336,8 +1336,10 @@ static struct dm_config_node *_add_def_node(struct dm_config_tree *cft,return cn; } -static int _should_skip_def_node (struct config_def_tree_spec *spec,int section_id,cfg_def_item_t *def) +static int _should_skip_def_node (struct config_def_tree_spec *spec,int section_id,int id) { +cfg_def_item_t *def =cfg_def_get_item_p (id); +if ((def->parent != section_id) || (spec->ignoreadvanced && def->flags &CFG_ADVANCED ) || (spec->ignoreunsupported && def->flags &CFG_UNSUPPORTED ))
@@ -1345,7 +1347,12 @@ static int _should_skip_def_node(struct config_def_tree_spec *spec, int section_switch (spec->type) {case CFG_DEF_TREE_MISSING : -if ((def->flags &CFG_USED ) || +if (!spec->check_status) { +log_error_once (INTERNAL_ERROR "couldn't determine missing " +"config nodes - unknown status of last config check." ); +return 1 ; + } +if ((spec->check_status[id] &CFG_USED ) || (def->flags &CFG_NAME_VARIABLE ) || (def->since_version > spec->version))return 1 ;
@@ -1374,13 +1381,13 @@ static struct dm_config_node *_add_def_section_subtree(struct dm_config_tree *cfint id;for (id =0 ; id <CFG_COUNT ; id++) { - def =cfg_def_get_item_p (id); -if (_should_skip_def_node (spec, section_id, def)) +if (_should_skip_def_node (spec, section_id, id))continue ;if (!cn && !(cn =_add_def_node (cft, spec, parent, relay,cfg_def_get_item_p (section_id)))) goto bad; + def =cfg_def_get_item_p (id);if ((tmp = def->type ==CFG_TYPE_SECTION ?_add_def_section_subtree (cft, spec, cn, relay_sub, id) :_add_def_node (cft, spec, cn, relay_sub, def))) relay_sub = tmp;
lib/config/config.h +1 -0
@@ -110,6 +110,7 @@ struct config_def_tree_spec {uint16_t version;/* tree at this LVM2 version */ int ignoreadvanced;/* do not include advanced configs */ int ignoreunsupported;/* do not include unsupported configs */ +uint8_t *check_status;/* status of last tree check (currently needed for CFG_DEF_TREE_MISSING only) */ };
tools/dumpconfig.c +33 -14
75 lines not on this page · raw message