059e59
From 9ab4c18355df1e55c39ca96f27ddb9b540054286 Mon Sep 17 00:00:00 2001
059e59
From: David Teigland <teigland@redhat.com>
059e59
Date: Wed, 8 Dec 2021 14:43:58 -0600
059e59
Subject: [PATCH] feat(lvm): update lvm command options
059e59
059e59
Drop checking for options that have been available for
059e59
at least ten years.  This simplifies code maintenance.
059e59
059e59
Add the new --nohints option (when available) to disable
059e59
the use of hints which is not useful during startup.
059e59
059e59
(cherry picked from commit c0a54f2993b1d3c2101202c274a41f925445d54b)
059e59
059e59
Resolves: #2037955
059e59
---
059e59
 modules.d/90lvm/lvm_scan.sh | 41 ++++++++++++++++++++++-------------------
059e59
 1 file changed, 22 insertions(+), 19 deletions(-)
059e59
059e59
diff --git a/modules.d/90lvm/lvm_scan.sh b/modules.d/90lvm/lvm_scan.sh
059e59
index 80382407..00143bff 100755
059e59
--- a/modules.d/90lvm/lvm_scan.sh
059e59
+++ b/modules.d/90lvm/lvm_scan.sh
059e59
@@ -59,39 +59,42 @@ min=$2
059e59
 sub=${3%% *}
059e59
 sub=${sub%%\(*}
059e59
 
059e59
-lvm_ignorelockingfailure="--ignorelockingfailure"
059e59
-lvm_quirk_args="--ignorelockingfailure --ignoremonitoring"
059e59
-
059e59
-check_lvm_ver 2 2 57 "$maj" "$min" "$sub" \
059e59
-    && lvm_quirk_args="$lvm_quirk_args --poll n"
059e59
-
059e59
-if check_lvm_ver 2 2 65 "$maj" "$min" "$sub"; then
059e59
-    lvm_quirk_args=" --sysinit $extraargs"
059e59
-fi
059e59
-
059e59
-if check_lvm_ver 2 2 221 "$maj" "$min" "$sub"; then
059e59
-    lvm_quirk_args=" $extraargs"
059e59
-    unset lvm_ignorelockingfailure
059e59
-fi
059e59
-
059e59
+# For lvchange and vgchange use --sysinit which:
059e59
+# disables polling (--poll n)
059e59
+# ignores monitoring (--ignoremonitoring)
059e59
+# ignores locking failures (--ignorelockingfailure)
059e59
+# disables hints (--nohints)
059e59
+#
059e59
+# For lvscan and vgscan:
059e59
+# disable locking (--nolocking)
059e59
+# disable hints (--nohints)
059e59
+
059e59
+activate_args="--sysinit $extraargs"
059e59
 unset extraargs
059e59
 
059e59
 export LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES=1
059e59
 
059e59
+scan_args="--nolocking"
059e59
+
059e59
+check_lvm_ver 2 3 14 "$maj" "$min" "$sub" \
059e59
+    && scan_args="$scan_args --nohints"
059e59
+
059e59
 if [ -n "$LVS" ]; then
059e59
     info "Scanning devices $lvmdevs for LVM logical volumes $LVS"
059e59
-    lvm lvscan $lvm_ignorelockingfailure 2>&1 | vinfo
059e59
+    # shellcheck disable=SC2086
059e59
+    lvm lvscan $scan_args 2>&1 | vinfo
059e59
     for LV in $LVS; do
059e59
         # shellcheck disable=SC2086
059e59
-        lvm lvchange --yes -K -ay $lvm_quirk_args "$LV" 2>&1 | vinfo
059e59
+        lvm lvchange --yes -K -ay $activate_args "$LV" 2>&1 | vinfo
059e59
     done
059e59
 fi
059e59
 
059e59
 if [ -z "$LVS" ] || [ -n "$VGS" ]; then
059e59
     info "Scanning devices $lvmdevs for LVM volume groups $VGS"
059e59
-    lvm vgscan $lvm_ignorelockingfailure 2>&1 | vinfo
059e59
     # shellcheck disable=SC2086
059e59
-    lvm vgchange -ay $lvm_quirk_args $VGS 2>&1 | vinfo
059e59
+    lvm vgscan $scan_args 2>&1 | vinfo
059e59
+    # shellcheck disable=SC2086
059e59
+    lvm vgchange -ay $activate_args $VGS 2>&1 | vinfo
059e59
 fi
059e59
 
059e59
 if [ "$lvmwritten" ]; then
059e59