Blame SOURCES/0269-fcoe-fcoe-edd.sh-cleanup-the-script.patch

18971c
From 34203d03c0d43aa0aed12988d2719455e80eae54 Mon Sep 17 00:00:00 2001
18971c
From: Harald Hoyer <harald@redhat.com>
18971c
Date: Fri, 3 Jul 2015 13:52:32 +0200
18971c
Subject: [PATCH] fcoe/fcoe-edd.sh: cleanup the script
18971c
18971c
- check if modprobe was successful
18971c
- add a timeout for /sys/firmware/edd
18971c
- only remove the module, if it was loaded by the script
18971c
---
18971c
 modules.d/95fcoe/fcoe-edd.sh | 46 +++++++++++++++++++++++++-----------
18971c
 1 file changed, 32 insertions(+), 14 deletions(-)
18971c
18971c
diff --git a/modules.d/95fcoe/fcoe-edd.sh b/modules.d/95fcoe/fcoe-edd.sh
18971c
index d0ea60d5..8607b568 100755
18971c
--- a/modules.d/95fcoe/fcoe-edd.sh
18971c
+++ b/modules.d/95fcoe/fcoe-edd.sh
18971c
@@ -2,37 +2,55 @@
18971c
 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
18971c
 # ex: ts=8 sw=4 sts=4 et filetype=sh
18971c
 
18971c
-dcb=$1
18971c
+dcb="$1"
18971c
 
18971c
-if ! [ -d /sys/firmware/edd ]; then
18971c
-    modprobe edd
18971c
-    while ! [ -d /sys/firmware/edd ]; do sleep 0.1; done
18971c
-fi
18971c
+_modprobe_r_edd="0"
18971c
+
18971c
+check_edd() {
18971c
+    local cnt=0
18971c
+
18971c
+    [ -d /sys/firmware/edd ] && return 0
18971c
+
18971c
+    _modprobe_r_edd="1"
18971c
+    modprobe edd || return $?
18971c
+
18971c
+    while [ $cnt -lt 600 ]; do
18971c
+        [ -d /sys/firmware/edd ] && return 0
18971c
+        cnt=$(($cnt+1))
18971c
+        sleep 0.1
18971c
+    done
18971c
+    return 1
18971c
+}
18971c
+
18971c
+check_edd || exit 1
18971c
 
18971c
 for disk in /sys/firmware/edd/int13_*; do
18971c
-    [ -d $disk ] || continue
18971c
-    if [ -e ${disk}/pci_dev/driver ]; then
18971c
-	    driver=`readlink ${disk}/pci_dev/driver`
18971c
+    [ -d "$disk" ] || continue
18971c
+    if [ -e "${disk}/pci_dev/driver" ]; then
18971c
+	    driver=$(readlink "${disk}/pci_dev/driver")
18971c
 	    driver=${driver##*/}
18971c
     fi
18971c
     # i40e uses dev_port 1 for a virtual fcoe function
18971c
     if [ "${driver}" == "i40e" ]; then
18971c
 	    dev_port=1
18971c
     fi
18971c
-    for nic in ${disk}/pci_dev/net/*; do
18971c
-        [ -d $nic ] || continue
18971c
-	if [ -n "${dev_port}" -a -e ${nic}/dev_port ]; then
18971c
-		if [ `cat ${nic}/dev_port` -ne ${dev_port} ]; then
18971c
+    for nic in "${disk}"/pci_dev/net/*; do
18971c
+        [ -d "$nic" ] || continue
18971c
+	if [ -n "${dev_port}" -a -e "${nic}/dev_port" ]; then
18971c
+		if [ "$(cat ${nic}/dev_port)" -ne "${dev_port}" ]; then
18971c
 			continue
18971c
 		fi
18971c
 	fi
18971c
         if [ -e ${nic}/address ]; then
18971c
 	    fcoe_interface=${nic##*/}
18971c
 	    if ! [ -e "/tmp/.fcoe-$fcoe_interface" ]; then
18971c
-		/sbin/fcoe-up $fcoe_interface $dcb
18971c
+		/sbin/fcoe-up "$fcoe_interface" "$dcb"
18971c
 		> "/tmp/.fcoe-$fcoe_interface"
18971c
 	    fi
18971c
         fi
18971c
     done
18971c
 done
18971c
-modprobe -r edd
18971c
+
18971c
+[ "$_modprobe_r_edd" = "1" ] && modprobe -r edd
18971c
+
18971c
+unset _modprobe_r_edd