1 Star 0 Fork 32

luck/dracut

forked from src-openEuler/dracut 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-feat-lvm-only-run-lvchange-for-LV-that-is-seen-on-de.patch 2.02 KB
一键复制 编辑 原始数据 按行查看 历史
panxiaohe 提交于 2022-04-11 17:17 . sync commits from branch 22.03
From 1af46743195422aaebcde5c508a5dd479eff51ea Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Fri, 10 Dec 2021 12:51:26 -0600
Subject: [PATCH] feat(lvm): only run lvchange for LV that is seen on devices
Change the command listing LVs from lvscan to lvs, and list
only the LV names that are being activated. Before attempting
to activate an LV, check that that LV name appears in the
lvs command output. This avoids wasting time running an
lvchange command that we know will fail.
---
modules.d/90lvm/lvm_scan.sh | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/modules.d/90lvm/lvm_scan.sh b/modules.d/90lvm/lvm_scan.sh
index bda265f..89f077a 100755
--- a/modules.d/90lvm/lvm_scan.sh
+++ b/modules.d/90lvm/lvm_scan.sh
@@ -119,7 +119,7 @@ sub=${sub%%\(*}
# ignores locking failures (--ignorelockingfailure)
# disables hints (--nohints)
#
-# For lvscan and vgscan:
+# For lvs and vgscan:
# disable locking (--nolocking)
# disable hints (--nohints)
@@ -136,10 +136,20 @@ check_lvm_ver 2 3 14 "$maj" "$min" "$sub" \
if [ -n "$LVS" ]; then
info "Scanning devices $lvmdevs for LVM logical volumes $LVS"
# shellcheck disable=SC2086
- lvm lvscan $scan_args 2>&1 | vinfo
+ LVSLIST=$(lvm lvs $scan_args --noheading -o lv_full_name,segtype $LVS)
+ info "$LVSLIST"
+
+ # Only attempt to activate an LV if it appears in the lvs output.
for LV in $LVS; do
- # shellcheck disable=SC2086
- lvm lvchange --yes -K -ay $activate_args "$LV" 2>&1 | vinfo
+ if strstr "$LVSLIST" "$LV"; then
+ # This lvchange is expected to fail if all PVs used by
+ # the LV are not yet present. Premature/failed lvchange
+ # could be avoided by reporting if an LV is complete
+ # from the lvs command above and skipping this lvchange
+ # if the LV is not lised as complete.
+ # shellcheck disable=SC2086
+ lvm lvchange --yes -K -ay $activate_args "$LV" 2>&1 | vinfo
+ fi
done
fi
--
1.8.3.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/luc_a/dracut.git
git@gitee.com:luc_a/dracut.git
luc_a
dracut
dracut
master

搜索帮助