master - allocation: use vg memory pool
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=15ba2afdc2d70e...
Commit: 15ba2afdc2d70ee21c2599f0d51a413f0a7afa9b
Parent: 3880ca5ecad1761bd13a190c58f8f85fdd7cd0e1
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Sep 11 19:00:13 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Sep 12 13:39:58 2014 +0200
allocation: use vg memory pool
Looks like forgotten memory allocation related to VG used cmd mem pool.
---
lib/metadata/lv_manip.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 8c1bd83..12585ef 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -3083,7 +3083,7 @@ struct alloc_handle *allocate_extents(struct volume_group *vg,
if (alloc >= ALLOC_INHERIT)
alloc = vg->alloc;
- if (!(ah = _alloc_init(vg->cmd, vg->cmd->mem, segtype, alloc, approx_alloc,
+ if (!(ah = _alloc_init(vg->cmd, vg->vgmem, segtype, alloc, approx_alloc,
lv ? lv->le_count : 0, extents, mirrors, stripes, log_count,
vg->extent_size, region_size,
parallel_areas)))
9 years, 7 months
master - libdm: use dm-mod autoloading during dm_is_dm_major call if needed
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3880ca5ecad176...
Commit: 3880ca5ecad1761bd13a190c58f8f85fdd7cd0e1
Parent: f0cafc92812e285e5120241da04b5d119b27060b
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Sep 12 12:49:37 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Sep 12 12:49:37 2014 +0200
libdm: use dm-mod autoloading during dm_is_dm_major call if needed
For dm_is_dm_major to determine whether the major number given as
an argument belongs to a DM device, libdm code needs to know what
the actual DM major is to do the comparison.
It may happen that the dm-mod module is not loaded during this
call and so for the completness let's try our best before we start
giving various errors - we can still make use of dm-mod autoloading,
though only since kernels 2.6.36 where this feature was introduced.
---
WHATS_NEW_DM | 1 +
libdm/ioctl/libdm-iface.c | 40 +++++++++++++++++++++++++++++-----------
2 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 4effe09..1374934 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.91 -
====================================
+ Use dm-mod autoloading during dm_is_dm_major call if needed (kernels>=2.6.36).
Version 1.02.90 - 1st September 2014
====================================
diff --git a/libdm/ioctl/libdm-iface.c b/libdm/ioctl/libdm-iface.c
index 7d50f3a..9350912 100644
--- a/libdm/ioctl/libdm-iface.c
+++ b/libdm/ioctl/libdm-iface.c
@@ -336,17 +336,6 @@ static int _create_dm_bitset(void)
#endif
}
-int dm_is_dm_major(uint32_t major)
-{
- if (!_create_dm_bitset())
- return 0;
-
- if (_dm_multiple_major_support)
- return dm_bit(_dm_bitset, major) ? 1 : 0;
- else
- return (major == _dm_device_major) ? 1 : 0;
-}
-
static void _close_control_fd(void)
{
if (_control_fd != -1) {
@@ -423,6 +412,35 @@ bad:
#endif
}
+int dm_is_dm_major(uint32_t major)
+{
+ /*
+ * If dm-mod module is not loaded yet during this call, we
+ * can make it to load automatically in kernels >= 2.6.36
+ * just by opening the dm control device. However, in older
+ * kernels, there's nothing else we can do here - dm_is_dm_major
+ * will fail as it can't determine this without the module
+ * being loaded first - there's an error message issued for
+ * this scenario deeper in this code.
+ */
+ if (!_uname())
+ return 0;
+
+ if (KERNEL_VERSION(_kernel_major, _kernel_minor, _kernel_release) >=
+ KERNEL_VERSION(2, 6, 36)) {
+ if (_control_fd == -1 && !_open_control())
+ return 0;
+ }
+
+ if (!_create_dm_bitset())
+ return 0;
+
+ if (_dm_multiple_major_support)
+ return dm_bit(_dm_bitset, major) ? 1 : 0;
+ else
+ return (major == _dm_device_major) ? 1 : 0;
+}
+
static void _dm_zfree_string(char *string)
{
if (string) {
9 years, 7 months
master - conf: add allocation/physical_extent_size config option for default PE size of VGs.
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f0cafc92812e28...
Commit: f0cafc92812e285e5120241da04b5d119b27060b
Parent: 80ac8f37d6ac5f8c5228678d4ee07187b5d4db7b
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Sep 12 10:03:12 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Sep 12 10:09:21 2014 +0200
conf: add allocation/physical_extent_size config option for default PE size of VGs.
Removes a need to use "vgcreate -s <desired PE size>" all the
time time just to override hardcoded default which is 4096KiB.
---
WHATS_NEW | 1 +
conf/example.conf.in | 3 +++
lib/config/config_settings.h | 2 +-
tools/toollib.c | 21 +++++++++++++++++----
tools/toollib.h | 3 ++-
tools/vgcreate.c | 3 ++-
tools/vgsplit.c | 5 ++++-
7 files changed, 30 insertions(+), 8 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 2175d29..983bc1a 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Add allocation/physical_extent_size config option for default PE size of VGs.
Introduce common code to modify metadate and reload updated LV.
Fix rename of active snapshot volume in cluster.
Make sure shared libraries are built with RELRO option.
diff --git a/conf/example.conf.in b/conf/example.conf.in
index 21c553a..511ca0b 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -370,6 +370,9 @@ allocation {
# first use.
# N.B. zeroing larger thin pool chunk size degrades performance.
# thin_pool_zero = 1
+
+ # Default physical extent size to use for newly created VGs (in KB).
+ # physical_extent_size = 4096
}
# This section that allows you to configure the nature of the
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index c6be2e3..7724c57 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -126,7 +126,7 @@ cfg(allocation_thin_pool_zero_CFG, "thin_pool_zero", allocation_CFG_SECTION, CFG
cfg(allocation_thin_pool_discards_CFG, "thin_pool_discards", allocation_CFG_SECTION, CFG_PROFILABLE | CFG_PROFILABLE_METADATA, CFG_TYPE_STRING, DEFAULT_THIN_POOL_DISCARDS, vsn(2, 2, 99), NULL)
cfg(allocation_thin_pool_chunk_size_policy_CFG, "thin_pool_chunk_size_policy", allocation_CFG_SECTION, CFG_PROFILABLE | CFG_PROFILABLE_METADATA, CFG_TYPE_STRING, DEFAULT_THIN_POOL_CHUNK_SIZE_POLICY, vsn(2, 2, 101), NULL)
cfg_runtime(allocation_thin_pool_chunk_size_CFG, "thin_pool_chunk_size", allocation_CFG_SECTION, CFG_PROFILABLE | CFG_PROFILABLE_METADATA | CFG_DEFAULT_UNDEFINED, CFG_TYPE_INT, vsn(2, 2, 99), NULL)
-
+cfg(allocation_physical_extent_size_CFG, "physical_extent_size", allocation_CFG_SECTION, 0, CFG_TYPE_INT, DEFAULT_EXTENT_SIZE, vsn(2, 2, 112), NULL)
cfg(log_verbose_CFG, "verbose", log_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_VERBOSE, vsn(1, 0, 0), NULL)
cfg(log_silent_CFG, "silent", log_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_SILENT, vsn(2, 2, 98), NULL)
diff --git a/tools/toollib.c b/tools/toollib.c
index 25ff21d..b160ead 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1305,9 +1305,14 @@ struct dm_list *clone_pv_list(struct dm_pool *mem, struct dm_list *pvsl)
return r;
}
-void vgcreate_params_set_defaults(struct vgcreate_params *vp_def,
- struct volume_group *vg)
+const char _pe_size_may_not_be_negative_msg[] = "Physical extent size may not be negative";
+
+int vgcreate_params_set_defaults(struct cmd_context *cmd,
+ struct vgcreate_params *vp_def,
+ struct volume_group *vg)
{
+ int64_t extent_size;
+
if (vg) {
vp_def->vg_name = NULL;
vp_def->extent_size = vg->extent_size;
@@ -1318,13 +1323,21 @@ void vgcreate_params_set_defaults(struct vgcreate_params *vp_def,
vp_def->vgmetadatacopies = vg->mda_copies;
} else {
vp_def->vg_name = NULL;
- vp_def->extent_size = DEFAULT_EXTENT_SIZE * 2;
+ extent_size = find_config_tree_int64(cmd,
+ allocation_physical_extent_size_CFG, NULL) * 2;
+ if (extent_size < 0) {
+ log_error(_pe_size_may_not_be_negative_msg);
+ return 0;
+ }
+ vp_def->extent_size = (uint32_t) extent_size;
vp_def->max_pv = DEFAULT_MAX_PV;
vp_def->max_lv = DEFAULT_MAX_LV;
vp_def->alloc = DEFAULT_ALLOC_POLICY;
vp_def->clustered = DEFAULT_CLUSTERED;
vp_def->vgmetadatacopies = DEFAULT_VGMETADATACOPIES;
}
+
+ return 1;
}
/*
@@ -1357,7 +1370,7 @@ int vgcreate_params_set_from_args(struct cmd_context *cmd,
vp_new->clustered = locking_is_clustered();
if (arg_sign_value(cmd, physicalextentsize_ARG, SIGN_NONE) == SIGN_MINUS) {
- log_error("Physical extent size may not be negative");
+ log_error(_pe_size_may_not_be_negative_msg);
return 0;
}
diff --git a/tools/toollib.h b/tools/toollib.h
index b51c637..c605aed 100644
--- a/tools/toollib.h
+++ b/tools/toollib.h
@@ -106,7 +106,8 @@ struct dm_list *create_pv_list(struct dm_pool *mem, struct volume_group *vg, int
struct dm_list *clone_pv_list(struct dm_pool *mem, struct dm_list *pvs);
-void vgcreate_params_set_defaults(struct vgcreate_params *vp_def,
+int vgcreate_params_set_defaults(struct cmd_context *cmd,
+ struct vgcreate_params *vp_def,
struct volume_group *vg);
int vgcreate_params_set_from_args(struct cmd_context *cmd,
struct vgcreate_params *vp_new,
diff --git a/tools/vgcreate.c b/tools/vgcreate.c
index 9d701c8..01bf421 100644
--- a/tools/vgcreate.c
+++ b/tools/vgcreate.c
@@ -41,7 +41,8 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
- vgcreate_params_set_defaults(&vp_def, NULL);
+ if (!vgcreate_params_set_defaults(cmd, &vp_def, NULL))
+ return EINVALID_CMD_LINE;
vp_def.vg_name = vg_name;
if (!vgcreate_params_set_from_args(cmd, &vp_new, &vp_def))
return EINVALID_CMD_LINE;
diff --git a/tools/vgsplit.c b/tools/vgsplit.c
index 5478e78..1a8e237 100644
--- a/tools/vgsplit.c
+++ b/tools/vgsplit.c
@@ -551,7 +551,10 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
if (!vgs_are_compatible(cmd, vg_from,vg_to))
goto_bad;
} else {
- vgcreate_params_set_defaults(&vp_def, vg_from);
+ if (!vgcreate_params_set_defaults(cmd, &vp_def, vg_from)) {
+ r = EINVALID_CMD_LINE;
+ goto_bad;
+ }
vp_def.vg_name = vg_name_to;
if (!vgcreate_params_set_from_args(cmd, &vp_new, &vp_def)) {
r = EINVALID_CMD_LINE;
9 years, 7 months
master - filters: fix incorrect filter indexing in composite filter array
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=80ac8f37d6ac5f...
Commit: 80ac8f37d6ac5f8c5228678d4ee07187b5d4db7b
Parent: 4748f4a9e4516a8c9226ce61b5a3ca41f0852ffc
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Sep 11 09:30:03 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Sep 11 09:30:03 2014 +0200
filters: fix incorrect filter indexing in composite filter array
Caused by recent changes - a7be3b12dfe7388d1648595e6cc4c7a1379bb8a7.
If global filter was not defined, then part of the code
creating composite filter (the cmd->lvmetad_filter) incorrectly
increased index value even if this global filter was not created
as part of the composite filter. This caused a gap with "NULL"
value in the composite filter array which ended up with the rest
of the filters after the gap to be ignored and also it caused a mem
leak when destroying the composite filter.
---
lib/commands/toolcontext.c | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 5bf5cbf..c3afae4 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -861,12 +861,13 @@ static struct dev_filter *_init_filter_components(struct cmd_context *cmd)
}
/* regex filter. Optional. */
- if ((cn = find_config_tree_node(cmd, devices_global_filter_CFG, NULL)) &&
- !(filters[nr_filt] = regex_filter_create(cn->v))) {
- log_error("Failed to create global regex device filter");
- goto bad;
- } else
+ if ((cn = find_config_tree_node(cmd, devices_global_filter_CFG, NULL))) {
+ if (!(filters[nr_filt] = regex_filter_create(cn->v))) {
+ log_error("Failed to create global regex device filter");
+ goto bad;
+ }
nr_filt++;
+ }
/* device type filter. Required. */
if (!(filters[nr_filt] = lvm_type_filter_create(cmd->dev_types))) {
9 years, 7 months
master - tests: test for rename of snapshot
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4748f4a9e4516a...
Commit: 4748f4a9e4516a8c9226ce61b5a3ca41f0852ffc
Parent: 671d0ea1b16ca83d0bf27ef6afdf451efaf4097e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Sep 10 22:02:18 2014 +0200
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Sep 10 22:59:13 2014 +0100
tests: test for rename of snapshot
---
test/shell/snapshot-rename.sh | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/test/shell/snapshot-rename.sh b/test/shell/snapshot-rename.sh
new file mode 100644
index 0000000..8d1eefb
--- /dev/null
+++ b/test/shell/snapshot-rename.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+# Copyright (C) 2014 Red Hat, Inc. All rights reserved.
+#
+# 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 General Public License v.2.
+#
+# You should have received a copy of the GNU 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
+
+# Testing renaming snapshots (had problem in cluster)
+# https://bugzilla.redhat.com/show_bug.cgi?id=1136925
+
+. lib/inittest
+
+aux prepare_vg 1
+
+lvcreate -aey -L1 -n $lv1 $vg
+lvcreate -s -L1 -n $lv2 $vg/$lv1
+lvrename $vg/$lv2 $vg/$lv3
+lvremove -f $vg/$lv1
+
+vgremove -f $vg
9 years, 7 months
master - lvmetad: Differentiate between filtered and truly missing devices.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=671d0ea1b16ca8...
Commit: 671d0ea1b16ca83d0bf27ef6afdf451efaf4097e
Parent: 5f9b30d17807aeb3bd31a3490cf9a45223324a4f
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Wed Sep 10 12:45:52 2014 +0200
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Sep 10 22:58:22 2014 +0100
lvmetad: Differentiate between filtered and truly missing devices.
We used to print an error message whenever we tried to deal with devices that
lvmetad knew about but were rejected by a client-side filter. Instead, we now
check whether the device is actually absent or only filtered out and only print
a warning in the latter case.
---
lib/cache/lvmetad.c | 6 +++++-
test/shell/lvmetad-client-filter.sh | 18 ++++++++++++++++++
2 files changed, 23 insertions(+), 1 deletions(-)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index 7896ddd..ef1d01a 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -293,7 +293,11 @@ static struct lvmcache_info *_pv_populate_lvmcache(struct cmd_context *cmd,
dev = dev_cache_get_by_devt(fallback, cmd->filter);
if (!dev) {
- log_error("No device found for PV %s.", pvid_txt);
+ 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);
return NULL;
}
diff --git a/test/shell/lvmetad-client-filter.sh b/test/shell/lvmetad-client-filter.sh
new file mode 100644
index 0000000..3002a47
--- /dev/null
+++ b/test/shell/lvmetad-client-filter.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+# Copyright (C) 2014 Red Hat, Inc. All rights reserved.
+#
+# 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 General Public License v.2.
+#
+# You should have received a copy of the GNU 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
+
+. lib/inittest
+
+test -e LOCAL_LVMETAD || skip
+aux prepare_pvs 2
+
+pvs --config 'devices { filter = [ "r%.*%" ] }' 2>&1 | grep rejected
+pvs --config 'devices { filter = [ "r%.*%" ] }' 2>&1 | not grep 'No device found'
9 years, 7 months
master - test: Add a test for MD component detection in pvscan --cache.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5f9b30d17807ae...
Commit: 5f9b30d17807aeb3bd31a3490cf9a45223324a4f
Parent: a7be3b12dfe7388d1648595e6cc4c7a1379bb8a7
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Tue Sep 9 17:25:29 2014 +0200
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Sep 10 22:58:12 2014 +0100
test: Add a test for MD component detection in pvscan --cache.
---
test/shell/lvmetad-pvscan-md.sh | 77 +++++++++++++++++++++++++++++++++++++++
1 files changed, 77 insertions(+), 0 deletions(-)
diff --git a/test/shell/lvmetad-pvscan-md.sh b/test/shell/lvmetad-pvscan-md.sh
new file mode 100644
index 0000000..dd85bb6
--- /dev/null
+++ b/test/shell/lvmetad-pvscan-md.sh
@@ -0,0 +1,77 @@
+#!/bin/sh
+# Copyright (C) 2014 Red Hat, Inc. All rights reserved.
+#
+# 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 General Public License v.2.
+#
+# You should have received a copy of the GNU 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
+
+. lib/inittest
+
+test -e LOCAL_LVMETAD || skip
+which mdadm || skip
+
+test -f /proc/mdstat && grep -q raid0 /proc/mdstat || \
+ modprobe raid0 || skip
+
+aux lvmconf 'devices/md_component_detection = 1'
+aux extend_filter_LVMTEST
+aux extend_filter "a|/dev/md.*|"
+
+aux prepare_devs 2
+
+# TODO factor out the following MD-creation code into lib/
+
+# Have MD use a non-standard name to avoid colliding with an existing MD device
+# - mdadm >= 3.0 requires that non-standard device names be in /dev/md/
+# - newer mdadm _completely_ defers to udev to create the associated device node
+mdadm_maj=$(mdadm --version 2>&1 | perl -pi -e 's|.* v(\d+).*|\1|')
+[ $mdadm_maj -ge 3 ] && \
+ mddev=/dev/md/md_lvm_test0 || \
+ mddev=/dev/md_lvm_test0
+
+cleanup_md() {
+ # sleeps offer hack to defeat: 'md: md127 still in use'
+ # see: https://bugzilla.redhat.com/show_bug.cgi?id=509908#c25
+ aux udev_wait
+ mdadm --stop "$mddev" || true
+ aux udev_wait
+ if [ -b "$mddev" ]; then
+ # mdadm doesn't always cleanup the device node
+ sleep 2
+ rm -f "$mddev"
+ fi
+}
+
+cleanup_md_and_teardown() {
+ cleanup_md
+ aux teardown
+}
+
+# create 2 disk MD raid0 array (stripe_width=128K)
+test -b "$mddev" && skip
+mdadm --create --metadata=1.0 "$mddev" --auto=md --level 0 --raid-devices=2 --chunk 64 "$dev1" "$dev2"
+trap 'cleanup_md_and_teardown' EXIT # cleanup this MD device at the end of the test
+test -b "$mddev" || skip
+cp -LR "$mddev" "$DM_DEV_DIR" # so that LVM/DM can see the device
+lvmdev="$DM_DEV_DIR/md_lvm_test0"
+
+# TODO end MD-creation code
+
+# maj=$(($(stat -L --printf=0x%t "$dev2")))
+# min=$(($(stat -L --printf=0x%T "$dev2")))
+
+pvcreate $lvmdev
+
+pvscan --cache "$lvmdev"
+
+# ensure that lvmetad can only see the toplevel MD device
+not pvscan --cache "$dev1" 2>&1 | grep "not found"
+not pvscan --cache "$dev2" 2>&1 | grep "not found"
+
+pvs | grep $lvmdev
+pvs | not grep $dev1
+pvs | not grep $dev2
9 years, 7 months
master - lvmetad: Re-organise filters to properly avoid scans of component devices.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a7be3b12dfe738...
Commit: a7be3b12dfe7388d1648595e6cc4c7a1379bb8a7
Parent: 1f0c4c811da287e7fc28b8c31dcd03347b16d360
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Tue Sep 9 17:16:40 2014 +0200
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Sep 10 22:58:02 2014 +0100
lvmetad: Re-organise filters to properly avoid scans of component devices.
If a PV label is exposed both through a composite device (MD for example) and
through its component devices, we always want the PV that lvmetad sees to be the
composite, since this is what all LVM commands (including activation) will then
use. If pvscan --cache is triggered for multiple clones of the same PV, the last
to finish wins. This patch basically re-arranges the filters so that
component-device filters are part of the global_filter chain, not of the
client-side filter chain. This has a subtle effect on filter evaluation order,
but should not alter visible semantics in the non-lvmetad case.
---
lib/commands/toolcontext.c | 47 +++++++++++++++++++++----------------------
1 files changed, 23 insertions(+), 24 deletions(-)
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index fe79a81..5bf5cbf 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -861,11 +861,9 @@ static struct dev_filter *_init_filter_components(struct cmd_context *cmd)
}
/* regex filter. Optional. */
- if (!(cn = find_config_tree_node(cmd, devices_filter_CFG, NULL)))
- log_very_verbose("devices/filter not found in config file: "
- "no regex filter installed");
- else if (!(filters[nr_filt] = regex_filter_create(cn->v))) {
- log_error("Failed to create regex device filter");
+ if ((cn = find_config_tree_node(cmd, devices_global_filter_CFG, NULL)) &&
+ !(filters[nr_filt] = regex_filter_create(cn->v))) {
+ log_error("Failed to create global regex device filter");
goto bad;
} else
nr_filt++;
@@ -918,16 +916,26 @@ static int _init_filters(struct cmd_context *cmd, unsigned load_persistent_cache
cmd->dump_filter = 0;
- if (!(f3 = _init_filter_components(cmd)))
+ if (!(cmd->lvmetad_filter = _init_filter_components(cmd)))
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 ((cn = find_config_tree_node(cmd, devices_filter_CFG, NULL))) {
+ if (!(f3 = 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)))
+ goto_bad;
+ } else
+ f4 = cmd->lvmetad_filter;
+
if (!(dev_cache = find_config_tree_str(cmd, devices_cache_CFG, NULL)))
goto_bad;
- if (!(f4 = persistent_filter_create(cmd->dev_types, f3, dev_cache))) {
+ if (!(cmd->filter = persistent_filter_create(cmd->dev_types, f4, dev_cache))) {
log_verbose("Failed to create persistent device filter.");
goto bad;
}
@@ -948,29 +956,20 @@ static int _init_filters(struct cmd_context *cmd, unsigned load_persistent_cache
load_persistent_cache && !cmd->is_long_lived &&
!stat(dev_cache, &st) &&
(st.st_ctime > config_file_timestamp(cmd->cft)) &&
- !persistent_filter_load(f4, NULL))
+ !persistent_filter_load(cmd->filter, NULL))
log_verbose("Failed to load existing device cache from %s",
dev_cache);
- if (!(cn = find_config_tree_node(cmd, devices_global_filter_CFG, NULL))) {
- cmd->filter = f4;
- } else if (!(cmd->lvmetad_filter = regex_filter_create(cn->v)))
- goto_bad;
- else {
- toplevel_components[0] = cmd->lvmetad_filter;
- toplevel_components[1] = f4;
- if (!(cmd->filter = composite_filter_create(2, toplevel_components)))
- goto_bad;
- }
-
return 1;
bad:
- if (f4)
+ if (f4) /* kills both f3 and cmd->lvmetad_filter */
f4->destroy(f4);
- else if (f3)
- f3->destroy(f3);
- if (toplevel_components[0])
- toplevel_components[0]->destroy(toplevel_components[0]);
+ else {
+ if (f3)
+ f3->destroy(f3);
+ if (cmd->lvmetad_filter)
+ cmd->lvmetad_filter->destroy(cmd->lvmetad_filter);
+ }
return 0;
}
9 years, 7 months
master - dev-cache: Filter wipe does not guarantee a full /dev scan.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1f0c4c811da287...
Commit: 1f0c4c811da287e7fc28b8c31dcd03347b16d360
Parent: 47ff145e08f689306762840efd72e8a4e1c91214
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Tue Sep 9 17:14:35 2014 +0200
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Sep 10 22:57:49 2014 +0100
dev-cache: Filter wipe does not guarantee a full /dev scan.
The code in dev_iter_create assumes that if a filter can be wiped, doing so will
always trigger a call to _full_scan. This is not true for composite filters
though, since they can always be wiped in principle, but there is no way to know
that a component filter inside will exist that actually triggers the scan.
---
lib/device/dev-cache.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 1d7a517..ba4ee54 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -1009,9 +1009,11 @@ struct dev_iter *dev_iter_create(struct dev_filter *f, int dev_scan)
if (dev_scan && !trust_cache()) {
/* Flag gets reset between each command */
if (!full_scan_done()) {
- if (f && f->wipe)
- f->wipe(f); /* Calls _full_scan(1) */
- else
+ if (f && f->wipe) {
+ f->wipe(f); /* might call _full_scan(1) */
+ if (!full_scan_done())
+ _full_scan(1);
+ } else
_full_scan(1);
}
} else
9 years, 7 months
master - debug: turn message into debug
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=47ff145e08f689...
Commit: 47ff145e08f689306762840efd72e8a4e1c91214
Parent: 55aa3cc813620ecbf2f569720fb24107e737b836
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Sep 10 10:10:13 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Sep 10 10:10:13 2014 +0200
debug: turn message into debug
This message should be printed only for activation commands,
however since the handling of this flag is not correct
(rhbz 1140029) and will require further changes,
do now just a minor change and switch message into log_debug
(so it's not printed i.e. with every 'lvs -v')
---
tools/lvmcmdline.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 10dac8f..14ea7a6 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1343,7 +1343,7 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
goto_out;
_apply_settings(cmd);
if (cmd->degraded_activation)
- log_verbose("DEGRADED MODE. Incomplete RAID LVs will be processed.");
+ log_debug("DEGRADED MODE. Incomplete RAID LVs will be processed.");
if (!get_activation_monitoring_mode(cmd, &monitoring))
goto_out;
9 years, 7 months