master - filters: refresh filters when lvmetad use is toggled
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a5f01dad224929...
Commit: a5f01dad224929ea39fd3a53753b8341028017b8
Parent: c2981cf921c5808b6e9b21d72a988e9b22f2d4a7
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Sep 30 16:08:05 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Sep 30 16:08:05 2014 +0200
filters: refresh filters when lvmetad use is toggled
We need to use proper filter chain when we disable lvmetad use
explicitly in the code by calling lvmetad_set_active(0) while
overriding existing configuration. We need to reinitialize filters
in this case so proper filter chain is used. The same applies
for the other way round - when we enable lvmetad use explicitly in
the code (though this is not yet used).
---
lib/cache/lvmetad.c | 4 +++-
lib/cache/lvmetad.h | 4 ++--
lib/commands/toolcontext.c | 14 ++++++++------
tools/lvchange.c | 2 +-
tools/lvmcmdline.c | 2 +-
tools/vgchange.c | 2 +-
tools/vgck.c | 2 +-
7 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index 5589cfd..5612c1b 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -98,11 +98,13 @@ int lvmetad_active(void)
return _lvmetad_connected;
}
-void lvmetad_set_active(int active)
+void lvmetad_set_active(struct cmd_context *cmd, int active)
{
_lvmetad_use = active;
if (!active && lvmetad_active())
lvmetad_disconnect();
+ if (cmd && !refresh_filters(cmd))
+ stack;
}
/*
diff --git a/lib/cache/lvmetad.h b/lib/cache/lvmetad.h
index d9aa77f..2cd738e 100644
--- a/lib/cache/lvmetad.h
+++ b/lib/cache/lvmetad.h
@@ -37,7 +37,7 @@ void lvmetad_init(struct cmd_context *);
/*
* Override the use of lvmetad for retrieving scan results and metadata.
*/
-void lvmetad_set_active(int);
+void lvmetad_set_active(struct cmd_context *, int);
/*
* Configure the socket that lvmetad_init will use to connect to the daemon.
@@ -161,7 +161,7 @@ int lvmetad_pvscan_all_devs(struct cmd_context *cmd, activation_handler handler)
# define lvmetad_init(cmd) do { } while (0)
# define lvmetad_disconnect() do { } while (0)
-# define lvmetad_set_active(a) do { } while (0)
+# define lvmetad_set_active(cmd, a) do { } while (0)
# define lvmetad_set_socket(a) do { } while (0)
# define lvmetad_used() (0)
# define lvmetad_socket_present() (0)
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 7c77e54..e72691d 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -463,9 +463,9 @@ static int _process_config(struct cmd_context *cmd)
find_config_tree_bool(cmd, global_use_lvmetad_CFG, NULL)) {
log_warn("WARNING: configuration setting use_lvmetad overridden to 0 due to locking_type 3. "
"Clustered environment not supported by lvmetad yet.");
- lvmetad_set_active(0);
+ lvmetad_set_active(NULL, 0);
} else
- lvmetad_set_active(find_config_tree_bool(cmd, global_use_lvmetad_CFG, NULL));
+ lvmetad_set_active(NULL, find_config_tree_bool(cmd, global_use_lvmetad_CFG, NULL));
lvmetad_init(cmd);
@@ -972,8 +972,10 @@ static int _init_filters(struct cmd_context *cmd, unsigned load_persistent_cache
log_verbose("Failed to create usable device filter.");
goto bad;
}
- } else
+ } else {
filter_components[0] = cmd->lvmetad_filter;
+ cmd->lvmetad_filter = NULL;
+ }
/* filter component 1 */
if ((cn = find_config_tree_node(cmd, devices_filter_CFG, NULL))) {
@@ -1036,7 +1038,7 @@ bad:
}
/* if lvmetad is used, the cmd->lvmetad_filter is separate */
- if (lvmetad_used() && cmd->lvmetad_filter)
+ if (cmd->lvmetad_filter)
cmd->lvmetad_filter->destroy(cmd->lvmetad_filter);
return 0;
@@ -1659,7 +1661,7 @@ static void _destroy_filters(struct cmd_context *cmd)
* is actually a part of cmd->filter and as such, it
* will be destroyed together with cmd->filter.
*/
- if (lvmetad_used() && cmd->lvmetad_filter) {
+ if (cmd->lvmetad_filter) {
cmd->lvmetad_filter->destroy(cmd->lvmetad_filter);
cmd->lvmetad_filter = NULL;
}
@@ -1826,7 +1828,7 @@ void destroy_toolcontext(struct cmd_context *cmd)
* is actually a part of cmd->filter and as such, it
* will be destroyed together with cmd->filter.
*/
- if (lvmetad_used() && cmd->lvmetad_filter)
+ if (cmd->lvmetad_filter)
cmd->lvmetad_filter->destroy(cmd->lvmetad_filter);
if (cmd->filter)
cmd->filter->destroy(cmd->filter);
diff --git a/tools/lvchange.c b/tools/lvchange.c
index fb3df50..3a0e848 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -1131,7 +1131,7 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
* direct activation instead of autoactivation.
*/
log_warn("lvmetad is not active yet, using direct activation during sysinit");
- lvmetad_set_active(0);
+ lvmetad_set_active(cmd, 0);
} else if (lvmetad_active()) {
/*
* If lvmetad is active already, we want
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index bb496d0..4697b24 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1342,7 +1342,7 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
if (arg_count(cmd, readonly_ARG)) {
locking_type = 5;
if (lvmetad_used()) {
- lvmetad_set_active(0);
+ lvmetad_set_active(cmd, 0);
log_verbose("Disabling use of lvmetad because read-only is set.");
}
} else if (arg_count(cmd, nolocking_ARG))
diff --git a/tools/vgchange.c b/tools/vgchange.c
index dfb1251..9a9fe48 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -689,7 +689,7 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
* direct activation instead of autoactivation.
*/
log_warn("lvmetad is not active yet, using direct activation during sysinit");
- lvmetad_set_active(0);
+ lvmetad_set_active(cmd, 0);
} else if (lvmetad_active()) {
/*
* If lvmetad is active already, we want
diff --git a/tools/vgck.c b/tools/vgck.c
index 4ad045a..b9d05ae 100644
--- a/tools/vgck.c
+++ b/tools/vgck.c
@@ -37,7 +37,7 @@ static int vgck_single(struct cmd_context *cmd __attribute__((unused)),
int vgck(struct cmd_context *cmd, int argc, char **argv)
{
- lvmetad_set_active(0);
+ lvmetad_set_active(cmd, 0);
return process_each_vg(cmd, argc, argv, 0, NULL,
&vgck_single);
}
9 years
master - filters: use usable device filter and separate lvmetad filter chain so it's not reevaluated for any lvmetad response
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c2981cf921c580...
Commit: c2981cf921c5808b6e9b21d72a988e9b22f2d4a7
Parent: 8a843d0d97c66aae1872c05b0f6cf4bda176aae2
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Sep 23 12:50:09 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Sep 30 13:22:11 2014 +0200
filters: use usable device filter and separate lvmetad filter chain so it's not reevaluated for any lvmetad response
With this change, the filter chains used look like this now:
A) When *lvmetad is not used*:
- persistent filter -> regex filter -> sysfs filter ->
global regex filter -> type filter ->
usable device filter(FILTER_MODE_NO_LVMETAD) ->
mpath component filter -> partitioned filter ->
md component filter
B) When *lvmetad is used* (two separate filter chains):
- the lvmetad filter chain used when scanning devs for lvmetad update:
sysfs filter -> global regex filter -> type filter ->
usable device filter(FILTER_MODE_PRE_LVMETAD) ->
mpath component filter -> partitioned filter ->
md component filter
- the filter chain used for lvmetad responses:
persistent filter -> usable device filter(FILTER_MODE_POST_LVMETAD) ->
regex filter
---
lib/cache/lvmetad.c | 6 +--
lib/commands/toolcontext.c | 141 ++++++++++++++++++++++++++++++++-------
lib/filters/filter-persistent.c | 9 ---
3 files changed, 117 insertions(+), 39 deletions(-)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index ef1d01a..5589cfd 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -293,11 +293,7 @@ static struct lvmcache_info *_pv_populate_lvmcache(struct cmd_context *cmd,
dev = dev_cache_get_by_devt(fallback, cmd->filter);
if (!dev) {
- dev = dev_cache_get_by_devt(devt, cmd->lvmetad_filter);
- if (!dev)
- log_error("No device found for PV %s.", pvid_txt);
- else
- log_warn("WARNING: Device %s for PV %s rejected by a filter.", dev_name(dev), pvid_txt);
+ log_warn("WARNING: Device for PV %s not found or rejected by a filter.", pvid_txt);
return NULL;
}
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index c3afae4..7c77e54 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -835,9 +835,9 @@ static int _init_dev_cache(struct cmd_context *cmd)
return 1;
}
-#define MAX_FILTERS 6
+#define MAX_FILTERS 7
-static struct dev_filter *_init_filter_components(struct cmd_context *cmd)
+static struct dev_filter *_init_lvmetad_filter_chain(struct cmd_context *cmd)
{
int nr_filt = 0;
const struct dm_config_node *cn;
@@ -876,6 +876,15 @@ static struct dev_filter *_init_filter_components(struct cmd_context *cmd)
}
nr_filt++;
+ /* usable device filter. Required. */
+ if (!(filters[nr_filt] = usable_filter_create(cmd->dev_types,
+ lvmetad_used() ? FILTER_MODE_PRE_LVMETAD
+ : FILTER_MODE_NO_LVMETAD))) {
+ log_error("Failed to create usabled device filter");
+ goto bad;
+ }
+ nr_filt++;
+
/* mpath component filter. Optional, non-critical. */
if (find_config_tree_bool(cmd, devices_multipath_component_detection_CFG, NULL)) {
if ((filters[nr_filt] = mpath_filter_create(cmd->dev_types)))
@@ -908,39 +917,85 @@ bad:
return NULL;
}
+/*
+ * The way the filtering is initialized depends on whether lvmetad is uesd or not.
+ *
+ * If lvmetad is used, there are two filter chains:
+ *
+ * - the lvmetad filter chain used when scanning devs for lvmetad update:
+ * sysfs filter -> global regex filter -> type filter ->
+ * usable device filter(FILTER_MODE_PRE_LVMETAD) ->
+ * mpath component filter -> partitioned filter ->
+ * md component filter
+ *
+ * - the filter chain used for lvmetad responses:
+ * persistent filter -> usable device filter(FILTER_MODE_POST_LVMETAD) ->
+ * regex filter
+ *
+ *
+ * If lvmetad isnot used, there's just one filter chain:
+ *
+ * - persistent filter -> regex filter -> sysfs filter ->
+ * global regex filter -> type filter ->
+ * usable device filter(FILTER_MODE_NO_LVMETAD) ->
+ * mpath component filter -> partitioned filter ->
+ * md component filter
+ *
+ */
static int _init_filters(struct cmd_context *cmd, unsigned load_persistent_cache)
{
const char *dev_cache;
- struct dev_filter *f3 = NULL, *f4 = NULL, *toplevel_components[2] = { 0 };
+ struct dev_filter *filter = NULL, *filter_components[2] = {0};
struct stat st;
const struct dm_config_node *cn;
cmd->dump_filter = 0;
- if (!(cmd->lvmetad_filter = _init_filter_components(cmd)))
+ cmd->lvmetad_filter = _init_lvmetad_filter_chain(cmd);
+ if (!cmd->lvmetad_filter)
goto_bad;
init_ignore_suspended_devices(find_config_tree_bool(cmd, devices_ignore_suspended_devices_CFG, NULL));
init_ignore_lvm_mirrors(find_config_tree_bool(cmd, devices_ignore_lvm_mirrors_CFG, NULL));
+ /*
+ * If lvmetad is used, there's a separation between pre-lvmetad filter chain
+ * ("cmd->lvmetad_filter") applied only if scanning for lvmetad update and
+ * post-lvmetad filter chain ("filter") applied on each lvmetad response.
+ * However, if lvmetad is not used, these two chains are not separated
+ * and we use exactly one filter chain during device scanning ("filter"
+ * that includes also "cmd->lvmetad_filter" chain).
+ */
+ /* filter component 0 */
+ if (lvmetad_used()) {
+ if (!(filter_components[0] = usable_filter_create(cmd->dev_types, FILTER_MODE_POST_LVMETAD))) {
+ log_verbose("Failed to create usable device filter.");
+ goto bad;
+ }
+ } else
+ filter_components[0] = cmd->lvmetad_filter;
+
+ /* filter component 1 */
if ((cn = find_config_tree_node(cmd, devices_filter_CFG, NULL))) {
- if (!(f3 = regex_filter_create(cn->v)))
+ if (!(filter_components[1] = regex_filter_create(cn->v)))
goto_bad;
- toplevel_components[0] = cmd->lvmetad_filter;
- toplevel_components[1] = f3;
- if (!(f4 = composite_filter_create(2, toplevel_components)))
+ /* we have two filter components - create composite filter */
+ if (!(filter = composite_filter_create(2, filter_components)))
goto_bad;
} else
- f4 = cmd->lvmetad_filter;
+ /* we have only one filter component - no need to create composite filter */
+ filter = filter_components[0];
if (!(dev_cache = find_config_tree_str(cmd, devices_cache_CFG, NULL)))
goto_bad;
- if (!(cmd->filter = persistent_filter_create(cmd->dev_types, f4, dev_cache))) {
+ if (!(filter = persistent_filter_create(cmd->dev_types, filter, dev_cache))) {
log_verbose("Failed to create persistent device filter.");
goto bad;
}
+ cmd->filter = filter;
+
/* Should we ever dump persistent filter state? */
if (find_config_tree_bool(cmd, devices_write_cache_state_CFG, NULL))
cmd->dump_filter = 1;
@@ -963,14 +1018,27 @@ static int _init_filters(struct cmd_context *cmd, unsigned load_persistent_cache
return 1;
bad:
- if (f4) /* kills both f3 and cmd->lvmetad_filter */
- f4->destroy(f4);
- else {
- if (f3)
- f3->destroy(f3);
- if (cmd->lvmetad_filter)
- cmd->lvmetad_filter->destroy(cmd->lvmetad_filter);
+ if (!filter) {
+ /*
+ * composite filter not created - destroy
+ * each component directly
+ */
+ if (filter_components[0])
+ filter_components[0]->destroy(filter_components[0]);
+ if (filter_components[1])
+ filter_components[1]->destroy(filter_components[1]);
+ } else {
+ /*
+ * composite filter created - destroy it - this
+ * will also destroy any of its components
+ */
+ filter->destroy(filter);
}
+
+ /* if lvmetad is used, the cmd->lvmetad_filter is separate */
+ if (lvmetad_used() && cmd->lvmetad_filter)
+ cmd->lvmetad_filter->destroy(cmd->lvmetad_filter);
+
return 0;
}
@@ -1581,17 +1649,31 @@ static void _destroy_dev_types(struct cmd_context *cmd)
cmd->dev_types = NULL;
}
-int refresh_filters(struct cmd_context *cmd)
+static void _destroy_filters(struct cmd_context *cmd)
{
- int r, saved_ignore_suspended_devices = ignore_suspended_devices();
-
+ /*
+ * If lvmetad is used, the cmd->lvmetad_filter is
+ * a separate filter chain than cmd->filter so
+ * we need to destroy it separately.
+ * Otherwise, if lvmetad is not used, cmd->lvmetad_filter
+ * is actually a part of cmd->filter and as such, it
+ * will be destroyed together with cmd->filter.
+ */
+ if (lvmetad_used() && cmd->lvmetad_filter) {
+ cmd->lvmetad_filter->destroy(cmd->lvmetad_filter);
+ cmd->lvmetad_filter = NULL;
+ }
if (cmd->filter) {
cmd->filter->destroy(cmd->filter);
cmd->filter = NULL;
}
+}
- cmd->lvmetad_filter = NULL;
+int refresh_filters(struct cmd_context *cmd)
+{
+ int r, saved_ignore_suspended_devices = ignore_suspended_devices();
+ _destroy_filters(cmd);
if (!(r = _init_filters(cmd, 0)))
stack;
@@ -1621,10 +1703,8 @@ int refresh_toolcontext(struct cmd_context *cmd)
label_exit();
_destroy_segtypes(&cmd->segtypes);
_destroy_formats(cmd, &cmd->formats);
- if (cmd->filter) {
- cmd->filter->destroy(cmd->filter);
- cmd->filter = NULL;
- }
+ _destroy_filters(cmd);
+
if (!dev_cache_exit())
stack;
_destroy_dev_types(cmd);
@@ -1737,6 +1817,17 @@ void destroy_toolcontext(struct cmd_context *cmd)
label_exit();
_destroy_segtypes(&cmd->segtypes);
_destroy_formats(cmd, &cmd->formats);
+
+ /*
+ * If lvmetad is used, the cmd->lvmetad_filter is
+ * a separate filter chain than cmd->filter so
+ * we need to destroy it separately.
+ * Otherwise, if lvmetad is not used, cmd->lvmetad_filter
+ * is actually a part of cmd->filter and as such, it
+ * will be destroyed together with cmd->filter.
+ */
+ if (lvmetad_used() && cmd->lvmetad_filter)
+ cmd->lvmetad_filter->destroy(cmd->lvmetad_filter);
if (cmd->filter)
cmd->filter->destroy(cmd->filter);
if (cmd->mem)
diff --git a/lib/filters/filter-persistent.c b/lib/filters/filter-persistent.c
index ca3ad37..600fa38 100644
--- a/lib/filters/filter-persistent.c
+++ b/lib/filters/filter-persistent.c
@@ -288,15 +288,6 @@ static int _lookup_p(struct dev_filter *f, struct device *dev)
log_error("Failed to hash device to filter.");
return 0;
}
- if (!device_is_usable(dev, (struct dev_usable_check_params)
- { .check_empty = 1,
- .check_blocked = 1,
- .check_suspended = ignore_suspended_devices(),
- .check_error_target = 1,
- .check_reserved = 1 })) {
- log_debug_devs("%s: Skipping unusable device", dev_name(dev));
- return 0;
- }
return pf->real->passes_filter(pf->real, dev);
}
9 years
master - filters: add "usable device" filter
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8a843d0d97c66a...
Commit: 8a843d0d97c66aae1872c05b0f6cf4bda176aae2
Parent: 00d8ab84923af87191110b1cb77b13a483659ef1
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Sep 23 12:49:01 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Sep 30 13:11:58 2014 +0200
filters: add "usable device" filter
Usable device filter is responsible for filtering out unusable DM devices.
The filter has 3 modes of operation:
- FILTER_MODE_NO_LVMETAD:
When this mode is used, we check DM device usability by looking:
- whether device is empty
- whether device is blocked
- whether device is suspended (only on devices/ignore_suspended_devices=1)
- whether device uses an error target
- whether device name/uuid is reserved
- FILTER_MODE_PRE_LVMETAD:
When this mode is used, we check DM device usability by looking:
- whether device is empty
- whether device is suspended (only on devices/ignore_suspended_devices=1)
- whether device uses an error target
- whether device name/uuid is reserved
- FILTER_MODE_POST_LVMETAD:
When this mode is used, we check DM device usability by looking:
- whether device is blocked
- whether device is suspended (only on devices/ignore_suspended_devices=1)
These modes will be used by subsequent patch to create different
instances of this filter, depending on lvmetad use.
---
lib/Makefile.in | 1 +
lib/filters/filter-usable.c | 89 +++++++++++++++++++++++++++++++++++++++++++
lib/filters/filter.h | 7 +++
3 files changed, 97 insertions(+), 0 deletions(-)
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 9f101f3..bad5d8c 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -72,6 +72,7 @@ SOURCES =\
filters/filter-mpath.c \
filters/filter-partitioned.c \
filters/filter-type.c \
+ filters/filter-usable.c \
format_text/archive.c \
format_text/archiver.c \
format_text/export.c \
diff --git a/lib/filters/filter-usable.c b/lib/filters/filter-usable.c
new file mode 100644
index 0000000..e91c3f3
--- /dev/null
+++ b/lib/filters/filter-usable.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2014 Red Hat, Inc. All rights reserved.
+ *
+ * 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,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "lib.h"
+#include "filter.h"
+#include "activate.h" /* device_is_usable */
+
+static int _passes_usable_filter(struct dev_filter *f, struct device *dev)
+{
+ filter_mode_t mode = *((filter_mode_t *) f->private);
+ struct dev_usable_check_params ucp;
+ int r;
+
+ /* filter only device-mapper devices */
+ if (!dm_is_dm_major(MAJOR(dev->dev)))
+ return 1;
+
+ switch (mode) {
+ case FILTER_MODE_NO_LVMETAD:
+ ucp.check_empty = 1;
+ ucp.check_blocked = 1;
+ ucp.check_suspended = ignore_suspended_devices();
+ ucp.check_error_target = 1;
+ ucp.check_reserved = 1;
+ break;
+ case FILTER_MODE_PRE_LVMETAD:
+ ucp.check_empty = 1;
+ ucp.check_blocked = 0;
+ ucp.check_suspended = ignore_suspended_devices();
+ ucp.check_error_target = 1;
+ ucp.check_reserved = 1;
+ break;
+ case FILTER_MODE_POST_LVMETAD:
+ ucp.check_empty = 0;
+ ucp.check_blocked = 1;
+ ucp.check_suspended = ignore_suspended_devices();
+ ucp.check_error_target = 0;
+ ucp.check_reserved = 0;
+ break;
+ }
+
+ if (!(r = device_is_usable(dev, ucp)))
+ log_debug_devs("%s: Skipping unusable device", dev_name(dev));
+
+ return r;
+}
+
+static void _usable_filter_destroy(struct dev_filter *f)
+{
+ if (f->use_count)
+ log_error(INTERNAL_ERROR "Destroying usable device filter while in use %u times.", f->use_count);
+
+ dm_free(f->private);
+ dm_free(f);
+}
+
+struct dev_filter *usable_filter_create(struct dev_types *dt __attribute__((unused)), filter_mode_t mode)
+{
+ struct dev_filter *f;
+
+ if (!(f = dm_zalloc(sizeof(struct dev_filter)))) {
+ log_error("Usable device filter allocation failed");
+ return NULL;
+ }
+
+ f->passes_filter = _passes_usable_filter;
+ f->destroy = _usable_filter_destroy;
+ f->use_count = 0;
+ if (!(f->private = dm_zalloc(sizeof(filter_mode_t)))) {
+ log_error("Usable device filter mode allocation failed");
+ return NULL;
+ }
+ *((filter_mode_t *) f->private) = mode;
+
+ log_debug_devs("Usable device filter initialised.");
+
+ return f;
+}
diff --git a/lib/filters/filter.h b/lib/filters/filter.h
index 219d3f7..0519439 100644
--- a/lib/filters/filter.h
+++ b/lib/filters/filter.h
@@ -40,6 +40,13 @@ struct dev_filter *sysfs_filter_create(void);
struct dev_filter *regex_filter_create(const struct dm_config_value *patterns);
+typedef enum {
+ FILTER_MODE_NO_LVMETAD,
+ FILTER_MODE_PRE_LVMETAD,
+ FILTER_MODE_POST_LVMETAD
+} filter_mode_t;
+struct dev_filter *usable_filter_create(struct dev_types *dt, filter_mode_t mode);
+
int persistent_filter_load(struct dev_filter *f, struct dm_config_tree **cft_out);
#endif /* _LVM_FILTER_H */
9 years
master - refactor: make it possible to select what to check exactly when calling device_is_usable fn
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=00d8ab84923af8...
Commit: 00d8ab84923af87191110b1cb77b13a483659ef1
Parent: fbc28cc7adb453122b83a18361809152bdee263f
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Sep 23 12:47:11 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Sep 30 13:11:58 2014 +0200
refactor: make it possible to select what to check exactly when calling device_is_usable fn
Currently, there are 5 things that device_is_usable function checks
(for DM devices only, of course):
- is device empty?
- is device blocked? (mirror)
- is device suspended?
- is device composed of an error target?
- is device name/uuid reserved?
If answer to any of these questions is "yes", then the device is not usable.
This patch just adds possibility to choose what to check for exactly - the
device_is_usable function now accepts struct dev_usable_check_params make
this selection possible. This is going to be used by subsequent patches.
---
lib/activate/activate.c | 2 +-
lib/activate/activate.h | 17 +++++++++--------
lib/activate/dev_manager.c | 35 ++++++++++++++---------------------
lib/filters/filter-persistent.c | 7 ++++++-
liblvm/lvm_base.c | 2 +-
tools/lvmcmdline.c | 2 +-
6 files changed, 32 insertions(+), 33 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 58e847e..6ba4712 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -411,7 +411,7 @@ int add_areas_line(struct dev_manager *dm, struct lv_segment *seg,
{
return 0;
}
-int device_is_usable(struct device *dev)
+int device_is_usable(struct device *dev, struct dev_usable_check_params check)
{
return 0;
}
diff --git a/lib/activate/activate.h b/lib/activate/activate.h
index 4f32bca..4c170c1 100644
--- a/lib/activate/activate.h
+++ b/lib/activate/activate.h
@@ -172,18 +172,19 @@ int add_linear_area_to_dtree(struct dm_tree_node *node, uint64_t size,
int pv_uses_vg(struct physical_volume *pv,
struct volume_group *vg);
+struct dev_usable_check_params {
+ unsigned int check_empty:1;
+ unsigned int check_blocked:1;
+ unsigned int check_suspended:1;
+ unsigned int check_error_target:1;
+ unsigned int check_reserved:1;
+};
+
/*
* Returns 1 if mapped device is not suspended, blocked or
* is using a reserved name.
*/
-int device_is_usable(struct device *dev);
-
-/*
- * Returns 1 if the device is suspended or blocking.
- * (Does not perform check on the LV name of the device.)
- * N.B. This is !device_is_usable() without the name check.
- */
-int device_is_suspended_or_blocking(struct device *dev);
+int device_is_usable(struct device *dev, struct dev_usable_check_params check);
/*
* Declaration moved here from fs.h to keep header fs.h hidden
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 0437c69..9956fd4 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -279,7 +279,12 @@ static int _ignore_blocked_mirror_devices(struct device *dev,
goto_out;
tmp_dev->dev = log_dev;
- if (device_is_suspended_or_blocking(tmp_dev))
+ if (device_is_usable(tmp_dev, (struct dev_usable_check_params)
+ { .check_empty = 1,
+ .check_blocked = 1,
+ .check_suspended = ignore_suspended_devices(),
+ .check_error_target = 1,
+ .check_reserved = 0 }))
goto_out;
}
}
@@ -334,7 +339,7 @@ out:
}
/*
- * _device_is_usable
+ * device_is_usable
* @dev
* @check_lv_names
*
@@ -345,12 +350,11 @@ out:
* a) the device is suspended
* b) it is a snapshot origin
* 4) an error target
- * And optionally, if 'check_lv_names' is set
* 5) the LV name is a reserved name.
*
* Returns: 1 if usable, 0 otherwise
*/
-static int _device_is_usable(struct device *dev, int check_lv_names)
+int device_is_usable(struct device *dev, struct dev_usable_check_params check)
{
struct dm_task *dmt;
struct dm_info info;
@@ -385,18 +389,18 @@ static int _device_is_usable(struct device *dev, int check_lv_names)
name = dm_task_get_name(dmt);
uuid = dm_task_get_uuid(dmt);
- if (!info.target_count) {
+ if (check.check_empty && !info.target_count) {
log_debug_activation("%s: Empty device %s not usable.", dev_name(dev), name);
goto out;
}
- if (info.suspended && ignore_suspended_devices()) {
+ if (check.check_suspended && info.suspended) {
log_debug_activation("%s: Suspended device %s not usable.", dev_name(dev), name);
goto out;
}
/* Check internal lvm devices */
- if (check_lv_names &&
+ if (check.check_reserved &&
uuid && !strncmp(uuid, UUID_PREFIX, sizeof(UUID_PREFIX) - 1)) {
if (strlen(uuid) > (sizeof(UUID_PREFIX) + 2 * ID_LEN)) { /* 68 */
log_debug_activation("%s: Reserved uuid %s on internal LV device %s not usable.",
@@ -421,7 +425,7 @@ static int _device_is_usable(struct device *dev, int check_lv_names)
next = dm_get_next_target(dmt, next, &start, &length,
&target_type, ¶ms);
- if (target_type && !strcmp(target_type, "mirror")) {
+ if (check.check_blocked && target_type && !strcmp(target_type, "mirror")) {
if (ignore_lvm_mirrors()) {
log_debug_activation("%s: Scanning mirror devices is disabled.", dev_name(dev));
goto out;
@@ -442,8 +446,7 @@ static int _device_is_usable(struct device *dev, int check_lv_names)
* FIXME: rather than skipping origin, check if mirror is
* underneath and if the mirror is blocking I/O.
*/
- if (target_type && !strcmp(target_type, "snapshot-origin") &&
- ignore_suspended_devices()) {
+ if (check.check_suspended && target_type && !strcmp(target_type, "snapshot-origin")) {
log_debug_activation("%s: Snapshot-origin device %s not usable.",
dev_name(dev), name);
goto out;
@@ -455,7 +458,7 @@ static int _device_is_usable(struct device *dev, int check_lv_names)
/* Skip devices consisting entirely of error targets. */
/* FIXME Deal with device stacked above error targets? */
- if (only_error_target) {
+ if (check.check_error_target && only_error_target) {
log_debug_activation("%s: Error device %s not usable.",
dev_name(dev), name);
goto out;
@@ -471,16 +474,6 @@ static int _device_is_usable(struct device *dev, int check_lv_names)
return r;
}
-int device_is_usable(struct device *dev)
-{
- return _device_is_usable(dev, 1);
-}
-
-int device_is_suspended_or_blocking(struct device *dev)
-{
- return !_device_is_usable(dev, 0);
-}
-
static int _info(const char *dlid, int with_open_count, int with_read_ahead,
struct dm_info *info, uint32_t *read_ahead)
{
diff --git a/lib/filters/filter-persistent.c b/lib/filters/filter-persistent.c
index 6d406c7..ca3ad37 100644
--- a/lib/filters/filter-persistent.c
+++ b/lib/filters/filter-persistent.c
@@ -288,7 +288,12 @@ static int _lookup_p(struct dev_filter *f, struct device *dev)
log_error("Failed to hash device to filter.");
return 0;
}
- if (!device_is_usable(dev)) {
+ if (!device_is_usable(dev, (struct dev_usable_check_params)
+ { .check_empty = 1,
+ .check_blocked = 1,
+ .check_suspended = ignore_suspended_devices(),
+ .check_error_target = 1,
+ .check_reserved = 1 })) {
log_debug_devs("%s: Skipping unusable device", dev_name(dev));
return 0;
}
diff --git a/liblvm/lvm_base.c b/liblvm/lvm_base.c
index 80d8dbb..31fc0bb 100644
--- a/liblvm/lvm_base.c
+++ b/liblvm/lvm_base.c
@@ -38,7 +38,7 @@ static lvm_t _lvm_init(const char *system_dir)
/*
* It's not necessary to use name mangling for LVM:
* - the character set used for VG-LV names is subset of udev character set
- * - when we check other devices (e.g. _device_is_usable fn), we use major:minor, not dm names
+ * - when we check other devices (e.g. device_is_usable fn), we use major:minor, not dm names
*/
dm_set_name_mangling_mode(DM_STRING_MANGLING_NONE);
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index e56a57a..bb496d0 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1588,7 +1588,7 @@ struct cmd_context *init_lvm(void)
/*
* It's not necessary to use name mangling for LVM:
* - the character set used for LV names is subset of udev character set
- * - when we check other devices (e.g. _device_is_usable fn), we use major:minor, not dm names
+ * - when we check other devices (e.g. device_is_usable fn), we use major:minor, not dm names
*/
dm_set_name_mangling_mode(DM_STRING_MANGLING_NONE);
9 years
master - conf: Update comments on lvmetad+filters in example.conf.in.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fbc28cc7adb453...
Commit: fbc28cc7adb453122b83a18361809152bdee263f
Parent: 9f3c11b39acc4252d6d40ae040319f66f9060a75
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Tue Sep 30 11:39:07 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Tue Sep 30 11:39:07 2014 +0200
conf: Update comments on lvmetad+filters in example.conf.in.
---
conf/example.conf.in | 35 ++++++++++++++++++++---------------
1 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/conf/example.conf.in b/conf/example.conf.in
index 511ca0b..dd1d066 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -678,26 +678,31 @@ global {
# If lvmetad has been running while use_lvmetad was 0, it MUST be stopped
# before changing use_lvmetad to 1 and started again afterwards.
#
- # If using lvmetad, the volume activation is also switched to automatic
+ # If using lvmetad, volume activation is also switched to automatic
# event-based mode. In this mode, the volumes are activated based on
- # incoming udev events that automatically inform lvmetad about new PVs
- # that appear in the system. Once the VG is complete (all the PVs are
- # present), it is auto-activated. The activation/auto_activation_volume_list
- # setting controls which volumes are auto-activated (all by default).
- #
+ # incoming udev events that automatically inform lvmetad about new PVs that
+ # appear in the system. Once a VG is complete (all the PVs are present), it
+ # is auto-activated. The activation/auto_activation_volume_list setting
+ # controls which volumes are auto-activated (all by default).
+
# A note about device filtering while lvmetad is used:
- # When lvmetad is updated (either automatically based on udev events
- # or directly by pvscan --cache <device> call), the devices/filter
- # is ignored and all devices are scanned by default. The lvmetad always
- # keeps unfiltered information which is then provided to LVM commands
- # and then each LVM command does the filtering based on devices/filter
- # setting itself.
- # To prevent scanning devices completely, even when using lvmetad,
- # the devices/global_filter must be used.
+
+ # When lvmetad is updated (either automatically based on udev events or
+ # directly by a pvscan --cache <device> call), devices/filter is ignored and
+ # all devices are scanned by default -- lvmetad always keeps unfiltered
+ # information which is then provided to LVM commands and then each LVM
+ # command does the filtering based on devices/filter setting itself. This
+ # does not apply to non-regexp filters though: component filters such as
+ # multipath and MD are checked at pvscan --cache time.
+
+ # In order to completely prevent LVM from scanning a device, even when using
+ # lvmetad, devices/global_filter must be used.
+
# N.B. Don't use lvmetad with locking type 3 as lvmetad is not yet
# supported in clustered environment. If use_lvmetad=1 and locking_type=3
# is set at the same time, LVM always issues a warning message about this
- # and then it automatically disables lvmetad use.
+ # and then it automatically disables use_lvmetad.
+
use_lvmetad = 0
# Full path of the utility called to check that a thin metadata device
9 years
master - man: lvmthin remove unnecessary fixme
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9f3c11b39acc42...
Commit: 9f3c11b39acc4252d6d40ae040319f66f9060a75
Parent: 9646c3359f89840dd05560d0adfab99f337d81f3
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Sep 29 12:28:00 2014 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Sep 29 12:28:00 2014 -0500
man: lvmthin remove unnecessary fixme
The existing method for single step thin-pool + thin creation
makes sense.
---
man/lvmthin.7.in | 6 ------
1 files changed, 0 insertions(+), 6 deletions(-)
diff --git a/man/lvmthin.7.in b/man/lvmthin.7.in
index 30a31d1..af9669d 100644
--- a/man/lvmthin.7.in
+++ b/man/lvmthin.7.in
@@ -1007,9 +1007,6 @@ and creates a thin LV in the new pool.
.B \-n ThinLV \-\-thinpool VG/ThinPoolLV
.RE
-./" FIXME: make this work
-./" lvcreate \-\-type thin\-pool \-V VirtualSize \-L LargeSize \-n ThinLV VG/ThinPoolLV
-
Equivalent to:
.br
.B lvcreate \-\-type thin\-pool \-L LargeSize VG/ThinPoolLV
@@ -1021,9 +1018,6 @@ Equivalent to:
.nf
# lvcreate \-L8M \-V2G \-n thin1 \-\-thinpool vg/pool0
-./" FIXME: change to
-./" lvcreate \-\-type thin\-pool \-L8M \-V2G \-n thin1 vg/pool0
-
# lvs \-a
pool0 vg twi-a-tz-- 8.00m
[pool0_tdata] vg Twi-ao---- 8.00m
9 years
master - Revert "Revert "man: lvmthin should use clearer thin pool options""
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9646c3359f8984...
Commit: 9646c3359f89840dd05560d0adfab99f337d81f3
Parent: d1be66ba3708c23a20c2062ff63b0240531caa31
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Sep 29 12:26:16 2014 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Sep 29 12:26:16 2014 -0500
Revert "Revert "man: lvmthin should use clearer thin pool options""
This reverts commit 17a1869df506a3641d49d52c413b5bc04ec2adc9.
We've agreed on the clearer syntax.
---
man/lvmthin.7.in | 50 +++++++++++++++++++++++++++++++-------------------
1 files changed, 31 insertions(+), 19 deletions(-)
diff --git a/man/lvmthin.7.in b/man/lvmthin.7.in
index 6652f7e..30a31d1 100644
--- a/man/lvmthin.7.in
+++ b/man/lvmthin.7.in
@@ -129,11 +129,11 @@ ThinMetaLV is renamed to hidden ThinPoolLV_tmeta.
The new ThinPoolLV takes the previous name of ThinDataLV.
.fi
-.B lvconvert \-\-thinpool VG/ThinDataLV \-\-poolmetadata VG/ThinMetaLV
+.B lvconvert \-\-type thin-pool \-\-poolmetadata VG/ThinMetaLV VG/ThinDataLV
.I Example
.br
-# lvconvert \-\-thinpool vg/pool0 \-\-poolmetadata vg/pool0meta
+# lvconvert \-\-type thin-pool \-\-poolmetadata vg/pool0meta vg/pool0
# lvs vg/pool0
LV VG Attr LSize Pool Origin Data% Meta%
@@ -286,14 +286,14 @@ to use fast devices for the metadata LV.
.br
.B lvcreate \-n ThinMetaLV \-L SmallSize VG SmallPV
.br
-.B lvconvert \-\-thinpool VG/ThinDataLV \-\-poolmetadata VG/ThinMetaLV
+.B lvconvert \-\-type thin\-pool \-\-poolmetadata VG/ThinMetaLV VG/ThinDataLV
.I Example
.br
.nf
# lvcreate \-n pool0 \-L 10G vg /dev/sdA
# lvcreate \-n pool0meta \-L 1G vg /dev/sdB
-# lvconvert \-\-thinpool vg/pool0 \-\-poolmetadata vg/pool0meta
+# lvconvert \-\-type thin\-pool \-\-poolmetadata vg/pool0meta vg/pool0
.fi
.BR lvm.conf (5)
@@ -314,14 +314,14 @@ pool metadata LV. This is especially recommended for pool metadata LVs.
.br
.B lvcreate \-\-type raid1 \-m 1 \-n ThinDataLV \-L LargeSize VG PVC PVD
.br
-.B lvconvert \-\-thinpool VG/ThinDataLV \-\-poolmetadata VG/ThinMetaLV
+.B lvconvert \-\-type thin\-pool \-\-poolmetadata VG/ThinMetaLV VG/ThinDataLV
.I Example
.br
.nf
# lvcreate \-\-type raid1 \-m 1 \-n pool0 \-L 10G vg /dev/sdA /dev/sdB
# lvcreate \-\-type raid1 \-m 1 \-n pool0meta \-L 1G vg /dev/sdC /dev/sdD
-# lvconvert \-\-thinpool vg/pool0 \-\-poolmetadata vg/pool0meta
+# lvconvert \-\-type thin\-pool \-\-poolmetadata vg/pool0meta vg/pool0
.fi
@@ -348,7 +348,7 @@ explicitly.
.nf
# lvcreate \-n pool0 \-L 10G vg
# lvcreate \-n pool0meta \-L 1G vg
-# lvconvert \-\-thinpool vg/pool0 \-\-poolmetadata vg/pool0meta
+# lvconvert \-\-type thin\-pool \-\-poolmetadata vg/pool0meta vg/pool0
# lvs \-a
[lvol0_pmspare] vg ewi------- 10.00g
@@ -430,13 +430,13 @@ create a metadata LV from the same VG.
.B lvcreate \-n ThinDataLV \-L LargeSize VG
.br
-.B lvconvert \-\-thinpool VG/ThinDataLV
+.B lvconvert \-\-type thin\-pool VG/ThinDataLV
.I Example
.br
.nf
# lvcreate \-n pool0 \-L 10G vg
-# lvconvert \-\-thinpool vg/pool0
+# lvconvert \-\-type thin\-pool vg/pool0
# lvs \-a
pool0 vg twi-a-tz-- 10.00g
@@ -772,10 +772,11 @@ indicated by the "z" attribute displayed by lvs. The option \-Z
Command to set the zeroing mode when creating a thin pool LV:
.br
-.B lvconvert \-Z{y|n} \-\-thinpool VG/ThinDataLV
+.B lvconvert \-\-type thin\-pool \-Z{y|n}
.br
-.B " " \-\-poolmetadata VG/ThinMetaLV
-
+.RS
+.B \-\-poolmetadata VG/ThinMetaLV VG/ThinDataLV
+.RE
Command to change the zeroing mode of an existing thin pool LV:
.br
@@ -819,7 +820,7 @@ Command to set the discard mode when creating a thin pool LV:
.B lvconvert \-\-discards {ignore|nopassdown|passdown}
.br
.RS
-.B \-\-thinpool VG/ThinDataLV \-\-poolmetadata VG/ThinMetaLV
+.B \-\-type thin\-pool \-\-poolmetadata VG/ThinMetaLV VG/ThinDataLV
.RE
Command to change the discard mode of an existing thin pool LV:
@@ -966,12 +967,16 @@ rather than using lvconvert on existing LVs.
This one command creates a thin data LV, a thin metadata LV,
and combines the two into a thin pool LV.
-.B lvcreate \-L LargeSize \-\-thinpool VG/ThinPoolLV
+.B lvcreate \-\-type thin\-pool \-L LargeSize VG/ThinPoolLV
+
+./" FIXME: make this work
+./" or using standard form of lvcreate:
+./" .B lvcreate \-\-type thin\-pool \-L LargeSize \-n ThinPoolLV VG
.I Example
.br
.nf
-# lvcreate \-L8M \-\-thinpool vg/pool0
+# lvcreate \-\-type thin\-pool \-L8M vg/pool0
# lvs vg/pool0
LV VG Attr LSize Pool Origin Data%
@@ -997,13 +1002,17 @@ and creates a thin LV in the new pool.
.br
\-V VirtualSize specifies the virtual size of the thin LV.
-.B lvcreate \-L LargeSize \-V VirtualSize \-n ThinLV
-.br
-.B " " \-\-thinpool VG/ThinPoolLV
+.B lvcreate \-V VirtualSize \-L LargeSize
+.RS
+.B \-n ThinLV \-\-thinpool VG/ThinPoolLV
+.RE
+
+./" FIXME: make this work
+./" lvcreate \-\-type thin\-pool \-V VirtualSize \-L LargeSize \-n ThinLV VG/ThinPoolLV
Equivalent to:
.br
-.B lvcreate \-L LargeSize \-\-thinpool VG/ThinPoolLV
+.B lvcreate \-\-type thin\-pool \-L LargeSize VG/ThinPoolLV
.br
.B lvcreate \-n ThinLV \-V VirtualSize \-\-thinpool VG/ThinPoolLV
@@ -1012,6 +1021,9 @@ Equivalent to:
.nf
# lvcreate \-L8M \-V2G \-n thin1 \-\-thinpool vg/pool0
+./" FIXME: change to
+./" lvcreate \-\-type thin\-pool \-L8M \-V2G \-n thin1 vg/pool0
+
# lvs \-a
pool0 vg twi-a-tz-- 8.00m
[pool0_tdata] vg Twi-ao---- 8.00m
9 years
master - valgrind: don't eat mem with valgrind
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d1be66ba3708c2...
Commit: d1be66ba3708c23a20c2062ff63b0240531caa31
Parent: f3e9ff7179303cb23ee78819a0c24fc1ccc5394f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Sep 27 16:27:34 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Sep 28 13:49:01 2014 +0200
valgrind: don't eat mem with valgrind
When compiled with valgrind pool support - don't waste time
with preallocation of memory - it just waste of CPU cycles to
trace access to this memory.
We also may get slightly better estimation about real memory usage
during command processing.
---
lib/mm/memlock.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/lib/mm/memlock.c b/lib/mm/memlock.c
index 37d9457..547fb46 100644
--- a/lib/mm/memlock.c
+++ b/lib/mm/memlock.c
@@ -132,6 +132,8 @@ static void _touch_memory(void *mem, size_t size)
static void _allocate_memory(void)
{
+#ifndef VALGRIND_POOL
+ /* With Valgrind don't waste time in with preallocating memory */
void *stack_mem, *temp_malloc_mem;
struct rlimit limit;
@@ -149,6 +151,7 @@ static void _allocate_memory(void)
_touch_memory(_malloc_mem, _size_malloc);
free(temp_malloc_mem);
+#endif
}
static void _release_memory(void)
9 years
master - cleanup: drop unused variable
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f3e9ff7179303c...
Commit: f3e9ff7179303cb23ee78819a0c24fc1ccc5394f
Parent: ad60805ffd6a2a5a52c81bc52d818098f674f44e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Sep 27 20:43:32 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Sep 28 13:49:01 2014 +0200
cleanup: drop unused variable
---
tools/lvresize.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/tools/lvresize.c b/tools/lvresize.c
index c5f01da..133cc6f 100644
--- a/tools/lvresize.c
+++ b/tools/lvresize.c
@@ -20,7 +20,6 @@ static int _lvresize_params(struct cmd_context *cmd, int argc, char **argv,
{
const char *cmd_name;
char *st;
- unsigned dev_dir_found = 0;
int use_policy = arg_count(cmd, use_policies_ARG);
lp->sign = SIGN_NONE;
@@ -106,7 +105,7 @@ static int _lvresize_params(struct cmd_context *cmd, int argc, char **argv,
argv++;
argc--;
- if (!(lp->lv_name = skip_dev_dir(cmd, lp->lv_name, &dev_dir_found)) ||
+ if (!(lp->lv_name = skip_dev_dir(cmd, lp->lv_name, NULL)) ||
!(lp->vg_name = extract_vgname(cmd, lp->lv_name))) {
log_error("Please provide a volume group name");
return 0;
9 years
master - lvconvert: switch to validate_lvname_param
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ad60805ffd6a2a...
Commit: ad60805ffd6a2a5a52c81bc52d818098f674f44e
Parent: 0d4baeba18646478e1edb7b26a9f9c74d6add1f5
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Sep 28 13:07:18 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Sep 28 13:49:01 2014 +0200
lvconvert: switch to validate_lvname_param
Use new toollib function for validation.
---
tools/lvconvert.c | 39 ++++-----------------------------------
1 files changed, 4 insertions(+), 35 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 28a3526..c05ea1b 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -72,37 +72,6 @@ struct lvconvert_params {
thin_discards_t discards;
};
-static int _lvconvert_vg_name(struct lvconvert_params *lp,
- struct cmd_context *cmd,
- const char **lv_name)
-{
- const char *vg_name;
- const char *tmp_str;
-
- if (!lv_name || !*lv_name)
- return 1;
-
- /* If contains VG name, extract it. */
- if ((tmp_str = strchr(*lv_name, (int) '/'))) {
- if (!(vg_name = extract_vgname(cmd, *lv_name)))
- return_0;
- if (!lp->vg_name)
- lp->vg_name = vg_name;
- else if (strcmp(vg_name, lp->vg_name)) {
- log_error("Please use a single volume group name "
- "(\"%s\" or \"%s\")", vg_name, lp->vg_name);
- return 0;
- }
- /* Strip VG from lv_name */
- *lv_name = tmp_str + 1;
- }
-
- if (!apply_lvname_restrictions(*lv_name))
- return_0;
-
- return 1;
-}
-
static int _lvconvert_name_params(struct lvconvert_params *lp,
struct cmd_context *cmd,
int *pargc, char ***pargv)
@@ -142,16 +111,16 @@ static int _lvconvert_name_params(struct lvconvert_params *lp,
(*pargv)++, (*pargc)--;
}
- if (!_lvconvert_vg_name(lp, cmd, &lp->pool_metadata_lv_name))
+ if (!validate_lvname_param(cmd, &lp->vg_name, &lp->pool_metadata_lv_name))
return_0;
- if (!_lvconvert_vg_name(lp, cmd, &lp->pool_data_lv_name))
+ if (!validate_lvname_param(cmd, &lp->vg_name, &lp->pool_data_lv_name))
return_0;
- if (!_lvconvert_vg_name(lp, cmd, &lp->origin_lv_name))
+ if (!validate_lvname_param(cmd, &lp->vg_name, &lp->origin_lv_name))
return_0;
- if (!_lvconvert_vg_name(lp, cmd, &lp->lv_split_name))
+ if (!validate_lvname_param(cmd, &lp->vg_name, &lp->lv_split_name))
return_0;
if (strchr(lp->lv_name_full, '/') &&
9 years