public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW ./WHATS_NEW_DM ./configure ./ ...
@ 2010-07-13 13:51 fabbione
  0 siblings, 0 replies; 2+ messages in thread
From: fabbione @ 2010-07-13 13:51 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	fabbione@sourceware.org	2010-07-13 13:51:03

Modified files:
	.              : WHATS_NEW WHATS_NEW_DM configure configure.in 
	daemons/clvmd  : clvmd.c 
	daemons/cmirrord: clogd.c 
	daemons/dmeventd: dmeventd.c dmeventd.h 
	lib/misc       : configure.h.in 
	libdm          : libdevmapper.h libdm-file.c 

Log message:
	Add dm_create_lockfile to libdm to handle pidfiles for all daemons.
	Switch dmeventd to use dm_create_lockfile and drop duplicate code.
	Allow clvmd pidfile to be configurable.
	Switch cmirrord and clvmd to use dm_create_lockfile.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1665&r2=1.1666
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.394&r2=1.395
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.diff?cvsroot=lvm2&r1=1.134&r2=1.135
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.in.diff?cvsroot=lvm2&r1=1.145&r2=1.146
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.72&r2=1.73
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/cmirrord/clogd.c.diff?cvsroot=lvm2&r1=1.11&r2=1.12
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/dmeventd.c.diff?cvsroot=lvm2&r1=1.63&r2=1.64
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/dmeventd.h.diff?cvsroot=lvm2&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/configure.h.in.diff?cvsroot=lvm2&r1=1.24&r2=1.25
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.h.diff?cvsroot=lvm2&r1=1.120&r2=1.121
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-file.c.diff?cvsroot=lvm2&r1=1.10&r2=1.11

--- LVM2/WHATS_NEW	2010/07/12 18:12:23	1.1665
+++ LVM2/WHATS_NEW	2010/07/13 13:51:01	1.1666
@@ -1,5 +1,7 @@
 Version 2.02.71 -
 ===============================
+  Switch cmirrord and clvmd to use dm_create_lockfile.
+  Allow clvmd pidfile to be configurable.
   Update comments about memory handling in lvm2app.h.
   Add more verbose messages while checking volume_list and hosttags settings.
   Add log_error when strdup fails in {vg|lv}_change_tag().
--- LVM2/WHATS_NEW_DM	2010/07/08 14:29:26	1.394
+++ LVM2/WHATS_NEW_DM	2010/07/13 13:51:01	1.395
@@ -1,5 +1,7 @@
 Version 1.02.53 -
 ===============================
+  Switch dmeventd to use dm_create_lockfile and drop duplicate code.
+  Add dm_create_lockfile to libdm to handle pidfiles for all daemons.
   Use "nowatch" udev rule for inappropriate devices.
 
 Version 1.02.52 - 6th July 2010
--- LVM2/configure	2010/07/08 12:02:48	1.134
+++ LVM2/configure	2010/07/13 13:51:01	1.135
@@ -736,8 +736,6 @@
 CCS_CFLAGS
 PKGCONFIGINIT_LIBS
 PKGCONFIGINIT_CFLAGS
-PKG_CONFIG_LIBDIR
-PKG_CONFIG_PATH
 PKG_CONFIG
 POW_LIB
 LIBOBJS
@@ -831,6 +829,7 @@
 enable_readline
 enable_realtime
 with_clvmd
+with_clvmd_pidfile
 enable_cmirrord
 with_cmirrord_pidfile
 enable_debug
@@ -877,8 +876,6 @@
 CPPFLAGS
 CPP
 PKG_CONFIG
-PKG_CONFIG_PATH
-PKG_CONFIG_LIBDIR
 PKGCONFIGINIT_CFLAGS
 PKGCONFIGINIT_LIBS
 CCS_CFLAGS
@@ -1580,6 +1577,8 @@
                            * all                   (autodetect)
                            * none                  (disable build)
                           [TYPE=none]
+  --with-clvmd-pidfile=PATH
+                          clvmd pidfile [/var/run/clvmd.pid]
   --with-cmirrord-pidfile=PATH
                           cmirrord pidfile [/var/run/cmirrord.pid]
   --with-optimisation=OPT C optimisation flag [OPT=-O2]
@@ -1617,10 +1616,6 @@
               you have headers in a nonstandard directory <include dir>
   CPP         C preprocessor
   PKG_CONFIG  path to pkg-config utility
-  PKG_CONFIG_PATH
-              directories to add to pkg-config's search path
-  PKG_CONFIG_LIBDIR
-              path overriding pkg-config's built-in search path
   PKGCONFIGINIT_CFLAGS
               C compiler flags for PKGCONFIGINIT, overriding pkg-config
   PKGCONFIGINIT_LIBS
@@ -11415,10 +11410,6 @@
 pkg_config_init() {
 
 
-
-
-
-
 if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
 	if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
@@ -11531,6 +11522,7 @@
 $as_echo "no" >&6; }
 		PKG_CONFIG=""
 	fi
+
 fi
 
 pkg_failed=no
@@ -11573,8 +11565,6 @@
 
 
 if test $pkg_failed = yes; then
-   	{ $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
 
 if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
         _pkg_short_errors_supported=yes
@@ -11589,11 +11579,11 @@
 	# Put the nasty error message in config.log where it belongs
 	echo "$PKGCONFIGINIT_PKG_ERRORS" >&5
 
-	{ $as_echo "$as_me:$LINENO: result: pkg-config initialized" >&5
+	{ $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+                { $as_echo "$as_me:$LINENO: result: pkg-config initialized" >&5
 $as_echo "pkg-config initialized" >&6; }
 elif test $pkg_failed = untried; then
-     	{ $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
 	{ $as_echo "$as_me:$LINENO: result: pkg-config initialized" >&5
 $as_echo "pkg-config initialized" >&6; }
 else
@@ -11601,7 +11591,7 @@
 	PKGCONFIGINIT_LIBS=$pkg_cv_PKGCONFIGINIT_LIBS
         { $as_echo "$as_me:$LINENO: result: yes" >&5
 $as_echo "yes" >&6; }
-
+	:
 fi
 	PKGCONFIG_INIT=1
 }
@@ -11807,8 +11797,6 @@
 
 
 if test $pkg_failed = yes; then
-   	{ $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
 
 if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
         _pkg_short_errors_supported=yes
@@ -11823,7 +11811,9 @@
 	# Put the nasty error message in config.log where it belongs
 	echo "$CCS_PKG_ERRORS" >&5
 
-	NOTFOUND=0
+	{ $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+                NOTFOUND=0
 
 for ac_header in ccs.h
 do
@@ -11980,8 +11970,6 @@
 			HAVE_CCS=yes
 		fi
 elif test $pkg_failed = untried; then
-     	{ $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
 	NOTFOUND=0
 
 for ac_header in ccs.h
@@ -12186,8 +12174,6 @@
 
 
 if test $pkg_failed = yes; then
-   	{ $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
 
 if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
         _pkg_short_errors_supported=yes
@@ -12202,7 +12188,9 @@
 	# Put the nasty error message in config.log where it belongs
 	echo "$GULM_PKG_ERRORS" >&5
 
-	NOTFOUND=0
+	{ $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+                NOTFOUND=0
 
 for ac_header in libgulm.h
 do
@@ -12359,8 +12347,6 @@
 			HAVE_GULM=yes
 		fi
 elif test $pkg_failed = untried; then
-     	{ $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
 	NOTFOUND=0
 
 for ac_header in libgulm.h
@@ -12568,8 +12554,6 @@
 
 
 if test $pkg_failed = yes; then
-   	{ $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
 
 if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
         _pkg_short_errors_supported=yes
@@ -12584,7 +12568,9 @@
 	# Put the nasty error message in config.log where it belongs
 	echo "$CMAN_PKG_ERRORS" >&5
 
-	NOTFOUND=0
+	{ $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+                NOTFOUND=0
 
 for ac_header in libcman.h
 do
@@ -12741,8 +12727,6 @@
 			HAVE_CMAN=yes
 		fi
 elif test $pkg_failed = untried; then
-     	{ $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
 	NOTFOUND=0
 
 for ac_header in libcman.h
@@ -12953,8 +12937,6 @@
 
 
 if test $pkg_failed = yes; then
-   	{ $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
 
 if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
         _pkg_short_errors_supported=yes
@@ -12969,10 +12951,10 @@
 	# Put the nasty error message in config.log where it belongs
 	echo "$COROSYNC_PKG_ERRORS" >&5
 
-	$bailout
-elif test $pkg_failed = untried; then
-     	{ $as_echo "$as_me:$LINENO: result: no" >&5
+	{ $as_echo "$as_me:$LINENO: result: no" >&5
 $as_echo "no" >&6; }
+                $bailout
+elif test $pkg_failed = untried; then
 	$bailout
 else
 	COROSYNC_CFLAGS=$pkg_cv_COROSYNC_CFLAGS
@@ -13026,8 +13008,6 @@
 
 
 if test $pkg_failed = yes; then
-   	{ $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
 
 if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
         _pkg_short_errors_supported=yes
@@ -13042,10 +13022,10 @@
 	# Put the nasty error message in config.log where it belongs
 	echo "$QUORUM_PKG_ERRORS" >&5
 
-	$bailout
-elif test $pkg_failed = untried; then
-     	{ $as_echo "$as_me:$LINENO: result: no" >&5
+	{ $as_echo "$as_me:$LINENO: result: no" >&5
 $as_echo "no" >&6; }
+                $bailout
+elif test $pkg_failed = untried; then
 	$bailout
 else
 	QUORUM_CFLAGS=$pkg_cv_QUORUM_CFLAGS
@@ -13100,8 +13080,6 @@
 
 
 if test $pkg_failed = yes; then
-   	{ $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
 
 if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
         _pkg_short_errors_supported=yes
@@ -13116,10 +13094,10 @@
 	# Put the nasty error message in config.log where it belongs
 	echo "$SALCK_PKG_ERRORS" >&5
 
-	$bailout
-elif test $pkg_failed = untried; then
-     	{ $as_echo "$as_me:$LINENO: result: no" >&5
+	{ $as_echo "$as_me:$LINENO: result: no" >&5
 $as_echo "no" >&6; }
+                $bailout
+elif test $pkg_failed = untried; then
 	$bailout
 else
 	SALCK_CFLAGS=$pkg_cv_SALCK_CFLAGS
@@ -13175,8 +13153,6 @@
 
 
 if test $pkg_failed = yes; then
-   	{ $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
 
 if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
         _pkg_short_errors_supported=yes
@@ -13191,10 +13167,10 @@
 	# Put the nasty error message in config.log where it belongs
 	echo "$CONFDB_PKG_ERRORS" >&5
 
-	HAVE_CONFDB=no
-elif test $pkg_failed = untried; then
-     	{ $as_echo "$as_me:$LINENO: result: no" >&5
+	{ $as_echo "$as_me:$LINENO: result: no" >&5
 $as_echo "no" >&6; }
+                HAVE_CONFDB=no
+elif test $pkg_failed = untried; then
 	HAVE_CONFDB=no
 else
 	CONFDB_CFLAGS=$pkg_cv_CONFDB_CFLAGS
@@ -13413,8 +13389,6 @@
 
 
 if test $pkg_failed = yes; then
-   	{ $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
 
 if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
         _pkg_short_errors_supported=yes
@@ -13429,10 +13403,10 @@
 	# Put the nasty error message in config.log where it belongs
 	echo "$CPG_PKG_ERRORS" >&5
 
-	$bailout
-elif test $pkg_failed = untried; then
-     	{ $as_echo "$as_me:$LINENO: result: no" >&5
+	{ $as_echo "$as_me:$LINENO: result: no" >&5
 $as_echo "no" >&6; }
+                $bailout
+elif test $pkg_failed = untried; then
 	$bailout
 else
 	CPG_CFLAGS=$pkg_cv_CPG_CFLAGS
@@ -13485,8 +13459,6 @@
 
 
 if test $pkg_failed = yes; then
-   	{ $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
 
 if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
         _pkg_short_errors_supported=yes
@@ -13501,7 +13473,9 @@
 	# Put the nasty error message in config.log where it belongs
 	echo "$DLM_PKG_ERRORS" >&5
 
-	NOTFOUND=0
+	{ $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+                NOTFOUND=0
 
 for ac_header in libdlm.h
 do
@@ -13658,8 +13632,6 @@
 			HAVE_DLM=yes
 		fi
 elif test $pkg_failed = untried; then
-     	{ $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
 	NOTFOUND=0
 
 for ac_header in libdlm.h
@@ -13862,6 +13834,23 @@
 fi
 
 ################################################################################
+if test "x$CLVMD" != xnone; then
+
+# Check whether --with-clvmd-pidfile was given.
+if test "${with_clvmd_pidfile+set}" = set; then
+  withval=$with_clvmd_pidfile; CLVMD_PIDFILE=$withval
+else
+  CLVMD_PIDFILE="/var/run/clvmd.pid"
+fi
+
+
+cat >>confdefs.h <<_ACEOF
+#define CLVMD_PIDFILE "$CLVMD_PIDFILE"
+_ACEOF
+
+fi
+
+################################################################################
 { $as_echo "$as_me:$LINENO: checking whether to build cluster mirror log daemon" >&5
 $as_echo_n "checking whether to build cluster mirror log daemon... " >&6; }
 # Check whether --enable-cmirrord was given.
@@ -13939,8 +13928,6 @@
 
 
 if test $pkg_failed = yes; then
-   	{ $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
 
 if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
         _pkg_short_errors_supported=yes
@@ -13964,7 +13951,8 @@
 
 Alternatively, you may set the environment variables SACKPT_CFLAGS
 and SACKPT_LIBS to avoid the need to call pkg-config.
-See the pkg-config man page for more details." >&5
+See the pkg-config man page for more details.
+" >&5
 $as_echo "$as_me: error: Package requirements (libSaCkpt) were not met:
 
 $SACKPT_PKG_ERRORS
@@ -13974,11 +13962,10 @@
 
 Alternatively, you may set the environment variables SACKPT_CFLAGS
 and SACKPT_LIBS to avoid the need to call pkg-config.
-See the pkg-config man page for more details." >&2;}
+See the pkg-config man page for more details.
+" >&2;}
    { (exit 1); exit 1; }; }
 elif test $pkg_failed = untried; then
-     	{ $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
 	{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
 { { $as_echo "$as_me:$LINENO: error: The pkg-config script could not be found or is too old.  Make sure it
@@ -14007,7 +13994,7 @@
 	SACKPT_LIBS=$pkg_cv_SACKPT_LIBS
         { $as_echo "$as_me:$LINENO: result: yes" >&5
 $as_echo "yes" >&6; }
-
+	:
 fi
 	if test x$HAVE_CPG != xyes; then
 
@@ -14051,8 +14038,6 @@
 
 
 if test $pkg_failed = yes; then
-   	{ $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
 
 if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
         _pkg_short_errors_supported=yes
@@ -14076,7 +14061,8 @@
 
 Alternatively, you may set the environment variables CPG_CFLAGS
 and CPG_LIBS to avoid the need to call pkg-config.
-See the pkg-config man page for more details." >&5
+See the pkg-config man page for more details.
+" >&5
 $as_echo "$as_me: error: Package requirements (libcpg) were not met:
 
 $CPG_PKG_ERRORS
@@ -14086,11 +14072,10 @@
 
 Alternatively, you may set the environment variables CPG_CFLAGS
 and CPG_LIBS to avoid the need to call pkg-config.
-See the pkg-config man page for more details." >&2;}
+See the pkg-config man page for more details.
+" >&2;}
    { (exit 1); exit 1; }; }
 elif test $pkg_failed = untried; then
-     	{ $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
 	{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
 { { $as_echo "$as_me:$LINENO: error: The pkg-config script could not be found or is too old.  Make sure it
@@ -14119,7 +14104,7 @@
 	CPG_LIBS=$pkg_cv_CPG_LIBS
         { $as_echo "$as_me:$LINENO: result: yes" >&5
 $as_echo "yes" >&6; }
-
+	:
 fi
 	fi
 fi
--- LVM2/configure.in	2010/07/08 12:02:48	1.145
+++ LVM2/configure.in	2010/07/13 13:51:01	1.146
@@ -601,6 +601,18 @@
 fi
 
 ################################################################################
+dnl -- clvmd pidfile
+if test "x$CLVMD" != xnone; then
+	AC_ARG_WITH(clvmd-pidfile,
+		    AC_HELP_STRING([--with-clvmd-pidfile=PATH],
+				   [clvmd pidfile [[/var/run/clvmd.pid]]]),
+		    CLVMD_PIDFILE=$withval,
+		    CLVMD_PIDFILE="/var/run/clvmd.pid")
+	AC_DEFINE_UNQUOTED(CLVMD_PIDFILE, ["$CLVMD_PIDFILE"],
+			   [Path to clvmd pidfile.])
+fi
+
+################################################################################
 dnl -- Build cluster mirror log daemon
 AC_MSG_CHECKING(whether to build cluster mirror log daemon)
 AC_ARG_ENABLE(cmirrord,
--- LVM2/daemons/clvmd/clvmd.c	2010/06/21 15:56:58	1.72
+++ LVM2/daemons/clvmd/clvmd.c	2010/07/13 13:51:02	1.73
@@ -271,6 +271,11 @@
 	return buf;
 }
 
+static void remove_lockfile(void)
+{
+	unlink(CLVMD_PIDFILE);
+}
+
 int main(int argc, char *argv[])
 {
 	int local_sock;
@@ -370,6 +375,14 @@
 		be_daemon(start_timeout);
 	}
 
+	/* Create pidfile */
+	if (dm_create_lockfile(CLVMD_PIDFILE) == 0) {
+		DEBUGLOG("clvmd: unable to create lockfile\n");
+		exit(1);
+	}
+
+	atexit(remove_lockfile);
+
 	DEBUGLOG("CLVMD started\n");
 
 	/* Open the Unix socket we listen for commands on.
--- LVM2/daemons/cmirrord/clogd.c	2010/07/09 15:34:40	1.11
+++ LVM2/daemons/cmirrord/clogd.c	2010/07/13 13:51:02	1.12
@@ -65,49 +65,6 @@
 	exit_now = 1;
 }
 
-/*
- * create_lockfile - create and lock a lock file
- * @lockfile: location of lock file
- *
- * Returns: 0 on success, -1 otherwise
- */
-static int create_lockfile(const char *lockfile)
-{
-	int fd;
-	struct flock lock;
-	char buffer[50];
-
-	if((fd = open(lockfile, O_CREAT | O_WRONLY,
-		      (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH))) < 0)
-		return -errno;
-
-	lock.l_type = F_WRLCK;
-	lock.l_start = 0;
-	lock.l_whence = SEEK_SET;
-	lock.l_len = 0;
-
-	if (fcntl(fd, F_SETLK, &lock) < 0) {
-		close(fd);
-		return -errno;
-	}
-
-	if (ftruncate(fd, 0) < 0) {
-		close(fd);
-		return -errno;
-	}
-
-	sprintf(buffer, "%d\n", getpid());
-
-	/* FIXME Handle other non-error returns without aborting */
-	if (write(fd, buffer, strlen(buffer)) < strlen(buffer)){
-		close(fd);
-		unlink(lockfile);
-		return -errno;
-	}
-
-	return 0;
-}
-
 static void sig_handler(int sig)
 {
 	/* FIXME Races - don't touch signal_mask here. */
@@ -162,6 +119,11 @@
 	}
 }
 
+static void remove_lockfile(void)
+{
+	unlink(CMIRRORD_PIDFILE);
+}
+
 /*
  * daemonize
  *
@@ -226,9 +188,11 @@
 
 	LOG_OPEN("cmirrord", LOG_PID, LOG_DAEMON);
 
-	if (create_lockfile(CMIRRORD_PIDFILE))
+	if (dm_create_lockfile(CMIRRORD_PIDFILE) == 0)
 		exit(EXIT_LOCKFILE);
 
+	atexit(remove_lockfile);
+
 	/* FIXME Replace with sigaction. (deprecated) */
 	signal(SIGINT, &sig_handler);
 	signal(SIGQUIT, &sig_handler);
--- LVM2/daemons/dmeventd/dmeventd.c	2010/07/09 15:34:41	1.63
+++ LVM2/daemons/dmeventd/dmeventd.c	2010/07/13 13:51:02	1.64
@@ -394,26 +394,6 @@
 	return pthread_mutex_unlock(&_global_mutex);
 }
 
-/* Store pid in pidfile. */
-static int _storepid(int lf)
-{
-	int len;
-	char pid[8];
-
-	if ((len = snprintf(pid, sizeof(pid), "%u\n", getpid())) < 0)
-		return 0;
-
-	if (len > (int) sizeof(pid))
-		len = (int) sizeof(pid);
-
-	if (write(lf, pid, (size_t) len) != len)
-		return 0;
-
-	fsync(lf);
-
-	return 1;
-}
-
 /* Check, if a device exists. */
 static int _fill_device_data(struct thread_status *ts)
 {
@@ -1541,23 +1521,6 @@
 
 }
 
-static int _lock_pidfile(void)
-{
-	int lf;
-	char pidfile[] = DMEVENTD_PIDFILE;
-
-	if ((lf = open(pidfile, O_CREAT | O_RDWR, 0644)) < 0)
-		exit(EXIT_OPEN_PID_FAILURE);
-
-	if (flock(lf, LOCK_EX | LOCK_NB) < 0)
-		exit(EXIT_LOCKFILE_INUSE);
-
-	if (!_storepid(lf))
-		exit(EXIT_FAILURE);
-
-	return 0;
-}
-
 #ifdef linux
 /*
  * Protection against OOM killer if kernel supports it
@@ -1589,6 +1552,11 @@
 }
 #endif
 
+static void remove_lockfile(void)
+{
+	unlink(DMEVENTD_PIDFILE);
+}
+
 static void _daemonize(void)
 {
 	int child_status;
@@ -1626,12 +1594,8 @@
 
 		/* Problem with child.  Determine what it is by exit code */
 		switch (WEXITSTATUS(child_status)) {
-		case EXIT_LOCKFILE_INUSE:
-			fprintf(stderr, "Another dmeventd daemon is already running\n");
-			break;
 		case EXIT_DESC_CLOSE_FAILURE:
 		case EXIT_DESC_OPEN_FAILURE:
-		case EXIT_OPEN_PID_FAILURE:
 		case EXIT_FIFO_FAILURE:
 		case EXIT_CHDIR_FAILURE:
 		default:
@@ -1717,7 +1681,10 @@
 
 	openlog("dmeventd", LOG_PID, LOG_DAEMON);
 
-	_lock_pidfile();		/* exits if failure */
+	if (dm_create_lockfile(DMEVENTD_PIDFILE) == 0)
+		exit(EXIT_FAILURE);
+
+	atexit(remove_lockfile);
 
 	/* Set the rest of the signals to cause '_exit_now' to be set */
 	signal(SIGINT, &_exit_handler);
--- LVM2/daemons/dmeventd/dmeventd.h	2007/08/21 16:26:06	1.5
+++ LVM2/daemons/dmeventd/dmeventd.h	2010/07/13 13:51:02	1.6
@@ -56,10 +56,10 @@
 
 /*      EXIT_SUCCESS             0 -- stdlib.h */
 /*      EXIT_FAILURE             1 -- stdlib.h */
-#define EXIT_LOCKFILE_INUSE      2
+/*      EXIT_LOCKFILE_INUSE      2 -- obsoleted */
 #define EXIT_DESC_CLOSE_FAILURE  3
 #define EXIT_DESC_OPEN_FAILURE   4
-#define EXIT_OPEN_PID_FAILURE    5
+/*      EXIT_OPEN_PID_FAILURE    5 -- obsoleted */
 #define EXIT_FIFO_FAILURE        6
 #define EXIT_CHDIR_FAILURE       7
 
--- LVM2/lib/misc/configure.h.in	2010/07/05 22:23:15	1.24
+++ LVM2/lib/misc/configure.h.in	2010/07/13 13:51:03	1.25
@@ -9,6 +9,9 @@
 /* Path to clvmd binary. */
 #undef CLVMD_PATH
 
+/* Path to clvmd pidfile. */
+#undef CLVMD_PIDFILE
+
 /* Path to cmirrord pidfile. */
 #undef CMIRRORD_PIDFILE
 
--- LVM2/libdm/libdevmapper.h	2010/07/09 15:34:47	1.120
+++ LVM2/libdm/libdevmapper.h	2010/07/13 13:51:03	1.121
@@ -980,6 +980,14 @@
 int dm_asprintf(char **buf, const char *format, ...)
     __attribute__ ((format(printf, 2, 3)));
 
+/*
+ * create lockfile (pidfile) - create and lock a lock file
+ * @lockfile: location of lock file
+ *
+ * Returns: 1 on success, 0 otherwise, errno is handled internally
+ */
+int dm_create_lockfile(const char* lockfile);
+
 /*********************
  * regular expressions
  *********************/
--- LVM2/libdm/libdm-file.c	2008/11/03 18:59:59	1.10
+++ LVM2/libdm/libdm-file.c	2010/07/13 13:51:03	1.11
@@ -84,3 +84,85 @@
 
 	return prev_fail || fclose_fail ? EOF : 0;
 }
+
+int dm_create_lockfile(const char *lockfile)
+{
+	int fd, value;
+	size_t bufferlen;
+	ssize_t write_out;
+	struct flock lock;
+	char buffer[50];
+
+	if((fd = open(lockfile, O_CREAT | O_WRONLY,
+		      (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH))) < 0) {
+		log_error("Cannot open lockfile [%s], error was [%s]",
+			  lockfile, strerror(errno));
+		return 0;
+	}
+
+	lock.l_type = F_WRLCK;
+	lock.l_start = 0;
+	lock.l_whence = SEEK_SET;
+	lock.l_len = 0;
+	if (fcntl(fd, F_SETLK, &lock) < 0) {
+		if (errno != EACCES && errno != EAGAIN)
+			log_error("Cannot lock lockfile [%s], error was [%s]",
+				   lockfile, strerror(errno));
+		else
+			log_error("process is already running");
+
+		goto fail;
+	}
+
+	if (ftruncate(fd, 0) < 0) {
+		log_error("Cannot truncate pidfile [%s], error was [%s]",
+			  lockfile, strerror(errno));
+
+		goto fail;
+	}
+
+	memset(buffer, 0, sizeof(buffer));
+	snprintf(buffer, sizeof(buffer)-1, "%u\n", getpid());
+
+	bufferlen = strlen(buffer);
+	write_out = write(fd, buffer, bufferlen);
+
+	if ((write_out < 0) || (write_out == 0 && errno)) {
+		log_error("Cannot write pid to pidfile [%s], error was [%s]",
+			  lockfile, strerror(errno));
+
+		goto fail;
+	}
+
+	if ((write_out == 0) || (write_out < bufferlen)) {
+		log_error("Cannot write pid to pidfile [%s], shortwrite of"
+			  "[%" PRIsize_t "] bytes, expected [%" PRIsize_t "]\n",
+			  lockfile, write_out, bufferlen);
+
+		goto fail;
+	}
+
+	if ((value = fcntl(fd, F_GETFD, 0)) < 0) {
+		log_error("Cannot get close-on-exec flag from pidfile [%s], "
+			  "error was [%s]", lockfile, strerror(errno));
+
+		goto fail;
+	}
+	value |= FD_CLOEXEC;
+	if (fcntl(fd, F_SETFD, value) < 0) {
+		log_error("Cannot set close-on-exec flag from pidfile [%s], "
+			  "error was [%s]", lockfile, strerror(errno));
+
+		goto fail;
+	}
+
+	return 1;
+
+fail:
+	if (close(fd))
+		stack;
+	if (unlink(lockfile))
+		stack;
+
+	return 0;
+}


^ permalink raw reply	[flat|nested] 2+ messages in thread

* LVM2 ./WHATS_NEW ./WHATS_NEW_DM ./configure ./ ...
@ 2010-08-16 22:54 agk
  0 siblings, 0 replies; 2+ messages in thread
From: agk @ 2010-08-16 22:54 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2010-08-16 22:54:37

Modified files:
	.              : WHATS_NEW WHATS_NEW_DM configure configure.in 
	daemons/dmeventd: .exported_symbols Makefile.in 
	                  libdevmapper-event.c libdevmapper-event.h 
	doc            : example.conf.in 
	lib/activate   : activate.c activate.h 
	lib/config     : defaults.h 
	lib/mirror     : mirrored.c 
	lib/misc       : configure.h.in 
	lib/snapshot   : snapshot.c 
	tools          : lvchange.c vgchange.c 

Log message:
	Various small cleanups and fixes related to monitoring.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1703&r2=1.1704
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.409&r2=1.410
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.diff?cvsroot=lvm2&r1=1.138&r2=1.139
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.in.diff?cvsroot=lvm2&r1=1.152&r2=1.153
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/.exported_symbols.diff?cvsroot=lvm2&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/Makefile.in.diff?cvsroot=lvm2&r1=1.44&r2=1.45
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/libdevmapper-event.c.diff?cvsroot=lvm2&r1=1.33&r2=1.34
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/libdevmapper-event.h.diff?cvsroot=lvm2&r1=1.14&r2=1.15
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/example.conf.in.diff?cvsroot=lvm2&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.173&r2=1.174
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.h.diff?cvsroot=lvm2&r1=1.68&r2=1.69
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/defaults.h.diff?cvsroot=lvm2&r1=1.65&r2=1.66
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mirror/mirrored.c.diff?cvsroot=lvm2&r1=1.75&r2=1.76
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/configure.h.in.diff?cvsroot=lvm2&r1=1.26&r2=1.27
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/snapshot/snapshot.c.diff?cvsroot=lvm2&r1=1.47&r2=1.48
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvchange.c.diff?cvsroot=lvm2&r1=1.122&r2=1.123
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgchange.c.diff?cvsroot=lvm2&r1=1.110&r2=1.111

--- LVM2/WHATS_NEW	2010/08/16 18:02:14	1.1703
+++ LVM2/WHATS_NEW	2010/08/16 22:54:35	1.1704
@@ -1,5 +1,8 @@
 Version 2.02.73 - 
 ================================
+  Fix some exit statuses when starting/stopping monitoring fails.
+  Enable snapshot monitoring by default when dmeventd is enabled.
+  Move cloned libdevmapper-event client code from segments into lib/activate.
   Fix 'lvconvert --splitmirrors' in cluster operation.
   Fix clvmd init script exit code when executed as non-root user.
   Change default alignment of pe_start to 1MB.
--- LVM2/WHATS_NEW_DM	2010/08/16 18:19:46	1.409
+++ LVM2/WHATS_NEW_DM	2010/08/16 22:54:35	1.410
@@ -1,5 +1,8 @@
 Version 1.02.54 - 
 ================================
+  Add dmeventd/executable to lvm.conf to test alternative dmeventd.
+  Export dm_event_handler_set_dmeventd_path to override built-in dmeventd path.
+  Generate libdevmapper-event exported symbols.
   Remove superfluous NULL pointer tests before dm_free from dmeventd.
   Assume dm-mod autoloading support is in kernel 2.6.36 and higher, not 2.6.35.
   Fix udev rules to support udev database content generated by older rules.
--- LVM2/configure	2010/07/31 00:43:41	1.138
+++ LVM2/configure	2010/08/16 22:54:35	1.139
@@ -688,6 +688,7 @@
 DM_DEVICE_MODE
 DM_DEVICE_GID
 DM_COMPAT
+DMEVENTD_PATH
 DMEVENTD
 DL_LIBS
 DEVMAPPER
@@ -840,6 +841,7 @@
 with_optimisation
 enable_profiling
 enable_testing
+enable_valgrind_pool
 enable_devmapper
 enable_udev_sync
 enable_udev_rules
@@ -1538,6 +1540,7 @@
   --enable-debug          enable debugging
   --enable-profiling      gather gcov profiling data
   --enable-testing        enable testing targets in the makefile
+  --enable-valgrind-pool  enable valgrind awareness of pools
   --disable-devmapper     disable LVM2 device-mapper interaction
   --enable-udev_sync      enable synchronisation with udev processing
   --enable-udev_rules     install rule files needed for udev synchronisation
@@ -14407,6 +14410,177 @@
 fi
 
 ################################################################################
+{ $as_echo "$as_me:$LINENO: checking whether to enable valgrind awareness of pools" >&5
+$as_echo_n "checking whether to enable valgrind awareness of pools... " >&6; }
+# Check whether --enable-valgrind_pool was given.
+if test "${enable_valgrind_pool+set}" = set; then
+  enableval=$enable_valgrind_pool; VALGRIND_POOL=$enableval
+else
+  VALGRIND_POOL=no
+fi
+
+{ $as_echo "$as_me:$LINENO: result: $VALGRIND_POOL" >&5
+$as_echo "$VALGRIND_POOL" >&6; }
+
+if test "$VALGRIND_POOL" = yes; then
+
+for ac_header in valgrind/memcheck.h
+do
+as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
+$as_echo_n "checking for $ac_header... " >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  $as_echo_n "(cached) " >&6
+fi
+ac_res=`eval 'as_val=${'$as_ac_Header'}
+		 $as_echo "$as_val"'`
+	       { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
+$as_echo_n "checking $ac_header usability... " >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
+$as_echo_n "checking $ac_header presence... " >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+
+    ;;
+esac
+{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
+$as_echo_n "checking for $ac_header... " >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  $as_echo_n "(cached) " >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval 'as_val=${'$as_ac_Header'}
+		 $as_echo "$as_val"'`
+	       { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+
+fi
+as_val=`eval 'as_val=${'$as_ac_Header'}
+		 $as_echo "$as_val"'`
+   if test "x$as_val" = x""yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+else
+  { { $as_echo "$as_me:$LINENO: error: bailing out" >&5
+$as_echo "$as_me: error: bailing out" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+done
+
+
+cat >>confdefs.h <<\_ACEOF
+#define VALGRIND_POOL 1
+_ACEOF
+
+fi
+
+################################################################################
 { $as_echo "$as_me:$LINENO: checking whether to use device-mapper" >&5
 $as_echo_n "checking whether to use device-mapper... " >&6; }
 # Check whether --enable-devmapper was given.
@@ -18045,8 +18219,9 @@
 
 
 
+
 ################################################################################
-ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile daemons/cmirrord/Makefile daemons/dmeventd/Makefile daemons/dmeventd/libdevmapper-event.pc daemons/dmeventd/plugins/Makefile daemons/dmeventd/plugins/lvm2/Makefile daemons/dmeventd/plugins/mirror/Makefile daemons/dmeventd/plugins/snapshot/Makefile doc/Makefile doc/example.conf include/.symlinks include/Makefile lib/Makefile lib/format1/Makefile lib/format_pool/Makefile lib/locking/Makefile lib/mirror/Makefile lib/replicator/Makefile lib/misc/lvm-version.h lib/snapshot/Makefile libdm/Makefile libdm/libdevmapper.pc liblvm/Makefile liblvm/liblvm2app.pc man/Makefile po/Makefile scripts/clvmd_init_red_hat scripts/cmirrord_init_red_hat scripts/lvm2_monitoring_init_red_hat scripts/Makefile test/Makefile test/api/Makefile tools/Makefile udev/Makefile unit-tests/datastruct/Makefile unit-tests/regex/Makefile"
+ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile daemons/cmirrord/Makefile daemons/dmeventd/Makefile daemons/dmeventd/libdevmapper-event.pc daemons/dmeventd/plugins/Makefile daemons/dmeventd/plugins/lvm2/Makefile daemons/dmeventd/plugins/mirror/Makefile daemons/dmeventd/plugins/snapshot/Makefile doc/Makefile doc/example.conf include/.symlinks include/Makefile lib/Makefile lib/format1/Makefile lib/format_pool/Makefile lib/locking/Makefile lib/mirror/Makefile lib/replicator/Makefile lib/misc/lvm-version.h lib/snapshot/Makefile libdm/Makefile libdm/libdevmapper.pc liblvm/Makefile liblvm/liblvm2app.pc man/Makefile po/Makefile scripts/clvmd_init_red_hat scripts/cmirrord_init_red_hat scripts/lvm2_monitoring_init_red_hat scripts/Makefile test/Makefile test/api/Makefile tools/Makefile udev/Makefile unit-tests/datastruct/Makefile unit-tests/regex/Makefile unit-tests/mm/Makefile"
 
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
@@ -18684,6 +18859,7 @@
     "udev/Makefile") CONFIG_FILES="$CONFIG_FILES udev/Makefile" ;;
     "unit-tests/datastruct/Makefile") CONFIG_FILES="$CONFIG_FILES unit-tests/datastruct/Makefile" ;;
     "unit-tests/regex/Makefile") CONFIG_FILES="$CONFIG_FILES unit-tests/regex/Makefile" ;;
+    "unit-tests/mm/Makefile") CONFIG_FILES="$CONFIG_FILES unit-tests/mm/Makefile" ;;
 
   *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
 $as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
--- LVM2/configure.in	2010/08/09 10:56:01	1.152
+++ LVM2/configure.in	2010/08/16 22:54:35	1.153
@@ -1251,6 +1251,7 @@
 AC_SUBST(DLM_LIBS)
 AC_SUBST(DL_LIBS)
 AC_SUBST(DMEVENTD)
+AC_SUBST(DMEVENTD_PATH)
 AC_SUBST(DM_COMPAT)
 AC_SUBST(DM_DEVICE_GID)
 AC_SUBST(DM_DEVICE_MODE)
--- LVM2/daemons/dmeventd/.exported_symbols	2007/01/22 15:03:57	1.9
+++ LVM2/daemons/dmeventd/.exported_symbols	2010/08/16 22:54:36	1.10
@@ -1,19 +0,0 @@
-dm_event_handler_create
-dm_event_handler_destroy
-dm_event_handler_set_dso
-dm_event_handler_set_dev_name
-dm_event_handler_set_uuid
-dm_event_handler_set_major
-dm_event_handler_set_minor
-dm_event_handler_set_event_mask
-dm_event_handler_get_dso
-dm_event_handler_get_devname
-dm_event_handler_get_uuid
-dm_event_handler_get_major
-dm_event_handler_get_minor
-dm_event_handler_get_event_mask
-dm_event_register_handler
-dm_event_unregister_handler
-dm_event_get_registered_device
-dm_event_handler_set_timeout
-dm_event_handler_get_timeout
--- LVM2/daemons/dmeventd/Makefile.in	2010/05/14 13:36:56	1.44
+++ LVM2/daemons/dmeventd/Makefile.in	2010/08/16 22:54:36	1.45
@@ -48,6 +48,9 @@
 CFLOW_LIST_TARGET = $(LIB_NAME).cflow
 CFLOW_TARGET = dmeventd
 
+EXPORTED_HEADER = $(srcdir)/libdevmapper-event.h
+EXPORTED_FN_PREFIX = dm_event
+
 include $(top_builddir)/make.tmpl
 
 all: device-mapper
@@ -102,4 +105,4 @@
 
 install_device-mapper: install_include install_lib install_dmeventd
 
-DISTCLEAN_TARGETS += libdevmapper-event.pc
+DISTCLEAN_TARGETS += libdevmapper-event.pc .exported_symbols_generated
--- LVM2/daemons/dmeventd/libdevmapper-event.c	2010/08/16 18:19:46	1.33
+++ LVM2/daemons/dmeventd/libdevmapper-event.c	2010/08/16 22:54:36	1.34
@@ -35,6 +35,8 @@
 struct dm_event_handler {
 	char *dso;
 
+	char *dmeventd_path;
+
 	char *dev_name;
 
 	char *uuid;
@@ -60,6 +62,7 @@
 	if (!(dmevh = dm_malloc(sizeof(*dmevh))))
 		return NULL;
 
+	dmevh->dmeventd_path = NULL;
 	dmevh->dso = dmevh->dev_name = dmevh->uuid = NULL;
 	dmevh->major = dmevh->minor = 0;
 	dmevh->mask = 0;
@@ -72,9 +75,24 @@
 {
 	_dm_event_handler_clear_dev_info(dmevh);
 	dm_free(dmevh->dso);
+	dm_free(dmevh->dmeventd_path);
 	dm_free(dmevh);
 }
 
+int dm_event_handler_set_dmeventd_path(struct dm_event_handler *dmevh, const char *dmeventd_path)
+{
+	if (!dmeventd_path) /* noop */
+		return 0;
+
+	dm_free(dmevh->dmeventd_path);
+
+	dmevh->dmeventd_path = dm_strdup(dmeventd_path);
+	if (!dmevh->dmeventd_path)
+		return -ENOMEM;
+
+	return 0;
+}
+
 int dm_event_handler_set_dso(struct dm_event_handler *dmevh, const char *path)
 {
 	if (!path) /* noop */
@@ -387,13 +405,13 @@
  *
  * Returns: 1 on success, 0 otherwise
  */
-static int _start_daemon(struct dm_event_fifos *fifos)
+static int _start_daemon(char *dmeventd_path, struct dm_event_fifos *fifos)
 {
 	int pid, ret = 0;
 	int status;
 	struct stat statbuf;
-	char dmeventdpath[] = DMEVENTD_PATH; /* const type for execvp */
-	char * const args[] = { dmeventdpath, NULL };
+	char default_dmeventd_path[] = DMEVENTD_PATH;
+	char *args[] = { dmeventd_path ? : default_dmeventd_path, NULL };
 
 	if (stat(fifos->client_path, &statbuf))
 		goto start_server;
@@ -449,17 +467,19 @@
 }
 
 /* Initialize client. */
-static int _init_client(struct dm_event_fifos *fifos)
+static int _init_client(char *dmeventd_path, struct dm_event_fifos *fifos)
 {
 	/* FIXME? Is fifo the most suitable method? Why not share
 	   comms/daemon code with something else e.g. multipath? */
 
 	/* init fifos */
 	memset(fifos, 0, sizeof(*fifos));
+
+	/* FIXME Make these either configurable or depend directly on dmeventd_path */
 	fifos->client_path = DM_EVENT_FIFO_CLIENT;
 	fifos->server_path = DM_EVENT_FIFO_SERVER;
 
-	if (!_start_daemon(fifos)) {
+	if (!_start_daemon(dmeventd_path, fifos)) {
 		stack;
 		return 0;
 	}
@@ -544,14 +564,14 @@
 }
 
 /* Handle the event (de)registration call and return negative error codes. */
-static int _do_event(int cmd, struct dm_event_daemon_message *msg,
+static int _do_event(int cmd, char *dmeventd_path, struct dm_event_daemon_message *msg,
 		     const char *dso_name, const char *dev_name,
 		     enum dm_event_mask evmask, uint32_t timeout)
 {
 	int ret;
 	struct dm_event_fifos fifos;
 
-	if (!_init_client(&fifos)) {
+	if (!_init_client(dmeventd_path, &fifos)) {
 		stack;
 		return -ESRCH;
 	}
@@ -585,7 +605,7 @@
 
 	uuid = dm_task_get_uuid(dmt);
 
-	if ((err = _do_event(DM_EVENT_CMD_REGISTER_FOR_EVENT, &msg,
+	if ((err = _do_event(DM_EVENT_CMD_REGISTER_FOR_EVENT, dmevh->dmeventd_path, &msg,
 			     dmevh->dso, uuid, dmevh->mask, dmevh->timeout)) < 0) {
 		log_error("%s: event registration failed: %s",
 			  dm_task_get_name(dmt),
@@ -614,7 +634,7 @@
 
 	uuid = dm_task_get_uuid(dmt);
 
-	if ((err = _do_event(DM_EVENT_CMD_UNREGISTER_FOR_EVENT, &msg,
+	if ((err = _do_event(DM_EVENT_CMD_UNREGISTER_FOR_EVENT, dmevh->dmeventd_path, &msg,
 			    dmevh->dso, uuid, dmevh->mask, dmevh->timeout)) < 0) {
 		log_error("%s: event deregistration failed: %s",
 			  dm_task_get_name(dmt),
@@ -689,7 +709,7 @@
 	uuid = dm_task_get_uuid(dmt);
 
 	if (!(ret = _do_event(next ? DM_EVENT_CMD_GET_NEXT_REGISTERED_DEVICE :
-			     DM_EVENT_CMD_GET_REGISTERED_DEVICE,
+			     DM_EVENT_CMD_GET_REGISTERED_DEVICE, dmevh->dmeventd_path,
 			      &msg, dmevh->dso, uuid, dmevh->mask, 0))) {
 		/* FIXME this will probably horribly break if we get
 		   ill-formatted reply */
--- LVM2/daemons/dmeventd/libdevmapper-event.h	2007/08/21 16:26:06	1.14
+++ LVM2/daemons/dmeventd/libdevmapper-event.h	2010/08/16 22:54:36	1.15
@@ -55,13 +55,18 @@
 /*
  * Path of shared library to handle events.
  *
- * All of dso, device_name and uuid strings are duplicated, you do not
- * need to keep the pointers valid after the call succeeds. Thes may
- * return -ENOMEM though.
+ * All of dmeventd, dso, device_name and uuid strings are duplicated so
+ * you do not need to keep the pointers valid after the call succeeds.
+ * They may return -ENOMEM though.
  */
 int dm_event_handler_set_dso(struct dm_event_handler *dmevh, const char *path);
 
 /*
+ * Path of dmeventd binary.
+ */
+int dm_event_handler_set_dmeventd_path(struct dm_event_handler *dmevh, const char *dmeventd_path);
+
+/*
  * Identify the device to monitor by exactly one of device_name, uuid or
  * device number. String arguments are duplicated, see above.
  */
--- LVM2/doc/example.conf.in	2010/08/12 04:11:48	1.7
+++ LVM2/doc/example.conf.in	2010/08/16 22:54:36	1.8
@@ -509,9 +509,13 @@
     # snapshot_library is the library used when monitoring a snapshot device.
     #
     # "libdevmapper-event-lvm2snapshot.so" monitors the filling of
-    # snapshots and emits a warning through syslog, when the use of
-    # snapshot exceedes 80%. The warning is repeated when 85%, 90% and
-    # 95% of the snapshot are filled.
+    # snapshots and emits a warning through syslog when the use of
+    # the snapshot exceeds 80%. The warning is repeated when 85%, 90% and
+    # 95% of the snapshot is filled.
 
     snapshot_library = "libdevmapper-event-lvm2snapshot.so"
+
+    # Full path of the dmeventd binary.
+    #
+    # executable = "@DMEVENTD_PATH@"
 }
--- LVM2/lib/activate/activate.c	2010/07/12 12:38:35	1.173
+++ LVM2/lib/activate/activate.c	2010/08/16 22:54:36	1.174
@@ -28,6 +28,7 @@
 #include "config.h"
 #include "filter.h"
 #include "segtype.h"
+#include "sharedlib.h"
 
 #include <limits.h>
 #include <fcntl.h>
@@ -727,6 +728,112 @@
 	return 1;
 }
 
+#ifdef DMEVENTD
+static struct dm_event_handler *_create_dm_event_handler(struct cmd_context *cmd, const char *dmuuid, const char *dso,
+							 const int timeout, enum dm_event_mask mask)
+{
+	struct dm_event_handler *dmevh;
+
+	if (!(dmevh = dm_event_handler_create()))
+		return_NULL;
+
+	if (dm_event_handler_set_dmeventd_path(dmevh, find_config_tree_str(cmd, "dmeventd/executable", NULL)))
+		goto_bad;
+
+	if (dm_event_handler_set_dso(dmevh, dso))
+		goto_bad;
+
+	if (dm_event_handler_set_uuid(dmevh, dmuuid))
+		goto_bad;
+
+	dm_event_handler_set_timeout(dmevh, timeout);
+	dm_event_handler_set_event_mask(dmevh, mask);
+
+	return dmevh;
+
+bad:
+	dm_event_handler_destroy(dmevh);
+	return NULL;
+}
+
+char *get_monitor_dso_path(struct cmd_context *cmd, const char *libpath)
+{
+	char *path;
+
+	if (!(path = dm_pool_alloc(cmd->mem, PATH_MAX))) {
+		log_error("Failed to allocate dmeventd library path.");
+		return NULL;
+	}
+
+	get_shared_library_path(cmd, libpath, path, PATH_MAX);
+
+	return path;
+}
+
+int target_registered_with_dmeventd(struct cmd_context *cmd, const char *dso, const char *lvid, int *pending)
+{
+	char *uuid;
+	enum dm_event_mask evmask = 0;
+	struct dm_event_handler *dmevh;
+
+	*pending = 0;
+
+	if (!dso)
+		return_0;
+
+	if (!(uuid = build_dm_uuid(cmd->mem, lvid, NULL)))
+		return_0;
+
+	if (!(dmevh = _create_dm_event_handler(cmd, uuid, dso, 0, DM_EVENT_ALL_ERRORS)))
+		return_0;
+
+	if (dm_event_get_registered_device(dmevh, 0)) {
+		dm_event_handler_destroy(dmevh);
+		return 0;
+	}
+
+	evmask = dm_event_handler_get_event_mask(dmevh);
+	if (evmask & DM_EVENT_REGISTRATION_PENDING) {
+		*pending = 1;
+		evmask &= ~DM_EVENT_REGISTRATION_PENDING;
+	}
+
+	dm_event_handler_destroy(dmevh);
+
+	return evmask;
+}
+
+int target_register_events(struct cmd_context *cmd, const char *dso, const char *lvid,
+			    int evmask __attribute__((unused)), int set, int timeout)
+{
+	char *uuid;
+	struct dm_event_handler *dmevh;
+	int r;
+
+	if (!dso)
+		return_0;
+
+	if (!(uuid = build_dm_uuid(cmd->mem, lvid, NULL)))
+		return_0;
+
+	if (!(dmevh = _create_dm_event_handler(cmd, uuid, dso, timeout,
+					       DM_EVENT_ALL_ERRORS | (timeout ? DM_EVENT_TIMEOUT : 0))))
+		return_0;
+
+	r = set ? dm_event_register_handler(dmevh) : dm_event_unregister_handler(dmevh);
+
+	dm_event_handler_destroy(dmevh);
+
+	if (!r)
+		return_0;
+
+	log_info("%s %s for events", set ? "Monitored" : "Unmonitored", uuid);
+
+	return 1;
+}
+
+#endif
+
 /*
  * Returns 0 if an attempt to (un)monitor the device failed.
  * Returns 1 otherwise.
--- LVM2/lib/activate/activate.h	2010/05/24 15:32:20	1.68
+++ LVM2/lib/activate/activate.h	2010/08/16 22:54:36	1.69
@@ -44,7 +44,7 @@
 int target_present(struct cmd_context *cmd, const char *target_name,
 		   int use_modprobe);
 int target_version(const char *target_name, uint32_t *maj,
-                   uint32_t *min, uint32_t *patchlevel);
+		   uint32_t *min, uint32_t *patchlevel);
 int list_segment_modules(struct dm_pool *mem, const struct lv_segment *seg,
 			 struct dm_list *modules);
 int list_lv_modules(struct dm_pool *mem, const struct logical_volume *lv,
@@ -102,6 +102,14 @@
 int monitor_dev_for_events(struct cmd_context *cmd,
 			    struct logical_volume *lv, int do_reg);
 
+#ifdef DMEVENTD
+#  include "libdevmapper-event.h"
+char *get_monitor_dso_path(struct cmd_context *cmd, const char *libpath);
+int target_registered_with_dmeventd(struct cmd_context *cmd, const char *libpath, const char *lvid, int *pending);
+int target_register_events(struct cmd_context *cmd, const char *dso, const char *lvid,
+			    int evmask __attribute__((unused)), int set, int timeout);
+#endif
+
 /*
  * Returns 1 if PV has a dependency tree that uses anything in VG.
  */
--- LVM2/lib/config/defaults.h	2010/08/12 04:11:48	1.65
+++ LVM2/lib/config/defaults.h	2010/08/16 22:54:36	1.66
@@ -48,6 +48,7 @@
 #define DEFAULT_MIRROR_IMAGE_FAULT_POLICY "remove"
 #define DEFAULT_MIRROR_MAX_IMAGES 8 /* limited by kernel DM_KCOPYD_MAX_REGIONS */
 #define DEFAULT_DMEVENTD_MIRROR_LIB "libdevmapper-event-lvm2mirror.so"
+#define DEFAULT_DMEVENTD_SNAPSHOT_LIB "libdevmapper-event-lvm2snapshot.so"
 #define DEFAULT_DMEVENTD_MONITOR 1
 #define DEFAULT_BACKGROUND_POLLING 1
 
--- LVM2/lib/mirror/mirrored.c	2010/08/04 15:55:03	1.75
+++ LVM2/lib/mirror/mirrored.c	2010/08/16 22:54:36	1.76
@@ -30,10 +30,6 @@
 
 #include <sys/utsname.h>
 
-#ifdef DMEVENTD
-#  include "libdevmapper-event.h"
-#endif
-
 static int _block_on_error_available = 0;
 static unsigned _mirror_attributes = 0;
 
@@ -520,19 +516,19 @@
 			} else if (module_present(cmd, "log-userspace"))
 				_mirror_attributes |= MIRROR_LOG_CLUSTERED;
 
-                        if (!(_mirror_attributes & MIRROR_LOG_CLUSTERED))
-                                log_verbose("Cluster mirror log module is not available");
+			if (!(_mirror_attributes & MIRROR_LOG_CLUSTERED))
+				log_verbose("Cluster mirror log module is not available");
 
-                        /*
-                         * The cluster mirror log daemon must be running,
-                         * otherwise, the kernel module will fail to make
-                         * contact.
-                         */
+			/*
+			 * The cluster mirror log daemon must be running,
+			 * otherwise, the kernel module will fail to make
+			 * contact.
+			 */
 #ifdef CMIRRORD_PIDFILE
-                        if (!dm_daemon_is_running(CMIRRORD_PIDFILE)) {
-                                log_verbose("Cluster mirror log daemon is not running");
-                                _mirror_attributes &= ~MIRROR_LOG_CLUSTERED;
-                        }
+			if (!dm_daemon_is_running(CMIRRORD_PIDFILE)) {
+				log_verbose("Cluster mirror log daemon is not running");
+				_mirror_attributes &= ~MIRROR_LOG_CLUSTERED;
+			}
 #else
 			log_verbose("Cluster mirror log daemon not included in build");
 			_mirror_attributes &= ~MIRROR_LOG_CLUSTERED;
@@ -546,116 +542,23 @@
 }
 
 #ifdef DMEVENTD
-static int _get_mirror_dso_path(struct cmd_context *cmd, char **dso)
+static const char *_get_mirror_dso_path(struct cmd_context *cmd)
 {
-	char *path;
-	const char *libpath;
-
-	if (!(path = dm_pool_alloc(cmd->mem, PATH_MAX))) {
-		log_error("Failed to allocate dmeventd library path.");
-		return 0;
-	}
-
-	libpath = find_config_tree_str(cmd, "dmeventd/mirror_library",
-				       DEFAULT_DMEVENTD_MIRROR_LIB);
-
-	get_shared_library_path(cmd, libpath, path, PATH_MAX);
-
-	*dso = path;
-
-	return 1;
+	return get_monitor_dso_path(cmd, find_config_tree_str(cmd, "dmeventd/mirror_library",
+							      DEFAULT_DMEVENTD_MIRROR_LIB));
 }
 
-static struct dm_event_handler *_create_dm_event_handler(const char *dmuuid,
-							 const char *dso,
-							 enum dm_event_mask mask)
+static int _target_registered(struct lv_segment *seg, int *pending)
 {
-	struct dm_event_handler *dmevh;
-
-	if (!(dmevh = dm_event_handler_create()))
-		return_0;
-
-       if (dm_event_handler_set_dso(dmevh, dso))
-		goto fail;
-
-	if (dm_event_handler_set_uuid(dmevh, dmuuid))
-		goto fail;
-
-	dm_event_handler_set_event_mask(dmevh, mask);
-	return dmevh;
-
-fail:
-	dm_event_handler_destroy(dmevh);
-	return NULL;
-}
-
-static int _target_monitored(struct lv_segment *seg, int *pending)
-{
-	char *dso, *uuid;
-	struct logical_volume *lv;
-	struct volume_group *vg;
-	enum dm_event_mask evmask = 0;
-	struct dm_event_handler *dmevh;
-
-	lv = seg->lv;
-	vg = lv->vg;
-
-	*pending = 0;
-	if (!_get_mirror_dso_path(vg->cmd, &dso))
-		return_0;
-
-	if (!(uuid = build_dm_uuid(vg->cmd->mem, lv->lvid.s, NULL)))
-		return_0;
-
-	if (!(dmevh = _create_dm_event_handler(uuid, dso, DM_EVENT_ALL_ERRORS)))
-		return_0;
-
-	if (dm_event_get_registered_device(dmevh, 0)) {
-		dm_event_handler_destroy(dmevh);
-		return 0;
-	}
-
-	evmask = dm_event_handler_get_event_mask(dmevh);
-	if (evmask & DM_EVENT_REGISTRATION_PENDING) {
-		*pending = 1;
-		evmask &= ~DM_EVENT_REGISTRATION_PENDING;
-	}
-
-	dm_event_handler_destroy(dmevh);
-
-	return evmask;
+	return target_registered_with_dmeventd(seg->lv->vg->cmd, _get_mirror_dso_path(seg->lv->vg->cmd),
+					       seg->lv->lvid.s, pending);
 }
 
 /* FIXME This gets run while suspended and performs banned operations. */
-static int _target_set_events(struct lv_segment *seg,
-			      int evmask __attribute__((unused)), int set)
+static int _target_set_events(struct lv_segment *seg, int evmask, int set)
 {
-	char *dso, *uuid;
-	struct logical_volume *lv;
-	struct volume_group *vg;
-	struct dm_event_handler *dmevh;
-	int r;
-
-	lv = seg->lv;
-	vg = lv->vg;
-
-	if (!_get_mirror_dso_path(vg->cmd, &dso))
-		return_0;
-
-	if (!(uuid = build_dm_uuid(vg->cmd->mem, lv->lvid.s, NULL)))
-		return_0;
-
-	if (!(dmevh = _create_dm_event_handler(uuid, dso, DM_EVENT_ALL_ERRORS)))
-		return_0;
-
-	r = set ? dm_event_register_handler(dmevh) : dm_event_unregister_handler(dmevh);
-	dm_event_handler_destroy(dmevh);
-	if (!r)
-		return_0;
-
-	log_info("%s %s for events", set ? "Monitored" : "Unmonitored", uuid);
-
-	return 1;
+	return target_register_events(seg->lv->vg->cmd, _get_mirror_dso_path(seg->lv->vg->cmd),
+				      seg->lv->lvid.s, evmask, set, 0);
 }
 
 static int _target_monitor_events(struct lv_segment *seg, int events)
@@ -710,7 +613,7 @@
 	.target_present = _mirrored_target_present,
 	.check_transient_status = _mirrored_transient_status,
 #ifdef DMEVENTD
-	.target_monitored = _target_monitored,
+	.target_monitored = _target_registered,
 	.target_monitor_events = _target_monitor_events,
 	.target_unmonitor_events = _target_unmonitor_events,
 #endif
@@ -735,7 +638,12 @@
 	segtype->ops = &_mirrored_ops;
 	segtype->name = "mirror";
 	segtype->private = NULL;
-	segtype->flags = SEG_AREAS_MIRRORED | SEG_MONITORED;
+	segtype->flags = SEG_AREAS_MIRRORED;
+
+#ifdef DMEVENTD
+	if (_get_mirror_dso_path(cmd))
+		segtype->flags |= SEG_MONITORED;
+#endif
 
 	log_very_verbose("Initialised segtype: %s", segtype->name);
 
--- LVM2/lib/misc/configure.h.in	2010/07/28 13:55:43	1.26
+++ LVM2/lib/misc/configure.h.in	2010/08/16 22:54:36	1.27
@@ -417,6 +417,9 @@
 /* Define to 1 if you have the <utmpx.h> header file. */
 #undef HAVE_UTMPX_H
 
+/* Define to 1 if you have the <valgrind/memcheck.h> header file. */
+#undef HAVE_VALGRIND_MEMCHECK_H
+
 /* Define to 1 if you have the `vfork' function. */
 #undef HAVE_VFORK
 
@@ -522,6 +525,9 @@
 /* Define to 1 to enable synchronisation with udev processing. */
 #undef UDEV_SYNC_SUPPORT
 
+/* Enable a valgrind aware build of pool */
+#undef VALGRIND_POOL
+
 /* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
    <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
    #define below would cause a syntax error. */
--- LVM2/lib/snapshot/snapshot.c	2010/07/09 15:34:46	1.47
+++ LVM2/lib/snapshot/snapshot.c	2010/08/16 22:54:36	1.48
@@ -21,10 +21,7 @@
 #include "config.h"
 #include "activate.h"
 #include "str_list.h"
-#ifdef DMEVENTD
-#  include "sharedlib.h"
-#  include "libdevmapper-event.h"
-#endif
+#include "defaults.h"
 
 static const char *_snap_name(const struct lv_segment *seg)
 {
@@ -164,117 +161,25 @@
 }
 
 #ifdef DMEVENTD
-static int _get_snapshot_dso_path(struct cmd_context *cmd, char **dso)
-{
-	char *path;
-	const char *libpath;
-
-	if (!(path = dm_pool_alloc(cmd->mem, PATH_MAX))) {
-		log_error("Failed to allocate dmeventd library path.");
-		return 0;
-	}
-
-	libpath = find_config_tree_str(cmd, "dmeventd/snapshot_library", NULL);
-	if (!libpath)
-		return 0;
-
-	get_shared_library_path(cmd, libpath, path, PATH_MAX);
 
-	*dso = path;
-
-	return 1;
-}
-
-static struct dm_event_handler *_create_dm_event_handler(const char *dmuuid,
-							 const char *dso,
-							 const int timeout,
-							 enum dm_event_mask mask)
+static const char *_get_snapshot_dso_path(struct cmd_context *cmd)
 {
-	struct dm_event_handler *dmevh;
-
-	if (!(dmevh = dm_event_handler_create()))
-		return_0;
-
-       if (dm_event_handler_set_dso(dmevh, dso))
-		goto fail;
-
-	if (dm_event_handler_set_uuid(dmevh, dmuuid))
-		goto fail;
-
-	dm_event_handler_set_timeout(dmevh, timeout);
-	dm_event_handler_set_event_mask(dmevh, mask);
-	return dmevh;
-
-fail:
-	dm_event_handler_destroy(dmevh);
-	return NULL;
+	return get_monitor_dso_path(cmd, find_config_tree_str(cmd, "dmeventd/snapshot_library",
+							      DEFAULT_DMEVENTD_SNAPSHOT_LIB));
 }
 
 static int _target_registered(struct lv_segment *seg, int *pending)
 {
-	char *dso, *uuid;
-	struct logical_volume *lv;
-	struct volume_group *vg;
-	enum dm_event_mask evmask = 0;
-	struct dm_event_handler *dmevh;
-
-	lv = seg->lv;
-	vg = lv->vg;
-
-	*pending = 0;
-	if (!_get_snapshot_dso_path(vg->cmd, &dso))
-		return_0;
-
-	if (!(uuid = build_dm_uuid(vg->cmd->mem, seg->cow->lvid.s, NULL)))
-		return_0;
-
-	if (!(dmevh = _create_dm_event_handler(uuid, dso, 0, DM_EVENT_ALL_ERRORS)))
-		return_0;
-
-	if (dm_event_get_registered_device(dmevh, 0)) {
-		dm_event_handler_destroy(dmevh);
-		return 0;
-	}
-
-	evmask = dm_event_handler_get_event_mask(dmevh);
-	if (evmask & DM_EVENT_REGISTRATION_PENDING) {
-		*pending = 1;
-		evmask &= ~DM_EVENT_REGISTRATION_PENDING;
-	}
-
-	dm_event_handler_destroy(dmevh);
-
-	return evmask;
+	return target_registered_with_dmeventd(seg->lv->vg->cmd, _get_snapshot_dso_path(seg->lv->vg->cmd),
+					       seg->cow->lvid.s, pending);
 }
 
 /* FIXME This gets run while suspended and performs banned operations. */
-static int _target_set_events(struct lv_segment *seg,
-			      int events __attribute__((unused)), int set)
+static int _target_set_events(struct lv_segment *seg, int evmask, int set)
 {
-	char *dso, *uuid;
-	struct volume_group *vg = seg->lv->vg;
-	struct dm_event_handler *dmevh;
-	int r;
-
-	if (!_get_snapshot_dso_path(vg->cmd, &dso))
-		return_0;
-
-	if (!(uuid = build_dm_uuid(vg->cmd->mem, seg->cow->lvid.s, NULL)))
-		return_0;
-
-	/* FIXME: make timeout configurable */
-	if (!(dmevh = _create_dm_event_handler(uuid, dso, 10,
-		DM_EVENT_ALL_ERRORS|DM_EVENT_TIMEOUT)))
-		return_0;
-
-	r = set ? dm_event_register_handler(dmevh) : dm_event_unregister_handler(dmevh);
-	dm_event_handler_destroy(dmevh);
-	if (!r)
-		return_0;
-
-	log_info("%s %s for events", set ? "Registered" : "Unregistered", uuid);
-
-	return 1;
+	/* FIXME Make timeout (10) configurable */
+	return target_register_events(seg->lv->vg->cmd, _get_snapshot_dso_path(seg->lv->vg->cmd),
+				      seg->cow->lvid.s, evmask, set, 10);
 }
 
 static int _target_register_events(struct lv_segment *seg,
@@ -335,9 +240,6 @@
 #endif
 {
 	struct segment_type *segtype = dm_malloc(sizeof(*segtype));
-#ifdef DMEVENTD
-	char *dso;
-#endif
 
 	if (!segtype)
 		return_NULL;
@@ -349,7 +251,7 @@
 	segtype->flags = SEG_SNAPSHOT;
 
 #ifdef DMEVENTD
-	if (_get_snapshot_dso_path(cmd, &dso))
+	if (_get_snapshot_dso_path(cmd))
 		segtype->flags |= SEG_MONITORED;
 #endif
 	log_very_verbose("Initialised segtype: %s", segtype->name);
--- LVM2/tools/lvchange.c	2010/07/09 15:34:48	1.122
+++ LVM2/tools/lvchange.c	2010/08/16 22:54:37	1.123
@@ -97,7 +97,7 @@
 
 	if ((dmeventd_monitor_mode() != DMEVENTD_MONITOR_IGNORE) &&
 	    !monitor_dev_for_events(cmd, lv, dmeventd_monitor_mode()))
-		stack;
+		return_0;
 
 	return 1;
 }
--- LVM2/tools/vgchange.c	2010/07/26 19:03:29	1.110
+++ LVM2/tools/vgchange.c	2010/08/16 22:54:37	1.111
@@ -15,14 +15,17 @@
 
 #include "tools.h"
 
+/*
+ * Increments *count by the number of _new_ monitored devices.
+ */
 static int _monitor_lvs_in_vg(struct cmd_context *cmd,
-			       struct volume_group *vg, int reg)
+			      struct volume_group *vg, int reg, int *count)
 {
 	struct lv_list *lvl;
 	struct logical_volume *lv;
 	struct lvinfo info;
 	int lv_active;
-	int count = 0;
+	int r = ECMD_PROCESSED;
 
 	dm_list_iterate_items(lvl, &vg->lvs) {
 		lv = lvl->lv;
@@ -39,16 +42,13 @@
 			continue;
 
 		if (!monitor_dev_for_events(cmd, lv, reg)) {
+			r = ECMD_FAILED;
 			continue;
 		} else
-			count++;
+			(*count)++;
 	}
 
-	/*
-	 * returns the number of _new_ monitored devices
-	 */
-
-	return count;
+	return r;
 }
 
 static int _poll_lvs_in_vg(struct cmd_context *cmd,
@@ -160,17 +160,18 @@
 
 static int _vgchange_monitoring(struct cmd_context *cmd, struct volume_group *vg)
 {
-	int monitored;
+	int ret_max = ECMD_PROCESSED;
+	int monitored = 0;
 
 	if (lvs_in_vg_activated(vg) &&
 	    dmeventd_monitor_mode() != DMEVENTD_MONITOR_IGNORE) {
-		monitored = _monitor_lvs_in_vg(cmd, vg, dmeventd_monitor_mode());
+		ret_max = max(ret_max, _monitor_lvs_in_vg(cmd, vg, dmeventd_monitor_mode(), &monitored));
 		log_print("%d logical volume(s) in volume group "
 			    "\"%s\" %smonitored",
 			    monitored, vg->name, (dmeventd_monitor_mode()) ? "" : "un");
 	}
 
-	return ECMD_PROCESSED;
+	return ret_max;
 }
 
 static int _vgchange_background_polling(struct cmd_context *cmd, struct volume_group *vg)
@@ -190,7 +191,7 @@
 static int _vgchange_available(struct cmd_context *cmd, struct volume_group *vg)
 {
 	int lv_open, active, monitored;
-	int available, ret;
+	int available, ret_max = ECMD_PROCESSED;
 	int activate = 1;
 
 	/*
@@ -219,7 +220,7 @@
 		log_verbose("%d logical volume(s) in volume group \"%s\" "
 			    "already active", active, vg->name);
 		if (dmeventd_monitor_mode() != DMEVENTD_MONITOR_IGNORE) {
-			monitored = _monitor_lvs_in_vg(cmd, vg, dmeventd_monitor_mode());
+			ret_max = max(ret_max, _monitor_lvs_in_vg(cmd, vg, dmeventd_monitor_mode(), &monitored));
 			log_verbose("%d existing logical volume(s) in volume "
 				    "group \"%s\" %smonitored",
 				    monitored, vg->name,
@@ -227,13 +228,13 @@
 		}
 	}
 
-	ret = _activate_lvs_in_vg(cmd, vg, available);
+	ret_max = max(ret_max, _activate_lvs_in_vg(cmd, vg, available));
 
 	/* Print message only if there was not found a missing VG */
 	if (!vg->cmd_missing_vgs)
 		log_print("%d logical volume(s) in volume group \"%s\" now active",
 			  lvs_in_vg_activated(vg), vg->name);
-	return ret;
+	return ret_max;
 }
 
 static int _vgchange_alloc(struct cmd_context *cmd, struct volume_group *vg)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-08-16 22:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-13 13:51 LVM2 ./WHATS_NEW ./WHATS_NEW_DM ./configure ./ fabbione
2010-08-16 22:54 agk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).