Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a5f01dad224929ea…
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);
}
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=00d8ab84923af871…
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);
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fbc28cc7adb45312…
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
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d1be66ba3708c23a…
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)