28ab1c
From 809423a5731e4433f3fa08e97ddf152e49cd00bf Mon Sep 17 00:00:00 2001
28ab1c
From: Kairui Song <kasong@redhat.com>
28ab1c
Date: Fri, 13 Nov 2020 18:08:47 +0800
28ab1c
Subject: [PATCH] 95fcoe: don't install if there is no FCoE hostonly devices
28ab1c
28ab1c
When in hostonly mode, 95fcoe module will still be installed even there
28ab1c
is no FCoE hostonly device. So use the new block_is_fcoe helper to check
28ab1c
for hostonly device in hostonly mode, avoid installing unneccessary module.
28ab1c
28ab1c
Signed-off-by: Kairui Song <kasong@redhat.com>
28ab1c
(cherry picked from commit 8c8af8a2cd728e917be8465c79b12149e6877aef)
28ab1c
28ab1c
Resolves: #1899456
28ab1c
---
28ab1c
 modules.d/95fcoe-uefi/module-setup.sh | 17 +++++------------
28ab1c
 modules.d/95fcoe/module-setup.sh      | 11 +++++------
28ab1c
 2 files changed, 10 insertions(+), 18 deletions(-)
28ab1c
28ab1c
diff --git a/modules.d/95fcoe-uefi/module-setup.sh b/modules.d/95fcoe-uefi/module-setup.sh
28ab1c
index a464df5a..9e5719df 100755
28ab1c
--- a/modules.d/95fcoe-uefi/module-setup.sh
28ab1c
+++ b/modules.d/95fcoe-uefi/module-setup.sh
28ab1c
@@ -2,22 +2,15 @@
28ab1c
 
28ab1c
 # called by dracut
28ab1c
 check() {
28ab1c
-    local _fcoe_ctlr
28ab1c
-    [[ $hostonly ]] || [[ $mount_needs ]] && {
28ab1c
-        for c in /sys/bus/fcoe/devices/ctlr_* ; do
28ab1c
-            [ -L $c ] || continue
28ab1c
-            _fcoe_ctlr=$c
28ab1c
-        done
28ab1c
-        [ -z "$_fcoe_ctlr" ] && return 255
28ab1c
+    is_fcoe() {
28ab1c
+        block_is_fcoe $1 || return 1
28ab1c
     }
28ab1c
+
28ab1c
     [[ $hostonly ]] || [[ $mount_needs ]] && {
28ab1c
+        for_each_host_dev_and_slaves is_fcoe || return 255
28ab1c
         [ -d /sys/firmware/efi ] || return 255
28ab1c
-        for c in /sys/bus/fcoe/devices/ctlr_* ; do
28ab1c
-            [ -L $c ] || continue
28ab1c
-            fcoe_ctlr=$c
28ab1c
-        done
28ab1c
-        [ -z "$fcoe_ctlr" ] && return 255
28ab1c
     }
28ab1c
+
28ab1c
     require_binaries dcbtool fipvlan lldpad ip readlink || return 1
28ab1c
     return 0
28ab1c
 }
28ab1c
diff --git a/modules.d/95fcoe/module-setup.sh b/modules.d/95fcoe/module-setup.sh
28ab1c
index c2224ec1..f5df705b 100755
28ab1c
--- a/modules.d/95fcoe/module-setup.sh
28ab1c
+++ b/modules.d/95fcoe/module-setup.sh
28ab1c
@@ -2,13 +2,12 @@
28ab1c
 
28ab1c
 # called by dracut
28ab1c
 check() {
28ab1c
-    local _fcoe_ctlr
28ab1c
+    is_fcoe() {
28ab1c
+        block_is_fcoe $1 || return 1
28ab1c
+    }
28ab1c
+
28ab1c
     [[ $hostonly ]] || [[ $mount_needs ]] && {
28ab1c
-        for c in /sys/bus/fcoe/devices/ctlr_* ; do
28ab1c
-            [ -L $c ] || continue
28ab1c
-            _fcoe_ctlr=$c
28ab1c
-        done
28ab1c
-        [ -z "$_fcoe_ctlr" ] && return 255
28ab1c
+        for_each_host_dev_and_slaves is_fcoe || return 255
28ab1c
     }
28ab1c
 
28ab1c
     require_binaries dcbtool fipvlan lldpad ip readlink fcoemon fcoeadm || return 1
28ab1c