[lvm2/f19] Additional fixes.

Peter Rajnoha prajnoha at fedoraproject.org
Fri Jul 26 12:09:29 UTC 2013


commit 19326ce8b8509d5174ea4a1986405c05131821b3
Author: Peter Rajnoha <prajnoha at redhat.com>
Date:   Fri Jul 26 14:08:12 2013 +0200

    Additional fixes.

 ...0-fix-segfault-if-global_filter-incorrect.patch |   43 ++++++
 ...obal-filter-in-pvscan-cache-with-a-device.patch |   40 ++++++
 ...err-msg-severity-for-activation-generator.patch |  137 ++++++++++++++++++++
 lvm2.spec                                          |   20 ++-
 4 files changed, 235 insertions(+), 5 deletions(-)
---
diff --git a/lvm2-2_02_100-fix-segfault-if-global_filter-incorrect.patch b/lvm2-2_02_100-fix-segfault-if-global_filter-incorrect.patch
new file mode 100644
index 0000000..c7359b9
--- /dev/null
+++ b/lvm2-2_02_100-fix-segfault-if-global_filter-incorrect.patch
@@ -0,0 +1,43 @@
+ WHATS_NEW                  | 4 ++++
+ lib/commands/toolcontext.c | 7 +++----
+ 2 files changed, 7 insertions(+), 4 deletions(-)
+
+diff --git a/WHATS_NEW b/WHATS_NEW
+index d14756e..500db7e 100644
+--- a/WHATS_NEW
++++ b/WHATS_NEW
+@@ -1,3 +1,7 @@
++Version 2.02.100 - 
++===================================
++  Fix segfault if devices/global_filter is not specified correctly.
++
+ Version 2.02.99 - 
+ ===================================
+   Respect lvmetad global filter in pvscan --cache with a device.
+diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
+index 61d5c26..e8cfba1 100644
+--- a/lib/commands/toolcontext.c
++++ b/lib/commands/toolcontext.c
+@@ -883,8 +883,7 @@ static int _init_filters(struct cmd_context *cmd, unsigned load_persistent_cache
+ 
+ 	if (!(f4 = persistent_filter_create(f3, dev_cache))) {
+ 		log_verbose("Failed to create persistent device filter.");
+-		f3->destroy(f3);
+-		return_0;
++		goto bad;
+ 	}
+ 
+ 	/* Should we ever dump persistent filter state? */
+@@ -918,10 +917,10 @@ static int _init_filters(struct cmd_context *cmd, unsigned load_persistent_cache
+ 
+ 	return 1;
+ bad:
+-	if (f3)
+-		f3->destroy(f3);
+ 	if (f4)
+ 		f4->destroy(f4);
++	else if (f3)
++		f3->destroy(f3);
+ 	if (toplevel_components[0])
+ 		toplevel_components[0]->destroy(toplevel_components[0]);
+ 	return 0;
diff --git a/lvm2-2_02_99-respect-global-filter-in-pvscan-cache-with-a-device.patch b/lvm2-2_02_99-respect-global-filter-in-pvscan-cache-with-a-device.patch
new file mode 100644
index 0000000..6f0339c
--- /dev/null
+++ b/lvm2-2_02_99-respect-global-filter-in-pvscan-cache-with-a-device.patch
@@ -0,0 +1,40 @@
+ WHATS_NEW      | 1 +
+ tools/pvscan.c | 5 ++---
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/WHATS_NEW b/WHATS_NEW
+index 67ae4be..d14756e 100644
+--- a/WHATS_NEW
++++ b/WHATS_NEW
+@@ -1,5 +1,6 @@
+ Version 2.02.99 - 
+ ===================================
++  Respect lvmetad global filter in pvscan --cache with a device.
+   Use LOG_DEBUG/ERR msg severity instead default for lvm2-activation-generator.
+   Fix premature DM version checking which caused useless mapper/control access.
+   Recognize DM_DISABLE_UDEV environment variable for a complete fallback.
+diff --git a/tools/pvscan.c b/tools/pvscan.c
+index 1e844c5..08ad5e9 100644
+--- a/tools/pvscan.c
++++ b/tools/pvscan.c
+@@ -185,7 +185,7 @@ static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv)
+ 	/* Process any command line PVs first. */
+ 	while (argc--) {
+ 		pv_name = *argv++;
+-		dev = dev_cache_get(pv_name, NULL);
++		dev = dev_cache_get(pv_name, cmd->lvmetad_filter);
+ 		if (!dev) {
+ 			log_error("Physical Volume %s not found.", pv_name);
+ 			ret = ECMD_FAILED;
+@@ -213,10 +213,9 @@ static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv)
+ 
+ 		devno = MKDEV((dev_t)major, minor);
+ 
+-		if (!(dev = dev_cache_get_by_devt(devno, NULL))) {
++		if (!(dev = dev_cache_get_by_devt(devno, cmd->lvmetad_filter))) {
+ 			if (!dm_asprintf(&buf, "%" PRIi32 ":%" PRIi32, major, minor))
+ 				stack;
+-			/* FIXME Filters? */
+ 			if (!lvmetad_pv_gone(devno, buf ? : "", handler)) {
+ 				ret = ECMD_FAILED;
+ 				if (buf)
diff --git a/lvm2-2_02_99-use-log_debug_err-msg-severity-for-activation-generator.patch b/lvm2-2_02_99-use-log_debug_err-msg-severity-for-activation-generator.patch
new file mode 100644
index 0000000..6638601
--- /dev/null
+++ b/lvm2-2_02_99-use-log_debug_err-msg-severity-for-activation-generator.patch
@@ -0,0 +1,137 @@
+ WHATS_NEW                                          |  1 +
+ .../lvm2_activation_generator_systemd_red_hat.c    | 35 ++++++++++++----------
+ 2 files changed, 21 insertions(+), 15 deletions(-)
+
+diff --git a/WHATS_NEW b/WHATS_NEW
+index eb7897d..67ae4be 100644
+--- a/WHATS_NEW
++++ b/WHATS_NEW
+@@ -1,5 +1,6 @@
+ Version 2.02.99 - 
+ ===================================
++  Use LOG_DEBUG/ERR msg severity instead default for lvm2-activation-generator.
+   Fix premature DM version checking which caused useless mapper/control access.
+   Recognize DM_DISABLE_UDEV environment variable for a complete fallback.
+   Do not verify udev operations if --noudevsync command option is used.
+diff --git a/scripts/lvm2_activation_generator_systemd_red_hat.c b/scripts/lvm2_activation_generator_systemd_red_hat.c
+index dfd6fc4..b666354 100644
+--- a/scripts/lvm2_activation_generator_systemd_red_hat.c
++++ b/scripts/lvm2_activation_generator_systemd_red_hat.c
+@@ -16,6 +16,7 @@
+ #include <unistd.h>
+ #include <errno.h>
+ #include <stdarg.h>
++#include <syslog.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <fcntl.h>
+@@ -31,23 +32,26 @@
+ 
+ static char unit_path[PATH_MAX];
+ static char target_path[PATH_MAX];
+-static char message[PATH_MAX];
++static char message[PATH_MAX + 3]; /* +3 for '<n>' where n is the log level */
+ static int kmsg_fd = -1;
+ 
+-__attribute__ ((format(printf, 1, 2)))
+-static void kmsg(const char *format, ...)
++__attribute__ ((format(printf, 2, 3)))
++static void kmsg(int log_level, const char *format, ...)
+ {
+ 	va_list ap;
+ 	int n;
+ 
++	snprintf(message, 4, "<%d>", log_level);
++
+ 	va_start(ap, format);
+-	n = vsnprintf(message, sizeof(message), format, ap);
++	n = vsnprintf(message + 3, PATH_MAX, format, ap);
+ 	va_end(ap);
+ 
+-	if (kmsg_fd < 0 || (n < 0 || ((unsigned) n + 1 > sizeof(message))))
++	if (kmsg_fd < 0 || (n < 0 || ((unsigned) n + 1 > PATH_MAX)))
+ 		return;
+ 
+-	(void) write(kmsg_fd, message, n + 1);
++	/* The n+4: +3 for "<n>" prefix and +1 for '\0' suffix */
++	(void) write(kmsg_fd, message, n + 4);
+ }
+ 
+ static int lvm_uses_lvmetad(void)
+@@ -56,7 +60,7 @@ static int lvm_uses_lvmetad(void)
+ 	int r;
+ 
+ 	if (!(lvm = lvm_init(NULL))) {
+-		kmsg("LVM: Failed to initialize library context for activation generator.\n");
++		kmsg(LOG_ERR, "LVM: Failed to initialize library context for activation generator.\n");
+ 		return 0;
+ 	}
+ 	r = lvm_config_find_bool(lvm, LVM_CONF_USE_LVMETAD, 0);
+@@ -74,7 +78,7 @@ static int register_unit_with_target(const char *dir, const char *unit, const ch
+ 	}
+ 	(void) dm_prepare_selinux_context(target_path, S_IFDIR);
+ 	if (mkdir(target_path, 0755) < 0 && errno != EEXIST) {
+-		kmsg("LVM: Failed to create target directory %s: %m.\n", target_path);
++		kmsg(LOG_ERR, "LVM: Failed to create target directory %s: %m.\n", target_path);
+ 		r = 0; goto out;
+ 	}
+ 
+@@ -83,7 +87,7 @@ static int register_unit_with_target(const char *dir, const char *unit, const ch
+ 	}
+ 	(void) dm_prepare_selinux_context(target_path, S_IFLNK);
+ 	if (symlink(unit_path, target_path) < 0) {
+-		kmsg("LVM: Failed to create symlink for unit %s: %m.\n", unit);
++		kmsg(LOG_ERR, "LVM: Failed to create symlink for unit %s: %m.\n", unit);
+ 		r = 0;
+ 	}
+ out:
+@@ -100,7 +104,7 @@ static int generate_unit(const char *dir, int early)
+ 		return 0;
+ 
+ 	if (!(f = fopen(unit_path, "wxe"))) {
+-		kmsg("LVM: Failed to create unit file %s: %m.\n", unit);
++		kmsg(LOG_ERR, "LVM: Failed to create unit file %s: %m.\n", unit);
+ 		return 0;
+ 	}
+ 
+@@ -129,12 +133,12 @@ static int generate_unit(const char *dir, int early)
+ 	      "Type=oneshot\n", f);
+ 
+ 	if (fclose(f) < 0) {
+-		kmsg("LVM: Failed to write unit file %s: %m.\n", unit);
++		kmsg(LOG_ERR, "LVM: Failed to write unit file %s: %m.\n", unit);
+ 		return 0;
+ 	}
+ 
+ 	if (!register_unit_with_target(dir, unit, UNIT_TARGET)) {
+-		kmsg("LVM: Failed to register unit %s with target %s.\n", unit, UNIT_TARGET);
++		kmsg(LOG_ERR, "LVM: Failed to register unit %s with target %s.\n", unit, UNIT_TARGET);
+ 		return 0;
+ 	}
+ 
+@@ -149,13 +153,13 @@ int main(int argc, char *argv[])
+ 	kmsg_fd = open(KMSG_DEV_PATH, O_WRONLY|O_NOCTTY);
+ 
+ 	if (argc > 1 && argc != 4) {
+-		kmsg("LVM: Activation generator takes three or no arguments.\n");
++		kmsg(LOG_ERR, "LVM: Activation generator takes three or no arguments.\n");
+ 		r = EXIT_FAILURE; goto out;
+ 	}
+ 
+ 	/* If lvmetad used, rely on autoactivation instead of direct activation. */
+ 	if (lvm_uses_lvmetad()) {
+-		kmsg("LVM: Logical Volume autoactivation enabled.\n");
++		kmsg(LOG_DEBUG, "LVM: Logical Volume autoactivation enabled.\n");
+ 		goto out;
+ 	}
+ 
+@@ -164,7 +168,8 @@ int main(int argc, char *argv[])
+ 	if (!generate_unit(dir, 1) || !generate_unit(dir, 0))
+ 		r = EXIT_FAILURE;
+ out:
+-	kmsg("LVM: Activation generator %s.\n", r ? "failed" : "successfully completed");
++	kmsg(r ? LOG_ERR : LOG_DEBUG, "LVM: Activation generator %s.\n",
++	     r ? "failed" : "successfully completed");
+ 	if (kmsg_fd != -1)
+ 		(void) close(kmsg_fd);
+ 	return r;
diff --git a/lvm2.spec b/lvm2.spec
index d17d125..8a223ea 100644
--- a/lvm2.spec
+++ b/lvm2.spec
@@ -71,6 +71,9 @@ Patch25: lvm2-2_02_99-add-dm-disable-udev-env-var-and-fix-noudevsync-arg.patch
 Patch26: lvm2-2_02_99-fix-premature-dm-version-checking-which-caused-useless-mapper-control-access.patch
 Patch27: lvm2-2_02_99-close-dmeventd-fifo-fds-on-exec.patch
 Patch28: lvm2-2_02_99-fix-dmsetup-splitname-to-not-fail-if-used-without-c-switch.patch
+Patch29: lvm2-2_02_99-use-log_debug_err-msg-severity-for-activation-generator.patch
+Patch30: lvm2-2_02_99-respect-global-filter-in-pvscan-cache-with-a-device.patch
+Patch31: lvm2-2_02_100-fix-segfault-if-global_filter-incorrect.patch
 
 BuildRequires: libselinux-devel >= %{libselinux_version}, libsepol-devel
 BuildRequires: ncurses-devel
@@ -134,6 +137,9 @@ or more physical volumes and creating one or more logical volumes
 %patch26 -p1 -b .premature_dm_version
 %patch27 -p1 -b .dmeventd_fd_cloexec
 %patch28 -p1 -b .dmsetup_splitname
+%patch29 -p1 -b .activation_generator_log
+%patch30 -p1 -b .pvscan_global_filter
+%patch31 -p1 -b .segfault_global_filter
 
 %build
 %define _default_pid_dir /run
@@ -627,8 +633,12 @@ the device-mapper event library.
 %{_libdir}/pkgconfig/devmapper-event.pc
 
 %changelog
-* Thu May 30 2013 Peter Rajnoha <prajnoha at redhat.com> - 2.02.98-10
+* Fri Jul 26 2013 Peter Rajnoha <prajnoha at redhat.com> - 2.02.98-10
+- Respect lvmetad global filter in pvscan --cache with a device.
+- Fix segfault if devices/global_filter is not specified correctly.
+- Use LOG_DEBUG/ERR msg severity instead default for lvm2-activation-generator.
 - Do not include /lib/udev and /lib/udev/rules.d in device-mapper package.
+- Fix some incorrect changelog dates.
 
 * Tue May 14 2013 Peter Rajnoha <prajnoha at redhat.com> - 2.02.98-9
 - Fix 'dmsetup splitname -o' to not fail if used without '-c' switch (1.02.68).
@@ -1036,7 +1046,7 @@ the device-mapper event library.
 - Add dm-event and lvm2-monitor unit files for use with systemd.
 - Add sysvinit subpackage for legacy SysV init script support.
 
-* Wed Jul 8 2011 Alasdair Kergon <agk at redhat.com> - 2.02.86-1
+* Fri Jul 8 2011 Alasdair Kergon <agk at redhat.com> - 2.02.86-1
 - Fix activation sequences to avoid trapped I/O with multiple LVs.
 - Fix activation sequences to avoid allocating tables while devs suspended.
 - Remove unnecessary warning in pvcreate for MD linear devices.
@@ -2203,7 +2213,7 @@ the device-mapper event library.
 - Modify lvremove to prompt for removal if LV active on other cluster nodes.
 - Add '-f' to vgremove to force removal of VG even if LVs exist.
 
-* Thu Aug 24 2007 Alasdair Kergon <agk at redhat.com> - 2.02.28-1
+* Fri Aug 24 2007 Alasdair Kergon <agk at redhat.com> - 2.02.28-1
 - vgscan and pvscan now trigger clvmd -R, which should now work.
 - Fix clvmd logging so you can get lvm-level debugging out of it.
 - Allow clvmd debug to be turned on in a running daemon using clvmd -d [-C].
@@ -2367,7 +2377,7 @@ the device-mapper event library.
 * Mon Nov 20 2006 Alasdair Kergon <agk at redhat.com> - 2.02.15-1
 - New upstream - see WHATS_NEW.
 
-* Fri Nov 11 2006 Alasdair Kergon <agk at redhat.com> - 2.02.14-1
+* Sat Nov 11 2006 Alasdair Kergon <agk at redhat.com> - 2.02.14-1
 - New upstream - see WHATS_NEW.
 
 * Mon Oct 30 2006 Alasdair Kergon <agk at redhat.com> - 2.02.13-2
@@ -2565,7 +2575,7 @@ the device-mapper event library.
 * Wed Sep 15 2004 Alasdair Kergon <agk at redhat.com> - 2.00.23-1
 - Various minor upstream fixes.
 
-* Thu Sep  3 2004 Alasdair Kergon <agk at redhat.com> - 2.00.22-1
+* Fri Sep  3 2004 Alasdair Kergon <agk at redhat.com> - 2.00.22-1
 - Permission fix included upstream; use different endian conversion macros.
 
 * Thu Sep  2 2004 Jeremy Katz <katzj at redhat.com> - 2.00.21-2


More information about the scm-commits mailing list