Blame 0010-lvm-use-sysinit-if-lvm-version-v2.02.65.patch

Harald Hoyer 59f9af
From b282107fa947817f1fc0bce6ae88b0a83c275847 Mon Sep 17 00:00:00 2001
Harald Hoyer 59f9af
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer 59f9af
Date: Fri, 18 Feb 2011 10:58:39 +0100
Harald Hoyer 59f9af
Subject: [PATCH] lvm: use --sysinit, if lvm version >=  v2.02.65
Harald Hoyer 59f9af
Harald Hoyer 59f9af
---
Harald Hoyer 59f9af
 modules.d/90lvm/lvm_scan.sh |   50 +++++++++++++++++++++++++++++-------------
Harald Hoyer 59f9af
 1 files changed, 34 insertions(+), 16 deletions(-)
Harald Hoyer 59f9af
Harald Hoyer 59f9af
diff --git a/modules.d/90lvm/lvm_scan.sh b/modules.d/90lvm/lvm_scan.sh
Harald Hoyer 59f9af
index e705d39..7d56fce 100755
Harald Hoyer 59f9af
--- a/modules.d/90lvm/lvm_scan.sh
Harald Hoyer 59f9af
+++ b/modules.d/90lvm/lvm_scan.sh
Harald Hoyer 59f9af
@@ -45,30 +45,40 @@ if [ ! -e /etc/lvm/lvm.conf ]; then
Harald Hoyer 59f9af
 fi
Harald Hoyer 59f9af
 
Harald Hoyer 59f9af
 check_lvm_ver() {
Harald Hoyer 59f9af
+    maj=$1; shift;
Harald Hoyer 59f9af
+    min=$1; shift;
Harald Hoyer 59f9af
+    ver=$1; shift;
Harald Hoyer 59f9af
     # --poll is supported since 2.2.57
Harald Hoyer 59f9af
-    [ $1 -lt 2 ] && return 1
Harald Hoyer 59f9af
-    [ $1 -gt 2 ] && return 0
Harald Hoyer 59f9af
-    # major is 2
Harald Hoyer 59f9af
-    [ $2 -lt 2 ] && return 1
Harald Hoyer 59f9af
-    [ $2 -gt 2 ] && return 0
Harald Hoyer 59f9af
-    # minor is 2, check for 
Harald Hoyer 59f9af
-    # greater or equal 57
Harald Hoyer 59f9af
-    [ $3 -ge 57 ] && return 0
Harald Hoyer 59f9af
+    [ $1 -lt $maj ] && return 1
Harald Hoyer 59f9af
+    [ $1 -gt $maj ] && return 0
Harald Hoyer 59f9af
+    [ $2 -lt $min ] && return 1
Harald Hoyer 59f9af
+    [ $2 -gt $min ] && return 0
Harald Hoyer 59f9af
+    [ $3 -ge $ver ] && return 0
Harald Hoyer 59f9af
     return 1
Harald Hoyer 59f9af
 }
Harald Hoyer 59f9af
 
Harald Hoyer 59f9af
+lvm version 2>/dev/null | ( \
Harald Hoyer 59f9af
+    IFS=. read maj min sub; 
Harald Hoyer 59f9af
+    maj=${maj##*:}; 
Harald Hoyer 59f9af
+    sub=${sub%% *}; sub=${sub%%\(*}; 
Harald Hoyer 59f9af
+    ) 2>/dev/null 
Harald Hoyer 59f9af
+
Harald Hoyer 59f9af
 nopoll=$(
Harald Hoyer 59f9af
     # hopefully this output format will never change, e.g.:
Harald Hoyer 59f9af
     #   LVM version:     2.02.53(1) (2009-09-25)
Harald Hoyer 59f9af
-    lvm version 2>/dev/null | ( \
Harald Hoyer 59f9af
-        IFS=. read maj min sub; 
Harald Hoyer 59f9af
-        maj=${maj##*:}; 
Harald Hoyer 59f9af
-        sub=${sub%% *}; sub=${sub%%\(*}; 
Harald Hoyer 59f9af
-        check_lvm_ver $maj $min $sub && \
Harald Hoyer 59f9af
+        check_lvm_ver 2 2 57 $maj $min $sub && \
Harald Hoyer 59f9af
             echo " --poll n ";
Harald Hoyer 59f9af
-    ) 2>/dev/null 
Harald Hoyer 59f9af
 )
Harald Hoyer 59f9af
 
Harald Hoyer 59f9af
+sysinit=$(
Harald Hoyer 59f9af
+    # hopefully this output format will never change, e.g.:
Harald Hoyer 59f9af
+    #   LVM version:     2.02.53(1) (2009-09-25)
Harald Hoyer 59f9af
+        check_lvm_ver 2 2 65 $maj $min $sub && \
Harald Hoyer 59f9af
+            echo " --sysinit ";
Harald Hoyer 59f9af
+)
Harald Hoyer 59f9af
+
Harald Hoyer 59f9af
+export LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES=1
Harald Hoyer 59f9af
+
Harald Hoyer 59f9af
 if [ -n "$SNAPSHOT" ] ; then
Harald Hoyer 59f9af
     # HACK - this should probably be done elsewhere or turned into a function
Harald Hoyer 59f9af
     # Enable read-write LVM locking
Harald Hoyer 59f9af
@@ -94,13 +104,21 @@ fi
Harald Hoyer 59f9af
 if [ -n "$LVS" ] ; then
Harald Hoyer 59f9af
     info "Scanning devices $lvmdevs for LVM logical volumes $LVS"
Harald Hoyer 59f9af
     lvm lvscan --ignorelockingfailure 2>&1 | vinfo
Harald Hoyer 59f9af
-    lvm lvchange -ay --ignorelockingfailure $nopoll --ignoremonitoring $LVS 2>&1 | vinfo
Harald Hoyer 59f9af
+    if [ -z "$sysinit" ]; then
Harald Hoyer 59f9af
+        lvm lvchange -ay --ignorelockingfailure $nopoll --ignoremonitoring $LVS 2>&1 | vinfo
Harald Hoyer 59f9af
+    else
Harald Hoyer 59f9af
+        lvm lvchange -ay $sysinit $LVS 2>&1 | vinfo
Harald Hoyer 59f9af
+    fi
Harald Hoyer 59f9af
 fi
Harald Hoyer 59f9af
 
Harald Hoyer 59f9af
 if [ -z "$LVS" -o -n "$VGS" ]; then
Harald Hoyer 59f9af
     info "Scanning devices $lvmdevs for LVM volume groups $VGS"
Harald Hoyer 59f9af
     lvm vgscan --ignorelockingfailure 2>&1 | vinfo
Harald Hoyer 59f9af
-    lvm vgchange -ay --ignorelockingfailure $nopoll --ignoremonitoring $VGS 2>&1 | vinfo
Harald Hoyer 59f9af
+    if [ -z "$sysinit" ]; then
Harald Hoyer 59f9af
+        lvm vgchange -ay --ignorelockingfailure $nopoll --ignoremonitoring $VGS 2>&1 | vinfo
Harald Hoyer 59f9af
+    else
Harald Hoyer 59f9af
+        lvm vgchange -ay $sysinit $VGS 2>&1 | vinfo
Harald Hoyer 59f9af
+    fi
Harald Hoyer 59f9af
 fi
Harald Hoyer 59f9af
 
Harald Hoyer 59f9af
 if [ "$lvmwritten" ]; then