lvmetad enabled by default, add lvm2-activation-generator and related fixes

- Add lvm2-activation-generator systemd generator to automatically
  systemd units to activate LVM2 volumes even if lvmetad is not
  This replaces lvm activation part of the former fedora-storage-init
  script that was included in the initscripts package before.
- Enable lvmetad - the LVM metadata daemon by default.
- Don't use lvmetad in lvm2-monitor.service ExecStop to avoid a systemd issue.
- Remove dependency on fedora-storage-init.service in lvm2 systemd units.
- Depend on lvm2-lvmetad.socket in lvm2-monitor.service systemd unit.
- Init lvmetad lazily to avoid early socket access on config overrides.
- Hardcode use_lvmetad=0 if cluster locking used and issue a warning  msg.
- Fix dm_task_set_cookie to properly process udev flags if udev_sync disabled.
This commit is contained in:
Peter Rajnoha 2012-11-01 09:49:55 +01:00
parent 67a1307c80
commit 785220f1ca
6 changed files with 313 additions and 9 deletions

View File

@ -0,0 +1,58 @@
diff --git a/WHATS_NEW b/WHATS_NEW
index c0ae3df..5887ec7 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,3 +1,7 @@
+Version 2.02.99 -
+===================================
+ Hardcode use_lvmetad=0 if cluster locking used and issue a warning msg.
+
Version 2.02.98 - 15th October 2012
===================================
Switch from DEBUG() to DEBUGLOG() in lvmetad as -DDEBUG is already used.
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index d7f8ece..eb1a90b 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -413,7 +413,15 @@ static int _process_config(struct cmd_context *cmd)
lvmetad_set_socket(lvmetad_socket);
cn = find_config_tree_node(cmd, "devices/global_filter");
lvmetad_set_token(cn ? cn->v : NULL);
- lvmetad_set_active(find_config_tree_int(cmd, "global/use_lvmetad", 1));
+
+ if (find_config_tree_int(cmd, "global/locking_type", 1) == 3 &&
+ find_config_tree_int(cmd, "global/use_lvmetad", 1)) {
+ log_warn("WARNING: configuration setting use_lvmetad overriden to 0 due to locking_type 3. "
+ "Clustered environment not supported by lvmetad yet.");
+ lvmetad_set_active(0);
+ } else
+ lvmetad_set_active(find_config_tree_int(cmd, "global/use_lvmetad", 1));
+
lvmetad_init(cmd);
return 1;
diff --git a/test/shell/lvmetad-no-cluster.sh b/test/shell/lvmetad-no-cluster.sh
new file mode 100644
index 0000000..db68e77
--- /dev/null
+++ b/test/shell/lvmetad-no-cluster.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+# Copyright (C) 2012 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/test
+
+test -e LOCAL_CLVMD || skip
+aux prepare_vg 2
+aux prepare_lvmetad
+vgs -vv 2> errs
+cat errs
+grep 'use_lvmetad' errs

View File

@ -0,0 +1,111 @@
diff --git a/WHATS_NEW b/WHATS_NEW
index 5887ec7..d0e0cd4 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Initialize lvmetad lazily to avoid early socket access on config overrides.
Hardcode use_lvmetad=0 if cluster locking used and issue a warning msg.
Version 2.02.98 - 15th October 2012
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index 6a374ac..72e07fd 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -33,7 +33,8 @@ static struct cmd_context *_lvmetad_cmd = NULL;
void lvmetad_disconnect(void)
{
- daemon_close(_lvmetad);
+ if (_lvmetad_connected)
+ daemon_close(_lvmetad);
_lvmetad_connected = 0;
_lvmetad_cmd = NULL;
}
@@ -41,19 +42,25 @@ void lvmetad_disconnect(void)
void lvmetad_init(struct cmd_context *cmd)
{
if (!_lvmetad_use && !access(LVMETAD_PIDFILE, F_OK))
- log_warn("WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!");
+ log_warn("WARNING: lvmetad is running but disabled."
+ " Restart lvmetad before enabling it!");
+ _lvmetad_cmd = cmd;
+}
+
+static void _lvmetad_connect()
+{
if (_lvmetad_use && _lvmetad_socket && !_lvmetad_connected) {
assert(_lvmetad_socket);
_lvmetad = lvmetad_open(_lvmetad_socket);
- if (_lvmetad.socket_fd >= 0 && !_lvmetad.error) {
+ if (_lvmetad.socket_fd >= 0 && !_lvmetad.error)
_lvmetad_connected = 1;
- _lvmetad_cmd = cmd;
- }
}
}
void lvmetad_warning(void)
{
+ if (!_lvmetad_connected)
+ _lvmetad_connect();
if (_lvmetad_use && (_lvmetad.socket_fd < 0 || _lvmetad.error))
log_warn("WARNING: Failed to connect to lvmetad: %s. Falling back to internal scanning.",
strerror(_lvmetad.error));
@@ -61,7 +68,11 @@ void lvmetad_warning(void)
int lvmetad_active(void)
{
- return _lvmetad_use && _lvmetad_connected;
+ if (!_lvmetad_use)
+ return 0;
+ if (!_lvmetad_connected)
+ _lvmetad_connect();
+ return _lvmetad_connected;
}
void lvmetad_set_active(int active)
@@ -873,6 +884,11 @@ int lvmetad_pvscan_all_devs(struct cmd_context *cmd, activation_handler handler)
char *future_token;
int was_silent;
+ if (!lvmetad_active()) {
+ log_error("Cannot proceed since lvmetad is not active.");
+ return 0;
+ }
+
if (!(iter = dev_iter_create(cmd->lvmetad_filter, 1))) {
log_error("dev_iter creation failed");
return 0;
diff --git a/test/shell/lvmetad-override.sh b/test/shell/lvmetad-override.sh
new file mode 100644
index 0000000..3fb281a
--- /dev/null
+++ b/test/shell/lvmetad-override.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+# Copyright (C) 2012 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/test
+
+test -e LOCAL_LVMETAD || skip
+aux prepare_pvs 2
+
+vgcreate $vg1 $dev1 $dev2
+lvchange -ay $vg1 2>&1 | not grep "Failed to connect"
+kill $(cat LOCAL_LVMETAD)
+lvchange -ay $vg1 2>&1 | grep "Failed to connect"
+lvchange -ay $vg1 --sysinit 2>&1 | not grep "Failed to connect"
+lvchange -ay $vg1 --config 'global { use_lvmetad = 0 }' 2>&1 | not grep "Failed to connect"
+aux lvmconf "global/use_lvmetad = 0"
+lvchange -ay $vg1 --config 'global { use_lvmetad = 1 }' 2>&1 | grep "Failed to connect"
+

View File

@ -0,0 +1,32 @@
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 2d0b05c..3f8d9c9 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,3 +1,7 @@
+Version 1.02.78 -
+===================================
+ Fix dm_task_set_cookie to properly process udev flags if udev_sync disabled.
+
Version 1.02.77 - 15th October 2012
===================================
Support unmount of thin volumes from pool above thin pool threshold.
diff --git a/libdm/libdm-common.c b/libdm/libdm-common.c
index b8533ed..afdac89 100644
--- a/libdm/libdm-common.c
+++ b/libdm/libdm-common.c
@@ -1838,6 +1838,7 @@ int dm_task_set_cookie(struct dm_task *dmt, uint32_t *cookie, uint16_t flags)
if (dm_cookie_supported())
dmt->event_nr = flags << DM_UDEV_FLAGS_SHIFT;
*cookie = 0;
+ dmt->cookie_set = 1;
return 1;
}
@@ -2207,6 +2208,7 @@ int dm_task_set_cookie(struct dm_task *dmt, uint32_t *cookie, uint16_t flags)
if (!dm_udev_get_sync_support()) {
*cookie = 0;
+ dmt->cookie_set = 1;
return 1;
}

View File

@ -0,0 +1,48 @@
commit 8dedeaa0183d2c87764a4012e443af9597d28575
Author: Peter Rajnoha <prajnoha@redhat.com>
Date: Wed Oct 31 14:15:54 2012 +0100
0
---
WHATS_NEW | 3 +++
scripts/lvm2_monitoring_systemd_red_hat.service.in | 7 ++++---
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index d0e0cd4..12307ed 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,8 @@
Version 2.02.99 -
===================================
+ Don't use lvmetad in lvm2-monitor.service ExecStop to avoid a systemd issue.
+ Remove dependency on fedora-storage-init.service in lvm2 systemd units.
+ Depend on lvm2-lvmetad.socket in lvm2-monitor.service systemd unit.
Initialize lvmetad lazily to avoid early socket access on config overrides.
Hardcode use_lvmetad=0 if cluster locking used and issue a warning msg.
diff --git a/scripts/lvm2_monitoring_systemd_red_hat.service.in b/scripts/lvm2_monitoring_systemd_red_hat.service.in
index 6c4c55f..e6b4814 100644
--- a/scripts/lvm2_monitoring_systemd_red_hat.service.in
+++ b/scripts/lvm2_monitoring_systemd_red_hat.service.in
@@ -1,8 +1,8 @@
[Unit]
Description=Monitoring of LVM2 mirrors, snapshots etc. using dmeventd or progress polling
Documentation=man:dmeventd(8) man:lvcreate(8) man:lvchange(8) man:vgchange(8)
-Requires=dm-event.socket
-After=dm-event.socket fedora-storage-init.service fedora-storage-init-late.service lvm2-activation.service lvm2-lvmetad.service
+Requires=dm-event.socket lvm2-lvmetad.socket
+After=dm-event.socket lvm2-lvmetad.socket lvm2-lvmetad.service
Before=local-fs.target
DefaultDependencies=no
Conflicts=shutdown.target
@@ -11,7 +11,8 @@ Conflicts=shutdown.target
Type=oneshot
Environment=LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES=1
ExecStart=@sbindir@/lvm vgchange --monitor y
-ExecStop=@sbindir@/lvm vgchange --monitor n
+# The lvmetad must be disabled here, it needs https://bugzilla.redhat.com/show_bug.cgi?id=843587 to be resolved first.
+ExecStop="@sbindir@/lvm vgchange --monitor n --config 'global{use_lvmetad=0}'"
RemainAfterExit=yes
[Install]

View File

@ -0,0 +1,30 @@
doc/example.conf.in | 2 +-
lib/commands/toolcontext.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/doc/example.conf.in b/doc/example.conf.in
index 10cfe16..442ad64 100644
--- a/doc/example.conf.in
+++ b/doc/example.conf.in
@@ -491,7 +491,7 @@ 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.
- use_lvmetad = 0
+ use_lvmetad = 1
# Full path of the utility called to check that a thin metadata device
# is in a state that allows it to be used.
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index d72b0c0..d7f8ece 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -413,7 +413,7 @@ static int _process_config(struct cmd_context *cmd)
lvmetad_set_socket(lvmetad_socket);
cn = find_config_tree_node(cmd, "devices/global_filter");
lvmetad_set_token(cn ? cn->v : NULL);
- lvmetad_set_active(find_config_tree_int(cmd, "global/use_lvmetad", 0));
+ lvmetad_set_active(find_config_tree_int(cmd, "global/use_lvmetad", 1));
lvmetad_init(cmd);
return 1;

View File

@ -37,16 +37,21 @@
Summary: Userland logical volume management tools
Name: lvm2
Version: 2.02.98
Release: 2%{?dist}
Release: 3%{?dist}
License: GPLv2
Group: System Environment/Base
URL: http://sources.redhat.com/lvm2
Source0: ftp://sources.redhat.com/pub/lvm2/LVM2.%{version}.tgz
Patch0: lvm2-set-default-preferred_names.patch
Patch1: lvm2-2_02_99-python-remove-liblvm-object.patch
Patch2: lvm2-2_02_99-python-whitespace-and-conditional-cleanup.patch
Patch3: lvm2-2_02_99-python-update-example-to-work-with-lvm-object-removal.patch
Patch4: lvm2-2_02_99-python-implement-proper-refcounting-for-parent-objects.patch
Patch1: lvm2-enable-lvmetad-by-default.patch
Patch2: lvm2-2_02_99-python-remove-liblvm-object.patch
Patch3: lvm2-2_02_99-python-whitespace-and-conditional-cleanup.patch
Patch4: lvm2-2_02_99-python-update-example-to-work-with-lvm-object-removal.patch
Patch5: lvm2-2_02_99-python-implement-proper-refcounting-for-parent-objects.patch
Patch6: lvm2-2_02_99-properly-set-cookie_set-var-on-dm_task_set_cookie-call.patch
Patch7: lvm2-2_02_99-hardcode-use_lvmetad0-if-cluster-locking-used-and-issue-warning-msg.patch
Patch8: lvm2-2_02_99-init-lvmetad-lazily-to-avoid-early-socket-access-on-config-overrides.patch
Patch9: lvm2-2_02_99-various-updates-and-fixes-for-systemd-units.patch
BuildRequires: libselinux-devel >= %{libselinux_version}, libsepol-devel
BuildRequires: ncurses-devel
@ -82,10 +87,15 @@ or more physical volumes and creating one or more logical volumes
%prep
%setup -q -n LVM2.%{version}
%patch0 -p1 -b .preferred_names
%patch1 -p1 -b .python_liblvm_object
%patch2 -p1 -b .python_cleanup
%patch3 -p1 -b .python_fix_example
%patch4 -p1 -b .python_refcounting
%patch1 -p1 -b .enable_lvmetad
%patch2 -p1 -b .python_liblvm_object
%patch3 -p1 -b .python_cleanup
%patch4 -p1 -b .python_fix_example
%patch5 -p1 -b .python_refcounting
%patch6 -p1 -b .cookie_flags
%patch7 -p1 -b .cluster_lvmetad
%patch8 -p1 -b .lvmetad_lazy_init
%patch9 -p1 -b .systemd_fixes
%build
%define _default_pid_dir /run
@ -116,6 +126,7 @@ make install DESTDIR=$RPM_BUILD_ROOT
make install_system_dirs DESTDIR=$RPM_BUILD_ROOT
make install_initscripts DESTDIR=$RPM_BUILD_ROOT
make install_systemd_units DESTDIR=$RPM_BUILD_ROOT
make install_systemd_generators DESTDIR=$RPM_BUILD_ROOT
make install_tmpfiles_configuration DESTDIR=$RPM_BUILD_ROOT
%clean
@ -266,6 +277,7 @@ rm -rf $RPM_BUILD_ROOT
%{_tmpfilesdir}/%{name}.conf
%{_unitdir}/blk-availability.service
%{_unitdir}/lvm2-monitor.service
%{_prefix}/lib/systemd/system-generators/lvm2-activation-generator
%if %{enable_lvmetad}
%{_unitdir}/lvm2-lvmetad.socket
%{_unitdir}/lvm2-lvmetad.service
@ -580,6 +592,19 @@ the device-mapper event library.
%{_libdir}/pkgconfig/devmapper-event.pc
%changelog
* Thu Nov 01 2012 Peter Rajnoha <prajnoha@redhat.com> - 2.02.98-3
- Add lvm2-activation-generator systemd generator to automatically generate
systemd units to activate LVM2 volumes even if lvmetad is not used.
This replaces lvm activation part of the former fedora-storage-init
script that was included in the initscripts package before.
- Enable lvmetad - the LVM metadata daemon by default.
- Don't use lvmetad in lvm2-monitor.service ExecStop to avoid a systemd issue.
- Remove dependency on fedora-storage-init.service in lvm2 systemd units.
- Depend on lvm2-lvmetad.socket in lvm2-monitor.service systemd unit.
- Init lvmetad lazily to avoid early socket access on config overrides.
- Hardcode use_lvmetad=0 if cluster locking used and issue a warning msg.
- Fix dm_task_set_cookie to properly process udev flags if udev_sync disabled.
* Sat Oct 20 2012 Peter Rajnoha <prajnoha@redhat.com> - 2.02.98-2
- Incorporate former python-lvm package in lvm2 as lvm2-python-libs subpackage.