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