|
|
059e59 |
From ec9b1e872ad3be0ec9440927a0f702c7bfa80932 Mon Sep 17 00:00:00 2001
|
|
|
059e59 |
From: David Teigland <teigland@redhat.com>
|
|
|
059e59 |
Date: Fri, 10 Dec 2021 12:51:26 -0600
|
|
|
059e59 |
Subject: [PATCH] feat(lvm): only run lvchange for LV that is seen on devices
|
|
|
059e59 |
|
|
|
059e59 |
Change the command listing LVs from lvscan to lvs, and list
|
|
|
059e59 |
only the LV names that are being activated. Before attempting
|
|
|
059e59 |
to activate an LV, check that that LV name appears in the
|
|
|
059e59 |
lvs command output. This avoids wasting time running an
|
|
|
059e59 |
lvchange command that we know will fail.
|
|
|
059e59 |
|
|
|
059e59 |
(cherry picked from commit 1af46743195422aaebcde5c508a5dd479eff51ea)
|
|
|
059e59 |
|
|
|
059e59 |
Resolves: #2037955
|
|
|
059e59 |
---
|
|
|
059e59 |
modules.d/90lvm/lvm_scan.sh | 18 ++++++++++++++----
|
|
|
059e59 |
1 file changed, 14 insertions(+), 4 deletions(-)
|
|
|
059e59 |
|
|
|
059e59 |
diff --git a/modules.d/90lvm/lvm_scan.sh b/modules.d/90lvm/lvm_scan.sh
|
|
|
059e59 |
index bda265f6..89f077ae 100755
|
|
|
059e59 |
--- a/modules.d/90lvm/lvm_scan.sh
|
|
|
059e59 |
+++ b/modules.d/90lvm/lvm_scan.sh
|
|
|
059e59 |
@@ -119,7 +119,7 @@ sub=${sub%%\(*}
|
|
|
059e59 |
# ignores locking failures (--ignorelockingfailure)
|
|
|
059e59 |
# disables hints (--nohints)
|
|
|
059e59 |
#
|
|
|
059e59 |
-# For lvscan and vgscan:
|
|
|
059e59 |
+# For lvs and vgscan:
|
|
|
059e59 |
# disable locking (--nolocking)
|
|
|
059e59 |
# disable hints (--nohints)
|
|
|
059e59 |
|
|
|
059e59 |
@@ -136,10 +136,20 @@ check_lvm_ver 2 3 14 "$maj" "$min" "$sub" \
|
|
|
059e59 |
if [ -n "$LVS" ]; then
|
|
|
059e59 |
info "Scanning devices $lvmdevs for LVM logical volumes $LVS"
|
|
|
059e59 |
# shellcheck disable=SC2086
|
|
|
059e59 |
- lvm lvscan $scan_args 2>&1 | vinfo
|
|
|
059e59 |
+ LVSLIST=$(lvm lvs $scan_args --noheading -o lv_full_name,segtype $LVS)
|
|
|
059e59 |
+ info "$LVSLIST"
|
|
|
059e59 |
+
|
|
|
059e59 |
+ # Only attempt to activate an LV if it appears in the lvs output.
|
|
|
059e59 |
for LV in $LVS; do
|
|
|
059e59 |
- # shellcheck disable=SC2086
|
|
|
059e59 |
- lvm lvchange --yes -K -ay $activate_args "$LV" 2>&1 | vinfo
|
|
|
059e59 |
+ if strstr "$LVSLIST" "$LV"; then
|
|
|
059e59 |
+ # This lvchange is expected to fail if all PVs used by
|
|
|
059e59 |
+ # the LV are not yet present. Premature/failed lvchange
|
|
|
059e59 |
+ # could be avoided by reporting if an LV is complete
|
|
|
059e59 |
+ # from the lvs command above and skipping this lvchange
|
|
|
059e59 |
+ # if the LV is not lised as complete.
|
|
|
059e59 |
+ # shellcheck disable=SC2086
|
|
|
059e59 |
+ lvm lvchange --yes -K -ay $activate_args "$LV" 2>&1 | vinfo
|
|
|
059e59 |
+ fi
|
|
|
059e59 |
done
|
|
|
059e59 |
fi
|
|
|
059e59 |
|
|
|
059e59 |
|