Try to avoid delays and locking errors in startup scripts.
Automatically set locking_type for lvm2.
--- /dev/null
+Index: new/lib/locking/locking.c
+===================================================================
+--- new.orig/lib/locking/locking.c 2011-06-11 02:03:07.000000000 +0200
++++ new/lib/locking/locking.c 2011-09-21 10:01:47.000000000 +0200
+@@ -225,7 +225,16 @@
+ suppress_messages = 1;
+
+ if (type < 0)
+- type = find_config_tree_int(cmd, "global/locking_type", 1);
++ type = find_config_tree_int(cmd, "global/locking_type", -1);
++
++ if (type < 0) {
++ struct stat info;
++ if (stat("/etc/cluster/cluster.conf", &info) == 0) {
++ type = 3;
++ } else {
++ type = 1;
++ }
++ }
+
+ _blocking_supported = find_config_tree_int(cmd,
+ "global/wait_for_locks", DEFAULT_WAIT_FOR_LOCKS);
+Index: new/doc/example.conf.in
+===================================================================
+--- new.orig/doc/example.conf.in 2011-07-01 16:09:19.000000000 +0200
++++ new/doc/example.conf.in 2011-09-21 10:01:47.000000000 +0200
+@@ -350,13 +350,16 @@
+ proc = "/proc"
+
+ # Type of locking to use. Defaults to local file-based locking (1).
++ # Proxmox VE sets default locking_type to 3 if file
++ # /etc/cluster/cluster.conf exists. So there is normally no need
++ # to set this value here.
+ # Turn locking off by setting to 0 (dangerous: risks metadata corruption
+ # if LVM2 commands get run concurrently).
+ # Type 2 uses the external shared library locking_library.
+ # Type 3 uses built-in clustered locking.
+ # Type 4 uses read-only locking which forbids any operations that might
+ # change metadata.
+- locking_type = 1
++ # locking_type = 1
+
+ # Set to 0 to fail when a lock request cannot be satisfied immediately.
+ wait_for_locks = 1
+Index: new/lib/locking/cluster_locking.c
+===================================================================
+--- new.orig/lib/locking/cluster_locking.c 2011-09-21 10:08:21.000000000 +0200
++++ new/lib/locking/cluster_locking.c 2011-09-21 10:10:55.000000000 +0200
+@@ -66,10 +66,14 @@
+ {
+ int local_socket;
+ struct sockaddr_un sockaddr;
++ int suppress_messages = 0;
++
++ if (ignorelockingfailure() && getenv("LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES"))
++ suppress_messages = 1;
+
+ /* Open local socket */
+ if ((local_socket = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
+- log_error("Local socket creation failed: %s", strerror(errno));
++ log_error_suppress(suppress_messages, "Local socket creation failed: %s", strerror(errno));
+ return -1;
+ }
+
+@@ -82,7 +86,7 @@
+ sizeof(sockaddr))) {
+ int saved_errno = errno;
+
+- log_error("connect() failed on local socket: %s",
++ log_error_suppress(suppress_messages, "connect() failed on local socket: %s",
+ strerror(errno));
+ if (close(local_socket))
+ stack;
-Index: lvm2new/debian/clvm.init
+Index: new/debian/clvm.init
===================================================================
---- lvm2new.orig/debian/clvm.init 2011-09-20 10:42:31.000000000 +0200
-+++ lvm2new/debian/clvm.init 2011-09-20 10:43:21.000000000 +0200
+--- new.orig/debian/clvm.init 2011-09-21 11:08:28.000000000 +0200
++++ new/debian/clvm.init 2011-09-21 11:22:15.000000000 +0200
@@ -4,8 +4,8 @@
# Provides: clvm
# Required-Start: $remote_fs lvm2 cman
# Short-Description: start and stop the lvm cluster locking daemon
### END INIT INFO
#
-Index: lvm2new/debian/rules
+@@ -44,10 +44,10 @@
+
+ do_start()
+ {
+- start-stop-daemon --start --quiet --exec $DAEMON -- $DAEMON_OPTS || status="$?"
++ start-stop-daemon --start --quiet --exec $DAEMON -- $DAEMON_OPTS || return $?
+ # flush cache
+ vgscan > /dev/null 2>&1
+- return $status
++ return 0
+ }
+
+ do_activate()
+@@ -91,7 +91,7 @@
+ case "$status" in
+ 0) log_end_msg 0 ;;
+ 1) log_action_msg " already running" ; log_end_msg 0 ;;
+- *) log_end_msg 1 ;;
++ *) log_end_msg 1 ; exit $status ;;
+ esac
+ # and activate clustered volume groups
+ do_activate
+@@ -99,6 +99,10 @@
+ exit $status
+ ;;
+ stop)
++ pid=$( pidof $DAEMON )
++ if [ -z "$pid" ] ; then
++ exit 0
++ fi
+ # deactivate volumes...
+ log_daemon_msg "Deactivating VG $vg:"
+ do_deactivate
+Index: new/debian/rules
===================================================================
---- lvm2new.orig/debian/rules 2011-09-20 10:52:11.000000000 +0200
-+++ lvm2new/debian/rules 2011-09-20 10:52:32.000000000 +0200
+--- new.orig/debian/rules 2011-09-21 11:08:28.000000000 +0200
++++ new/debian/rules 2011-09-21 11:08:51.000000000 +0200
@@ -160,7 +160,7 @@
install_clvm: DIR = $(BUILD_DIR)/install_deb
install_clvm: $(STAMPS_DIR)/install_deb
--- /dev/null
+Index: new/debian/lvm2.init
+===================================================================
+--- new.orig/debian/lvm2.init 2011-09-21 10:03:08.000000000 +0200
++++ new/debian/lvm2.init 2011-09-21 10:14:17.000000000 +0200
+@@ -20,6 +20,7 @@
+ do_start()
+ {
+ modprobe dm-mod 2> /dev/null || :
++ export LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES=1
+ /sbin/vgscan --ignorelockingfailure || :
+ /sbin/vgchange -aly --ignorelockingfailure || return 2
+ }
--- /dev/null
+Index: new/debian/control
+===================================================================
+--- new.orig/debian/control 2011-09-21 07:05:16.000000000 +0200
++++ new/debian/control 2011-09-21 07:06:32.000000000 +0200
+@@ -21,20 +21,6 @@
+ volume groups can be allocated to logical volumes, which are accessed as
+ regular block devices.
+
+-Package: lvm2-udeb
+-XC-Package-Type: udeb
+-Section: debian-installer
+-Architecture: any
+-Depends: ${shlibs:Depends}, ${misc:Depends}
+-Description: Linux Logical Volume Manager
+- This is a udeb, or a microdeb, for the debian-installer.
+- .
+- This is LVM2, the rewrite of The Linux Logical Volume Manager. LVM
+- supports enterprise level volume management of disk and disk subsystems
+- by grouping arbitrary disks into volume groups. The total capacity of
+- volume groups can be allocated to logical volumes, which are accessed as
+- regular block devices.
+-
+ Package: clvm
+ Priority: extra
+ Architecture: any
+@@ -78,20 +64,6 @@
+ device-mapper; it allows usage of the device-mapper through a clean,
+ consistent interface (as opposed to through kernel ioctls).
+
+-Package: libdevmapper1.02.1-udeb
+-XC-Package-Type: udeb
+-Section: debian-installer
+-Architecture: any
+-Depends: ${shlibs:Depends}, ${misc:Depends}
+-Description: Linux Kernel Device Mapper userspace library
+- This is a udeb, or a microdeb, for the debian-installer.
+- .
+- The Linux Kernel Device Mapper is the LVM (Linux Logical Volume Management)
+- Team's implementation of a minimalistic kernel-space driver that handles
+- volume management, while keeping knowledge of the underlying device layout
+- in user-space. This makes it useful for not only LVM, but EVMS, software
+- raid, and other drivers that create "virtual" block devices.
+-
+ Package: dmsetup
+ Architecture: any
+ Depends: ${shlibs:Depends}, ${misc:Depends}, util-linux (>> 2.16)
+@@ -99,20 +71,6 @@
+ Description: Linux Kernel Device Mapper userspace library
+ The Linux Kernel Device Mapper is the LVM (Linux Logical Volume Management)
+ Team's implementation of a minimalistic kernel-space driver that handles
+- volume management, while keeping knowledge of the underlying device layout
+- in user-space. This makes it useful for not only LVM, but EVMS, software
+- raid, and other drivers that create "virtual" block devices.
+- .
+- This package contains a utility for modifying device mappings.
+-
+-Package: dmsetup-udeb
+-XC-Package-Type: udeb
+-Section: debian-installer
+-Architecture: any
+-Depends: ${shlibs:Depends}, ${misc:Depends}
+-Description: Linux Kernel Device Mapper userspace library
+- The Linux Kernel Device Mapper is the LVM (Linux Logical Volume Management)
+- Team's implementation of a minimalistic kernel-space driver that handles
+ volume management, while keeping knowledge of the underlying device layout
+ in user-space. This makes it useful for not only LVM, but EVMS, software
+ raid, and other drivers that create "virtual" block devices.
+Index: new/debian/rules
+===================================================================
+--- new.orig/debian/rules 2011-09-21 07:09:37.000000000 +0200
++++ new/debian/rules 2011-09-21 07:15:09.000000000 +0200
+@@ -65,7 +65,7 @@
+ cd $(DIR); autoreconf
+ touch $@
+
+-setup: $(STAMPS_DIR)/setup_deb $(STAMPS_DIR)/setup_udeb
++setup: $(STAMPS_DIR)/setup_deb
+
+ $(STAMPS_DIR)/setup_deb: SOURCE_DIR = $(BUILD_DIR)/source
+ $(STAMPS_DIR)/setup_deb: DIR = $(BUILD_DIR)/build_deb
+@@ -105,7 +105,7 @@
+ --disable-selinux
+ touch $@
+
+-build: $(STAMPS_DIR)/build_deb $(STAMPS_DIR)/build_udeb
++build: $(STAMPS_DIR)/build_deb
+
+ build_deb: $(STAMPS_DIR)/build_deb
+ build_udeb: $(STAMPS_DIR)/build_udeb
+@@ -240,7 +240,7 @@
+ +$(MAKE_SELF) install-base
+
+ binary-indep:
+-binary-arch: $(addprefix install_,libdevmapper libdevmapper-udeb libdevmapper-dev dmsetup dmsetup-udeb liblvm2app liblvm2cmd liblvm2-dev lvm2 lvm2-udeb clvm)
++binary-arch: $(addprefix install_,libdevmapper libdevmapper-dev dmsetup liblvm2app liblvm2cmd liblvm2-dev lvm2 clvm)
+
+ binary: binary-indep binary-arch
+
fix-clvm-init-script.patch
fix-changelog.patch
fix-fsadm-install.patch
+remove-udebs.patch
+autodetect-locking-type.patch
+fix-lvm2-init-script-patch