master - dev-cache: fix mem corruption on refresh context
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=68d13b2517b49f...
Commit: 68d13b2517b49f53e395ea7754c6b8cf0b57dc0e
Parent: d29fe919e6a4000d0d78d2f3c88b291a303b82ac
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Mar 25 10:53:42 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Mar 25 11:22:57 2014 +0100
dev-cache: fix mem corruption on refresh context
When lvm2 command works with clvmd and uses locking in wrong way,
it may 'leak' certain file descriptors in opened (incorrect) state.
dev_cache_exit then destroys memory pool of cached devices, while
_open_devices list in dev-io.c was still referencing them if they
were still opened.
Patch properly calls _close() function to 'self-heal' from this
invalid state, but it will report internal error (so execution
with abort_on_internal_error causes immediate death). On the
normal 'execution', error is only reported, but memory state is
corrected, and linked list is not referencing devices from
released mempool.
For crash see: https://bugzilla.redhat.com/show_bug.cgi?id=1073886
---
WHATS_NEW | 1 +
lib/commands/toolcontext.c | 3 ++-
lib/device/dev-cache.c | 33 ++++++++++++++++++++++++++-------
lib/device/dev-cache.h | 3 ++-
4 files changed, 31 insertions(+), 9 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 4448717..a1eb7ed 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.106 -
====================================
+ Fix memory corruption in cmd context refresh if clvmd leaks opened device.
Reinitialise lvmcache properly on fork to fix premature polldaemon exit.
Add 'lvm dumpconfig --type diff' to show differences from defaults.
Fix swap signature detection for devices smaller then 2MB.
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index f0c0201..0c59ea0 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -1604,7 +1604,8 @@ int refresh_toolcontext(struct cmd_context *cmd)
cmd->filter->destroy(cmd->filter);
cmd->filter = NULL;
}
- dev_cache_exit();
+ if (!dev_cache_exit())
+ stack;
_destroy_dev_types(cmd);
_destroy_tags(cmd);
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 87d2f58..94052dc 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -760,21 +760,38 @@ int dev_cache_init(struct cmd_context *cmd)
return 0;
}
-static void _check_closed(struct device *dev)
+static int _check_for_open_devices(int close_immediate)
{
- if (dev->fd >= 0)
- log_error("Device '%s' has been left open.", dev_name(dev));
+ struct device *dev;
+ struct dm_hash_node *n;
+ int r = 0;
+
+ dm_hash_iterate(n, _cache.names) {
+ dev = (struct device *) dm_hash_get_data(_cache.names, n);
+ if (dev->fd >= 0) {
+ log_error("Device '%s' has been left open (%d).",
+ dev_name(dev), dev->open_count);
+ r++;
+ if (close_immediate)
+ dev_close_immediate(dev);
+ }
+ }
+
+ return r;
}
-static void _check_for_open_devices(void)
+int dev_cache_check_for_open_devices(void)
{
- dm_hash_iter(_cache.names, (dm_hash_iterate_fn) _check_closed);
+ return _check_for_open_devices(0);
}
-void dev_cache_exit(void)
+int dev_cache_exit(void)
{
+ int cnt = 0;
+
if (_cache.names)
- _check_for_open_devices();
+ if ((cnt = _check_for_open_devices(1)) > 0)
+ log_error(INTERNAL_ERROR "%d device(s) have been closed.", cnt);
if (_cache.preferred_names_matcher)
_cache.preferred_names_matcher = NULL;
@@ -793,6 +810,8 @@ void dev_cache_exit(void)
_cache.has_scanned = 0;
dm_list_init(&_cache.dirs);
dm_list_init(&_cache.files);
+
+ return (cnt == 0);
}
int dev_cache_add_dir(const char *path)
diff --git a/lib/device/dev-cache.h b/lib/device/dev-cache.h
index 0d342c5..c18d5f6 100644
--- a/lib/device/dev-cache.h
+++ b/lib/device/dev-cache.h
@@ -36,7 +36,8 @@ struct dev_filter {
*/
struct cmd_context;
int dev_cache_init(struct cmd_context *cmd);
-void dev_cache_exit(void);
+int dev_cache_check_for_open_devices(void);
+int dev_cache_exit(void);
/* Trigger(1) or avoid(0) a scan */
void dev_cache_scan(int do_scan);
9 years, 2 months
master - WHATS_NEW: commit f12ee43
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d29fe919e6a400...
Commit: d29fe919e6a4000d0d78d2f3c88b291a303b82ac
Parent: c84face8ceec82123a5d4ecc309ab9bb7fbbfddf
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Mar 25 11:00:44 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Mar 25 11:00:44 2014 +0100
WHATS_NEW: commit f12ee43
---
WHATS_NEW | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 4ac1fa2..4448717 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.106 -
====================================
+ Reinitialise lvmcache properly on fork to fix premature polldaemon exit.
Add 'lvm dumpconfig --type diff' to show differences from defaults.
Fix swap signature detection for devices smaller then 2MB.
Reindent some clvmd.c code.
9 years, 2 months
master - libdaemon: fix misleading "WARNING: Ignoring unsupported value for expected." when communicating with daemon
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c84face8ceec82...
Commit: c84face8ceec82123a5d4ecc309ab9bb7fbbfddf
Parent: 9446978e642c8f580386aa0279910553ab540fad
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Mar 24 16:47:08 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Mar 24 16:47:08 2014 +0100
libdaemon: fix misleading "WARNING: Ignoring unsupported value for expected." when communicating with daemon
When we're trying to search for certain tree node
in daemon's reply, we default to a blank string ""
if the node is not found. This happens during lvmetad
initialization.
However, when the default blank string is used, we
can't use dm_config_find_str at the same time - the
dm_config_find_str_allow_empty should be used instead.
Otherwise a a warning message:
"WARNING: Ignoring unsupported value for ..."
is issued.
---
libdaemon/client/daemon-client.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/libdaemon/client/daemon-client.h b/libdaemon/client/daemon-client.h
index 6ba65e6..8a44f8b 100644
--- a/libdaemon/client/daemon-client.h
+++ b/libdaemon/client/daemon-client.h
@@ -102,7 +102,7 @@ static inline int64_t daemon_reply_int(daemon_reply r, const char *path, int64_t
}
static inline const char *daemon_reply_str(daemon_reply r, const char *path, const char *def) {
- return dm_config_find_str(r.cft->root, path, def);
+ return dm_config_find_str_allow_empty(r.cft->root, path, def);
}
9 years, 2 months
master - config: define default value for global/thin_disabled_features as NULL instead
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9446978e642c8f...
Commit: 9446978e642c8f580386aa0279910553ab540fad
Parent: 4e47c34ffc6f1c7750b21074b733cf6356002c11
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Mar 24 16:31:27 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Mar 24 16:31:27 2014 +0100
config: define default value for global/thin_disabled_features as NULL instead
Before:
thin_disabled_features = ""
Now:
thin_disabled_features = []
Which is a more correct and consistent way of specifying void array
though parses can handle both forms.
---
lib/config/config_settings.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index 6fcf1a7..dce77b9 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -176,7 +176,7 @@ cfg(global_lvdisplay_shows_full_device_path_CFG, "lvdisplay_shows_full_device_pa
cfg(global_use_lvmetad_CFG, "use_lvmetad", global_CFG_SECTION, 0, CFG_TYPE_BOOL, 0, vsn(2, 2, 93), NULL)
cfg(global_thin_check_executable_CFG, "thin_check_executable", global_CFG_SECTION, CFG_ALLOW_EMPTY, CFG_TYPE_STRING, THIN_CHECK_CMD, vsn(2, 2, 94), NULL)
cfg_array(global_thin_check_options_CFG, "thin_check_options", global_CFG_SECTION, 0, CFG_TYPE_STRING, "#S" DEFAULT_THIN_CHECK_OPTIONS, vsn(2, 2, 96), NULL)
-cfg_array(global_thin_disabled_features_CFG, "thin_disabled_features", global_CFG_SECTION, CFG_ALLOW_EMPTY, CFG_TYPE_STRING, "#S", vsn(2, 2, 99), NULL)
+cfg_array(global_thin_disabled_features_CFG, "thin_disabled_features", global_CFG_SECTION, CFG_ALLOW_EMPTY, CFG_TYPE_STRING, NULL, vsn(2, 2, 99), NULL)
cfg(global_thin_dump_executable_CFG, "thin_dump_executable", global_CFG_SECTION, CFG_ALLOW_EMPTY, CFG_TYPE_STRING, THIN_DUMP_CMD, vsn(2, 2, 100), NULL)
cfg(global_thin_repair_executable_CFG, "thin_repair_executable", global_CFG_SECTION, CFG_ALLOW_EMPTY, CFG_TYPE_STRING, THIN_REPAIR_CMD, vsn(2, 2, 100), NULL)
cfg_array(global_thin_repair_options_CFG, "thin_repair_options", global_CFG_SECTION, 0, CFG_TYPE_STRING, "#S" DEFAULT_THIN_REPAIR_OPTIONS, vsn(2, 2, 100), NULL)
9 years, 2 months
master - config: also check empty arrays for difference against default values
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4e47c34ffc6f1c...
Commit: 4e47c34ffc6f1c7750b21074b733cf6356002c11
Parent: 5dcec1734e653ca137975bdfd4556e93447f10a0
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Mar 24 16:30:47 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Mar 24 16:30:47 2014 +0100
config: also check empty arrays for difference against default values
---
lib/config/config.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/lib/config/config.c b/lib/config/config.c
index 161241e..a751d3e 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -740,6 +740,9 @@ static int _check_value_differs_from_default(struct cft_check_handle *handle,
diff = strcmp(str, v->v.str);
}
break;
+ case DM_CFG_EMPTY_ARRAY:
+ diff = v_def->type != DM_CFG_EMPTY_ARRAY;
+ break;
default:
log_error(INTERNAL_ERROR "inconsistent state reached in _check_value_differs_from_default");
return 0;
9 years, 2 months
master - dumpconfig: add dumpconfig --type diff to show differences from defaults
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5dcec1734e653c...
Commit: 5dcec1734e653ca137975bdfd4556e93447f10a0
Parent: 76ff38fa5cdec332750452c2ed209d4beac261eb
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Mar 24 13:19:15 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Mar 24 15:35:54 2014 +0100
dumpconfig: add dumpconfig --type diff to show differences from defaults
---
WHATS_NEW | 1 +
lib/config/config.c | 9 +++++++++
lib/config/config.h | 3 ++-
tools/commands.h | 2 +-
tools/dumpconfig.c | 23 ++++++++++++++++++-----
5 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 3fd6a8a..4ac1fa2 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.106 -
====================================
+ Add 'lvm dumpconfig --type diff' to show differences from defaults.
Fix swap signature detection for devices smaller then 2MB.
Reindent some clvmd.c code.
Use dm_malloc function in clvmd.c.
diff --git a/lib/config/config.c b/lib/config/config.c
index 46e0cc1..161241e 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -1283,6 +1283,10 @@ static int _out_prefix_fn(const struct dm_config_node *cn, const char *line, voi
return 0;
}
+ if ((out->tree_spec->type == CFG_DEF_TREE_DIFF) &&
+ (!(out->tree_spec->check_status[cn->id] & CFG_DIFF)))
+ return 1;
+
cfg_def = cfg_def_get_item_p(cn->id);
if (out->tree_spec->withcomments) {
@@ -1324,7 +1328,12 @@ static int _out_line_fn(const struct dm_config_node *cn, const char *line, void
struct out_baton *out = baton;
struct cfg_def_item *cfg_def = cfg_def_get_item_p(cn->id);
+ if ((out->tree_spec->type == CFG_DEF_TREE_DIFF) &&
+ (!(out->tree_spec->check_status[cn->id] & CFG_DIFF)))
+ return 1;
+
fprintf(out->fp, "%s%s\n", (out->tree_spec->type != CFG_DEF_TREE_CURRENT) &&
+ (out->tree_spec->type != CFG_DEF_TREE_DIFF) &&
(cfg_def->flags & CFG_DEFAULT_UNDEFINED) ? "#" : "", line);
return 1;
}
diff --git a/lib/config/config.h b/lib/config/config.h
index 5d67e85..a61d285 100644
--- a/lib/config/config.h
+++ b/lib/config/config.h
@@ -121,7 +121,8 @@ typedef enum {
CFG_DEF_TREE_COMPLETE, /* CURRENT + MISSING, the tree actually used within execution, not implemented yet */
CFG_DEF_TREE_DEFAULT, /* tree of all possible config nodes with default values */
CFG_DEF_TREE_NEW, /* tree of all new nodes that appeared in given version */
- CFG_DEF_TREE_PROFILABLE /* tree of all nodes that are customizable by profiles */
+ CFG_DEF_TREE_PROFILABLE, /* tree of all nodes that are customizable by profiles */
+ CFG_DEF_TREE_DIFF, /* tree of all nodes that differ from defaults */
} cfg_def_tree_t;
/* configuration definition tree specification */
diff --git a/tools/commands.h b/tools/commands.h
index b0d608b..c047cb9 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -57,7 +57,7 @@ xx(dumpconfig,
PERMITTED_READ_ONLY,
"dumpconfig\n"
"\t[-f|--file filename] \n"
- "\t[--type {current|default|missing|new|profilable} \n"
+ "\t[--type {current|default|diff|missing|new|profilable} \n"
"\t[--atversion version]] \n"
"\t[--ignoreadvanced] \n"
"\t[--ignoreunsupported] \n"
diff --git a/tools/dumpconfig.c b/tools/dumpconfig.c
index 7404462..97863be 100644
--- a/tools/dumpconfig.c
+++ b/tools/dumpconfig.c
@@ -56,18 +56,23 @@ static struct cft_check_handle *_get_cft_check_handle(struct cmd_context *cmd, s
return handle;
}
-static int _do_def_check(struct cmd_context *cmd, struct dm_config_tree *cft,
+static int _do_def_check(struct config_def_tree_spec *spec,
+ struct dm_config_tree *cft,
struct cft_check_handle **cft_check_handle)
{
struct cft_check_handle *handle;
- if (!(handle = _get_cft_check_handle(cmd, cft)))
+ if (!(handle = _get_cft_check_handle(spec->cmd, cft)))
return 0;
handle->force_check = 1;
- handle->skip_if_checked = 1;
handle->suppress_messages = 1;
+ if (spec->type == CFG_DEF_TREE_DIFF)
+ handle->check_diff = 1;
+ else
+ handle->skip_if_checked = 1;
+
config_def_check(handle);
*cft_check_handle = handle;
@@ -168,14 +173,14 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
if (!strcmp(type, "current")) {
tree_spec.type = CFG_DEF_TREE_CURRENT;
- if (!_do_def_check(cmd, cft, &cft_check_handle)) {
+ if (!_do_def_check(&tree_spec, cft, &cft_check_handle)) {
r = ECMD_FAILED;
goto_out;
}
}
else if (!strcmp(type, "missing")) {
tree_spec.type = CFG_DEF_TREE_MISSING;
- if (!_do_def_check(cmd, cft, &cft_check_handle)) {
+ if (!_do_def_check(&tree_spec, cft, &cft_check_handle)) {
r = ECMD_FAILED;
goto_out;
}
@@ -184,6 +189,13 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
tree_spec.type = CFG_DEF_TREE_DEFAULT;
/* default type does not require check status */
}
+ else if (!strcmp(type, "diff")) {
+ tree_spec.type = CFG_DEF_TREE_DIFF;
+ if (!_do_def_check(&tree_spec, cft, &cft_check_handle)) {
+ r = ECMD_FAILED;
+ goto_out;
+ }
+ }
else if (!strcmp(type, "new")) {
tree_spec.type = CFG_DEF_TREE_NEW;
/* new type does not require check status */
@@ -209,6 +221,7 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
tree_spec.check_status = cft_check_handle->status;
if ((tree_spec.type != CFG_DEF_TREE_CURRENT) &&
+ (tree_spec.type != CFG_DEF_TREE_DIFF) &&
!(cft = config_def_create_tree(&tree_spec))) {
r = ECMD_FAILED;
goto_out;
9 years, 2 months
master - config: add support for comparing used config values with default ones
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=76ff38fa5cdec3...
Commit: 76ff38fa5cdec332750452c2ed209d4beac261eb
Parent: 630e0af14e65a860ee941adb2422628bec5ec95c
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Mar 21 10:43:44 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Mar 24 15:35:47 2014 +0100
config: add support for comparing used config values with default ones
---
lib/config/config.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++--
lib/config/config.h | 3 ++
2 files changed, 87 insertions(+), 4 deletions(-)
diff --git a/lib/config/config.c b/lib/config/config.c
index 425d3c6..46e0cc1 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -30,6 +30,8 @@
#include <fcntl.h>
#include <assert.h>
#include <ctype.h>
+#include <math.h>
+#include <float.h>
static const char *_config_source_names[] = {
[CONFIG_UNDEFINED] = "undefined",
@@ -681,10 +683,84 @@ static int _config_def_check_node_single_value(struct cft_check_handle *handle,
return 1;
}
+static int _check_value_differs_from_default(struct cft_check_handle *handle,
+ const struct dm_config_value *v,
+ const cfg_def_item_t *def,
+ struct dm_config_value *v_def)
+{
+ struct dm_config_value *v_def_array, *v_def_iter;
+ int diff = 0, id;
+ int64_t i;
+ float f;
+ const char *str;
+
+ /* if default value is undefined, the value used differs from default */
+ if (def->flags & CFG_DEFAULT_UNDEFINED) {
+ diff = 1;
+ goto out;
+ }
+
+ if (!v_def && (def->type & CFG_TYPE_ARRAY)) {
+ if (!(v_def_array = v_def_iter = _get_def_array_values(handle->cft, def)))
+ return_0;
+ do {
+ /* iterate over each element of the array and check its value */
+ if ((v->type != v_def_iter->type) ||
+ _check_value_differs_from_default(handle, v, def, v_def_iter))
+ break;
+ v_def_iter = v_def_iter->next;
+ v = v->next;
+ } while (v_def_iter && v);
+ diff = v || v_def_iter;
+ dm_pool_free(handle->cft->mem, v_def_array);
+ } else {
+ switch (v->type) {
+ case DM_CFG_INT:
+ /* int value can be a real int but it can also represent bool */
+ i = v_def ? v_def->v.i
+ : def->type & CFG_TYPE_BOOL ?
+ cfg_def_get_default_value(handle->cmd, def, CFG_TYPE_BOOL, NULL) :
+ cfg_def_get_default_value(handle->cmd, def, CFG_TYPE_INT, NULL);
+ diff = i != v->v.i;
+ break;
+ case DM_CFG_FLOAT:
+ f = v_def ? v_def->v.f
+ : cfg_def_get_default_value(handle->cmd, def, CFG_TYPE_FLOAT, NULL);
+ diff = fabs(f - v->v.f) < FLT_EPSILON;
+ break;
+ case DM_CFG_STRING:
+ /* string value can be a real string but it can also represent bool */
+ if (v_def ? v_def->type == DM_CFG_INT : def->type == CFG_TYPE_BOOL) {
+ i = v_def ? v_def->v.i
+ : cfg_def_get_default_value(handle->cmd, def, CFG_TYPE_BOOL, NULL);
+ diff = i != v->v.i;
+ } else {
+ str = v_def ? v_def->v.str
+ : cfg_def_get_default_value(handle->cmd, def, CFG_TYPE_STRING, NULL);
+ diff = strcmp(str, v->v.str);
+ }
+ break;
+ default:
+ log_error(INTERNAL_ERROR "inconsistent state reached in _check_value_differs_from_default");
+ return 0;
+ }
+ }
+out:
+ if (diff) {
+ /* mark whole path from bottom to top with CFG_DIFF */
+ for (id = def->id; id && !(handle->status[id] & CFG_DIFF); id = _cfg_def_items[id].parent)
+ handle->status[id] |= CFG_DIFF;
+ }
+
+ return diff;
+}
+
static int _config_def_check_node_value(struct cft_check_handle *handle,
const char *rp, const struct dm_config_value *v,
const cfg_def_item_t *def)
{
+ const struct dm_config_value *v_iter;
+
if (!v) {
if (def->type != CFG_TYPE_SECTION) {
_log_type_error(rp, CFG_TYPE_SECTION, def->type, handle->suppress_messages);
@@ -700,11 +776,15 @@ static int _config_def_check_node_value(struct cft_check_handle *handle,
}
}
+ v_iter = v;
do {
- if (!_config_def_check_node_single_value(handle, rp, v, def))
+ if (!_config_def_check_node_single_value(handle, rp, v_iter, def))
return 0;
- v = v->next;
- } while (v);
+ v_iter = v_iter->next;
+ } while (v_iter);
+
+ if (handle->check_diff)
+ _check_value_differs_from_default(handle, v, def, NULL);
return 1;
}
@@ -819,7 +899,7 @@ int config_def_check(struct cft_check_handle *handle)
/* Clear 'used' and 'valid' status flags. */
for (id = 0; id < CFG_COUNT; id++)
- handle->status[id] &= ~(CFG_USED | CFG_VALID);
+ handle->status[id] &= ~(CFG_USED | CFG_VALID | CFG_DIFF);
/*
* Create a hash of all possible configuration
diff --git a/lib/config/config.h b/lib/config/config.h
index e5bcab8..5d67e85 100644
--- a/lib/config/config.h
+++ b/lib/config/config.h
@@ -141,6 +141,8 @@ struct config_def_tree_spec {
#define CFG_USED 0x01
/* flag to mark the item as valid in a config tree instance during validation */
#define CFG_VALID 0x02
+/* flag to mark the item as having the value different from default one */
+#define CFG_DIFF 0x04
/*
* Register ID for each possible item in the configuration tree.
@@ -171,6 +173,7 @@ struct cft_check_handle {
unsigned force_check:1; /* force check even if disabled by config/checks setting */
unsigned skip_if_checked:1; /* skip the check if already done before - return last state */
unsigned suppress_messages:1; /* suppress messages during the check if config item is found invalid */
+ unsigned check_diff:1; /* check if the value used differs from default one */
uint8_t status[CFG_COUNT]; /* flags for each configuration item - the result of the check */
};
9 years, 2 months
master - cleanup: move _get_def_array_values fn
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=630e0af14e65a8...
Commit: 630e0af14e65a860ee941adb2422628bec5ec95c
Parent: c595b20e56f21505e8380c9b00801639143ee945
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Mar 24 13:21:41 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Mar 24 15:20:19 2014 +0100
cleanup: move _get_def_array_values fn
So we can use reuse it for the code that will follow...
---
lib/config/config.c | 182 +++++++++++++++++++++++++-------------------------
1 files changed, 91 insertions(+), 91 deletions(-)
diff --git a/lib/config/config.c b/lib/config/config.c
index ba1e280..425d3c6 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -537,6 +537,97 @@ static void _log_type_error(const char *path, cfg_def_type_t actual,
actual_type_name, expected_type_name);
}
+static struct dm_config_value *_get_def_array_values(struct dm_config_tree *cft,
+ const cfg_def_item_t *def)
+{
+ char *enc_value, *token, *p, *r;
+ struct dm_config_value *array = NULL, *v = NULL, *oldv = NULL;
+
+ if (!def->default_value.v_CFG_TYPE_STRING) {
+ if (!(array = dm_config_create_value(cft))) {
+ log_error("Failed to create default empty array for %s.", def->name);
+ return NULL;
+ }
+ array->type = DM_CFG_EMPTY_ARRAY;
+ return array;
+ }
+
+ if (!(p = token = enc_value = dm_strdup(def->default_value.v_CFG_TYPE_STRING))) {
+ log_error("_get_def_array_values: dm_strdup failed");
+ return NULL;
+ }
+ /* Proper value always starts with '#'. */
+ if (token[0] != '#')
+ goto bad;
+
+ while (token) {
+ /* Move to type identifier. Error on no char. */
+ token++;
+ if (!token[0])
+ goto bad;
+
+ /* Move to the actual value and decode any "##" into "#". */
+ p = token + 1;
+ while ((p = strchr(p, '#')) && p[1] == '#') {
+ memmove(p, p + 1, strlen(p));
+ p++;
+ }
+ /* Separate the value out of the whole string. */
+ if (p)
+ p[0] = '\0';
+
+ if (!(v = dm_config_create_value(cft))) {
+ log_error("Failed to create default config array value for %s.", def->name);
+ dm_free(enc_value);
+ return NULL;
+ }
+ if (oldv)
+ oldv->next = v;
+ if (!array)
+ array = v;
+
+ switch (toupper(token[0])) {
+ case 'I':
+ case 'B':
+ v->v.i = strtoll(token + 1, &r, 10);
+ if (*r)
+ goto bad;
+ v->type = DM_CFG_INT;
+ break;
+ case 'F':
+ v->v.f = strtod(token + 1, &r);
+ if (*r)
+ goto bad;
+ v->type = DM_CFG_FLOAT;
+ break;
+ case 'S':
+ if (!(r = dm_pool_strdup(cft->mem, token + 1))) {
+ dm_free(enc_value);
+ log_error("Failed to duplicate token for default "
+ "array value of %s.", def->name);
+ return NULL;
+ }
+ v->v.str = r;
+ v->type = DM_CFG_STRING;
+ break;
+ default:
+ goto bad;
+ }
+
+ oldv = v;
+ token = p;
+ }
+
+ dm_free(enc_value);
+ return array;
+bad:
+ log_error(INTERNAL_ERROR "Default array value malformed for \"%s\", "
+ "value: \"%s\", token: \"%s\".", def->name,
+ def->default_value.v_CFG_TYPE_STRING, token);
+ dm_free(enc_value);
+ return NULL;
+}
+
static int _config_def_check_node_single_value(struct cft_check_handle *handle,
const char *rp, const struct dm_config_value *v,
const cfg_def_item_t *def)
@@ -1214,97 +1305,6 @@ int config_write(struct dm_config_tree *cft,
return r;
}
-static struct dm_config_value *_get_def_array_values(struct dm_config_tree *cft,
- cfg_def_item_t *def)
-{
- char *enc_value, *token, *p, *r;
- struct dm_config_value *array = NULL, *v = NULL, *oldv = NULL;
-
- if (!def->default_value.v_CFG_TYPE_STRING) {
- if (!(array = dm_config_create_value(cft))) {
- log_error("Failed to create default empty array for %s.", def->name);
- return NULL;
- }
- array->type = DM_CFG_EMPTY_ARRAY;
- return array;
- }
-
- if (!(p = token = enc_value = dm_strdup(def->default_value.v_CFG_TYPE_STRING))) {
- log_error("_get_def_array_values: dm_strdup failed");
- return NULL;
- }
- /* Proper value always starts with '#'. */
- if (token[0] != '#')
- goto bad;
-
- while (token) {
- /* Move to type identifier. Error on no char. */
- token++;
- if (!token[0])
- goto bad;
-
- /* Move to the actual value and decode any "##" into "#". */
- p = token + 1;
- while ((p = strchr(p, '#')) && p[1] == '#') {
- memmove(p, p + 1, strlen(p));
- p++;
- }
- /* Separate the value out of the whole string. */
- if (p)
- p[0] = '\0';
-
- if (!(v = dm_config_create_value(cft))) {
- log_error("Failed to create default config array value for %s.", def->name);
- dm_free(enc_value);
- return NULL;
- }
- if (oldv)
- oldv->next = v;
- if (!array)
- array = v;
-
- switch (toupper(token[0])) {
- case 'I':
- case 'B':
- v->v.i = strtoll(token + 1, &r, 10);
- if (*r)
- goto bad;
- v->type = DM_CFG_INT;
- break;
- case 'F':
- v->v.f = strtod(token + 1, &r);
- if (*r)
- goto bad;
- v->type = DM_CFG_FLOAT;
- break;
- case 'S':
- if (!(r = dm_pool_strdup(cft->mem, token + 1))) {
- dm_free(enc_value);
- log_error("Failed to duplicate token for default "
- "array value of %s.", def->name);
- return NULL;
- }
- v->v.str = r;
- v->type = DM_CFG_STRING;
- break;
- default:
- goto bad;
- }
-
- oldv = v;
- token = p;
- }
-
- dm_free(enc_value);
- return array;
-bad:
- log_error(INTERNAL_ERROR "Default array value malformed for \"%s\", "
- "value: \"%s\", token: \"%s\".", def->name,
- def->default_value.v_CFG_TYPE_STRING, token);
- dm_free(enc_value);
- return NULL;
-}
-
static struct dm_config_node *_add_def_node(struct dm_config_tree *cft,
struct config_def_tree_spec *spec,
struct dm_config_node *parent,
9 years, 2 months
master - dev-swap: use SECTOR_SHIFT
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c595b20e56f215...
Commit: c595b20e56f21505e8380c9b00801639143ee945
Parent: 936bfeb8de3cbaa756a75bfe453a99efe8aa3006
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Mar 22 20:43:05 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Mar 22 20:43:05 2014 +0100
dev-swap: use SECTOR_SHIFT
---
lib/device/dev-swap.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/device/dev-swap.c b/lib/device/dev-swap.c
index bf3604b..d1feb0c 100644
--- a/lib/device/dev-swap.c
+++ b/lib/device/dev-swap.c
@@ -59,7 +59,7 @@ int dev_is_swap(struct device *dev, uint64_t *offset_found)
*/
if (page == 0x8000)
continue;
- if (size < (page / 512))
+ if (size < (page >> SECTOR_SHIFT))
break;
if (!dev_read(dev, page - SIGNATURE_SIZE,
SIGNATURE_SIZE, buf)) {
9 years, 2 months
master - dev-swap: detect swap signature on devices smaller then 2MB
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=936bfeb8de3cba...
Commit: 936bfeb8de3cbaa756a75bfe453a99efe8aa3006
Parent: 93d77455eaa06c111954bc29c052fdaf4f31464e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Mar 22 20:36:14 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Mar 22 20:36:14 2014 +0100
dev-swap: detect swap signature on devices smaller then 2MB
Smallest supported size for swap device is 40KB, however current
test skipped devices smaller then 4096 sectors (2MB).
Since page is in bytes, convert it to sectors before comparing
with device size (in sectors).
---
WHATS_NEW | 1 +
lib/device/dev-swap.c | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index bdfe111..3fd6a8a 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.106 -
====================================
+ Fix swap signature detection for devices smaller then 2MB.
Reindent some clvmd.c code.
Use dm_malloc function in clvmd.c.
Resolve memory release order for clvmd shutdown.
diff --git a/lib/device/dev-swap.c b/lib/device/dev-swap.c
index f506eda..bf3604b 100644
--- a/lib/device/dev-swap.c
+++ b/lib/device/dev-swap.c
@@ -59,7 +59,7 @@ int dev_is_swap(struct device *dev, uint64_t *offset_found)
*/
if (page == 0x8000)
continue;
- if (size < page)
+ if (size < (page / 512))
break;
if (!dev_read(dev, page - SIGNATURE_SIZE,
SIGNATURE_SIZE, buf)) {
9 years, 2 months