Blob Blame History Raw
From 9ab4c18355df1e55c39ca96f27ddb9b540054286 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Wed, 8 Dec 2021 14:43:58 -0600
Subject: [PATCH] feat(lvm): update lvm command options

Drop checking for options that have been available for
at least ten years.  This simplifies code maintenance.

Add the new --nohints option (when available) to disable
the use of hints which is not useful during startup.

(cherry picked from commit c0a54f2993b1d3c2101202c274a41f925445d54b)

Resolves: #2037955
---
 modules.d/90lvm/lvm_scan.sh | 41 ++++++++++++++++++++++-------------------
 1 file changed, 22 insertions(+), 19 deletions(-)

diff --git a/modules.d/90lvm/lvm_scan.sh b/modules.d/90lvm/lvm_scan.sh
index 80382407..00143bff 100755
--- a/modules.d/90lvm/lvm_scan.sh
+++ b/modules.d/90lvm/lvm_scan.sh
@@ -59,39 +59,42 @@ min=$2
 sub=${3%% *}
 sub=${sub%%\(*}
 
-lvm_ignorelockingfailure="--ignorelockingfailure"
-lvm_quirk_args="--ignorelockingfailure --ignoremonitoring"
-
-check_lvm_ver 2 2 57 "$maj" "$min" "$sub" \
-    && lvm_quirk_args="$lvm_quirk_args --poll n"
-
-if check_lvm_ver 2 2 65 "$maj" "$min" "$sub"; then
-    lvm_quirk_args=" --sysinit $extraargs"
-fi
-
-if check_lvm_ver 2 2 221 "$maj" "$min" "$sub"; then
-    lvm_quirk_args=" $extraargs"
-    unset lvm_ignorelockingfailure
-fi
-
+# For lvchange and vgchange use --sysinit which:
+# disables polling (--poll n)
+# ignores monitoring (--ignoremonitoring)
+# ignores locking failures (--ignorelockingfailure)
+# disables hints (--nohints)
+#
+# For lvscan and vgscan:
+# disable locking (--nolocking)
+# disable hints (--nohints)
+
+activate_args="--sysinit $extraargs"
 unset extraargs
 
 export LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES=1
 
+scan_args="--nolocking"
+
+check_lvm_ver 2 3 14 "$maj" "$min" "$sub" \
+    && scan_args="$scan_args --nohints"
+
 if [ -n "$LVS" ]; then
     info "Scanning devices $lvmdevs for LVM logical volumes $LVS"
-    lvm lvscan $lvm_ignorelockingfailure 2>&1 | vinfo
+    # shellcheck disable=SC2086
+    lvm lvscan $scan_args 2>&1 | vinfo
     for LV in $LVS; do
         # shellcheck disable=SC2086
-        lvm lvchange --yes -K -ay $lvm_quirk_args "$LV" 2>&1 | vinfo
+        lvm lvchange --yes -K -ay $activate_args "$LV" 2>&1 | vinfo
     done
 fi
 
 if [ -z "$LVS" ] || [ -n "$VGS" ]; then
     info "Scanning devices $lvmdevs for LVM volume groups $VGS"
-    lvm vgscan $lvm_ignorelockingfailure 2>&1 | vinfo
     # shellcheck disable=SC2086
-    lvm vgchange -ay $lvm_quirk_args $VGS 2>&1 | vinfo
+    lvm vgscan $scan_args 2>&1 | vinfo
+    # shellcheck disable=SC2086
+    lvm vgchange -ay $activate_args $VGS 2>&1 | vinfo
 fi
 
 if [ "$lvmwritten" ]; then