include rescan-scsi-bus script 1.56
This commit is contained in:
parent
9e5601691b
commit
251fe3bbfc
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@ sg3_utils-1.29.tgz
|
|||||||
rescan-scsi-bus.sh-1.35
|
rescan-scsi-bus.sh-1.35
|
||||||
/sg3_utils-1.31.tgz
|
/sg3_utils-1.31.tgz
|
||||||
/sg3_utils-1.33.tgz
|
/sg3_utils-1.33.tgz
|
||||||
|
/rescan-scsi-bus.sh-1.56
|
||||||
|
@ -1,194 +0,0 @@
|
|||||||
From 38842b5eafcd85bc91d96e2b2d0b99ea8864d907 Mon Sep 17 00:00:00 2001
|
|
||||||
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan@danny.cz>
|
|
||||||
Date: Thu, 14 Jan 2010 12:50:05 +0100
|
|
||||||
Subject: [PATCH 1/4] netapp - fixes in doreportlun
|
|
||||||
|
|
||||||
---
|
|
||||||
rescan-scsi-bus.sh | 64 ++++++++++++++++++++++++++++++++++------------------
|
|
||||||
1 files changed, 42 insertions(+), 22 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/rescan-scsi-bus.sh b/rescan-scsi-bus.sh
|
|
||||||
index af1f843..8d52e39 100644
|
|
||||||
--- a/rescan-scsi-bus.sh
|
|
||||||
+++ b/rescan-scsi-bus.sh
|
|
||||||
@@ -371,38 +371,58 @@ dolunscan()
|
|
||||||
# Perform report lun scan
|
|
||||||
doreportlun()
|
|
||||||
{
|
|
||||||
- lun=0
|
|
||||||
+ lun=
|
|
||||||
SCSISTR=
|
|
||||||
- devnr="$host $channel $id $lun"
|
|
||||||
- echo "Scanning for device $devnr ..."
|
|
||||||
- #printf "${yellow}OLD: $norm"
|
|
||||||
- testexist -q
|
|
||||||
- if test -z "$SCSISTR"; then
|
|
||||||
- # Device does not exist, try to add
|
|
||||||
- #printf "\r${green}NEW: $norm"
|
|
||||||
- if test -e /sys/class/scsi_host/host${host}/scan; then
|
|
||||||
- echo "$channel $id $lun" > /sys/class/scsi_host/host${host}/scan 2> /dev/null
|
|
||||||
- else
|
|
||||||
- echo "scsi add-single-device $devnr" > /proc/scsi/scsi
|
|
||||||
- fi
|
|
||||||
+ for dev in /sys/class/scsi_device/${host}:${channel}:${id}:*; do
|
|
||||||
+ if [ -d "$dev" ]; then
|
|
||||||
+ lun=${dev##*:}
|
|
||||||
+ break
|
|
||||||
+ else
|
|
||||||
+ continue
|
|
||||||
+ fi
|
|
||||||
+ done
|
|
||||||
+ #If not a single LUN is present then assign lun=0
|
|
||||||
+ if [ -z $lun ]; then
|
|
||||||
+ lun=0
|
|
||||||
+ devnr="$host $channel $id $lun"
|
|
||||||
+ echo "Scanning for device $devnr ..."
|
|
||||||
+ printf "${yellow}OLD: $norm"
|
|
||||||
testexist -1
|
|
||||||
if test -z "$SCSISTR"; then
|
|
||||||
- # Device not present
|
|
||||||
- printf "\r\x1b[A";
|
|
||||||
- lunsearch=
|
|
||||||
- return
|
|
||||||
+ # Device does not exist, try to add
|
|
||||||
+ printf "\r${green}NEW: $norm"
|
|
||||||
+ if test -e /sys/class/scsi_host/host${host}/scan; then
|
|
||||||
+ echo "$channel $id $lun" > /sys/class/scsi_host/host${host}/scan 2> /dev/null
|
|
||||||
+ else
|
|
||||||
+ echo "scsi add-single-device $devnr" > /proc/scsi/scsi
|
|
||||||
+ fi
|
|
||||||
+ testexist
|
|
||||||
+ if test -z "$SCSISTR"; then
|
|
||||||
+ # Device not present
|
|
||||||
+ printf "\r\x1b[A";
|
|
||||||
+ lunsearch=
|
|
||||||
+ return
|
|
||||||
+ fi
|
|
||||||
fi
|
|
||||||
#testonline
|
|
||||||
fi
|
|
||||||
- lunsearch=`getluns`
|
|
||||||
+ flag=0
|
|
||||||
+ lun_search="`getluns`"
|
|
||||||
+ # Set flag=1 if all the LUNs are removed
|
|
||||||
+ if [ "${#lun_search}" = "1" ]; then
|
|
||||||
+ flag=1
|
|
||||||
+ fi
|
|
||||||
lunremove=
|
|
||||||
# Check existing luns
|
|
||||||
for dev in /sys/class/scsi_device/${host}:${channel}:${id}:*; do
|
|
||||||
[ -d "$dev" ] || continue
|
|
||||||
lun=${dev##*:}
|
|
||||||
+ if [ "$flag" = "1" ]; then
|
|
||||||
+ lunremove="$lunremove $lun"
|
|
||||||
+ fi
|
|
||||||
newsearch=
|
|
||||||
- oldsearch="$lunsearch"
|
|
||||||
- for tmplun in $lunsearch; do
|
|
||||||
+ oldsearch="$lun_search"
|
|
||||||
+ for tmplun in $lun_search; do
|
|
||||||
if test $tmplun -eq $lun ; then
|
|
||||||
dolunscan
|
|
||||||
else
|
|
||||||
@@ -413,10 +433,10 @@ doreportlun()
|
|
||||||
# Stale lun
|
|
||||||
lunremove="$lunremove $lun"
|
|
||||||
fi
|
|
||||||
- lunsearch="$newsearch"
|
|
||||||
+ lun_search="$newsearch"
|
|
||||||
done
|
|
||||||
# Add new ones and check stale ones
|
|
||||||
- for lun in $lunsearch $lunremove; do
|
|
||||||
+ for lun in $lun_search $lunremove; do
|
|
||||||
dolunscan
|
|
||||||
done
|
|
||||||
}
|
|
||||||
--
|
|
||||||
1.6.5.2
|
|
||||||
|
|
||||||
From 0e94e0c27d575f18a57938b9d98dfe02d8c11eb9 Mon Sep 17 00:00:00 2001
|
|
||||||
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan@danny.cz>
|
|
||||||
Date: Thu, 14 Jan 2010 12:50:59 +0100
|
|
||||||
Subject: [PATCH 2/4] netapp - LIP is not required to do a scan on FC
|
|
||||||
|
|
||||||
---
|
|
||||||
rescan-scsi-bus.sh | 3 +--
|
|
||||||
1 files changed, 1 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/rescan-scsi-bus.sh b/rescan-scsi-bus.sh
|
|
||||||
index 8d52e39..13e9283 100644
|
|
||||||
--- a/rescan-scsi-bus.sh
|
|
||||||
+++ b/rescan-scsi-bus.sh
|
|
||||||
@@ -587,11 +587,10 @@ declare -i rmvd=0
|
|
||||||
for host in $hosts; do
|
|
||||||
echo -n "Scanning host $host "
|
|
||||||
if test -e /sys/class/fc_host/host$host ; then
|
|
||||||
- # It's pointless to do a target scan on FC
|
|
||||||
if test -n "$lipreset" ; then
|
|
||||||
echo 1 > /sys/class/fc_host/host$host/issue_lip 2> /dev/null;
|
|
||||||
- echo "- - -" > /sys/class/scsi_host/host$host/scan 2> /dev/null;
|
|
||||||
fi
|
|
||||||
+ echo "- - -" > /sys/class/scsi_host/host$host/scan 2> /dev/null;
|
|
||||||
channelsearch=""
|
|
||||||
idsearch=""
|
|
||||||
fi
|
|
||||||
--
|
|
||||||
1.6.5.2
|
|
||||||
|
|
||||||
From c3b67a28289bb010d141e172a184982c40e2fff2 Mon Sep 17 00:00:00 2001
|
|
||||||
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan@danny.cz>
|
|
||||||
Date: Thu, 14 Jan 2010 12:51:31 +0100
|
|
||||||
Subject: [PATCH 3/4] space before getluns call is required
|
|
||||||
|
|
||||||
---
|
|
||||||
rescan-scsi-bus.sh | 2 +-
|
|
||||||
1 files changed, 1 insertions(+), 1 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/rescan-scsi-bus.sh b/rescan-scsi-bus.sh
|
|
||||||
index 13e9283..26a9853 100644
|
|
||||||
--- a/rescan-scsi-bus.sh
|
|
||||||
+++ b/rescan-scsi-bus.sh
|
|
||||||
@@ -407,7 +407,7 @@ doreportlun()
|
|
||||||
#testonline
|
|
||||||
fi
|
|
||||||
flag=0
|
|
||||||
- lun_search="`getluns`"
|
|
||||||
+ lun_search=" `getluns`"
|
|
||||||
# Set flag=1 if all the LUNs are removed
|
|
||||||
if [ "${#lun_search}" = "1" ]; then
|
|
||||||
flag=1
|
|
||||||
--
|
|
||||||
1.6.5.2
|
|
||||||
|
|
||||||
From 5c10b085e2e83f371eddee16937157b0e7f63d5b Mon Sep 17 00:00:00 2001
|
|
||||||
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan@danny.cz>
|
|
||||||
Date: Thu, 14 Jan 2010 15:15:34 +0100
|
|
||||||
Subject: [PATCH 4/4] wait for device
|
|
||||||
|
|
||||||
When a device reports "unit attention" state after calling sg_turs, then wait until the device comes online or a timeout is reached.
|
|
||||||
---
|
|
||||||
rescan-scsi-bus.sh | 8 ++++++--
|
|
||||||
1 files changed, 6 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/rescan-scsi-bus.sh b/rescan-scsi-bus.sh
|
|
||||||
index 26a9853..23fba7d 100644
|
|
||||||
--- a/rescan-scsi-bus.sh
|
|
||||||
+++ b/rescan-scsi-bus.sh
|
|
||||||
@@ -195,8 +195,12 @@ testonline ()
|
|
||||||
if test ! -x /usr/bin/sg_turs; then return 0; fi
|
|
||||||
sgdevice
|
|
||||||
if test -z "$SGDEV"; then return 0; fi
|
|
||||||
- sg_turs /dev/$SGDEV >/dev/null 2>&1
|
|
||||||
- RC=$?
|
|
||||||
+ for t in 1 2 3 4 5; do
|
|
||||||
+ sg_turs /dev/$SGDEV >/dev/null 2>&1
|
|
||||||
+ RC=$?
|
|
||||||
+ [ $RC -ne 6 ] && break
|
|
||||||
+ sleep $t
|
|
||||||
+ done
|
|
||||||
# echo -e "\e[A\e[A\e[A${yellow}Test existence of $SGDEV = $RC ${norm} \n\n\n"
|
|
||||||
if test $RC = 1; then return $RC; fi
|
|
||||||
# OK, device online, compare INQUIRY string
|
|
||||||
--
|
|
||||||
1.6.5.2
|
|
||||||
|
|
@ -1,15 +1,14 @@
|
|||||||
%define rescan_version 1.35
|
%define rescan_version 1.56
|
||||||
%define rescan_script rescan-scsi-bus.sh
|
%define rescan_script rescan-scsi-bus.sh
|
||||||
|
|
||||||
Summary: Utilities for devices that use SCSI command sets
|
Summary: Utilities for devices that use SCSI command sets
|
||||||
Name: sg3_utils
|
Name: sg3_utils
|
||||||
Version: 1.33
|
Version: 1.33
|
||||||
Release: 1%{?dist}
|
Release: 2%{?dist}
|
||||||
License: GPLv2+ and BSD
|
License: GPLv2+ and BSD
|
||||||
Group: Applications/System
|
Group: Applications/System
|
||||||
Source0: http://sg.danny.cz/sg/p/sg3_utils-%{version}.tgz
|
Source0: http://sg.danny.cz/sg/p/sg3_utils-%{version}.tgz
|
||||||
Source1: http://www.garloff.de/kurt/linux/%{rescan_script}-%{rescan_version}
|
Source1: http://www.garloff.de/kurt/linux/%{rescan_script}-%{rescan_version}
|
||||||
Patch100: rescan-scsi-bus-fixes.patch
|
|
||||||
URL: http://sg.danny.cz/sg/sg3_utils.html
|
URL: http://sg.danny.cz/sg/sg3_utils.html
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||||
Requires: %{name}-libs = %{version}-%{release}
|
Requires: %{name}-libs = %{version}-%{release}
|
||||||
@ -51,7 +50,6 @@ developing applications.
|
|||||||
|
|
||||||
# rescan-scsi-bus.sh
|
# rescan-scsi-bus.sh
|
||||||
cp -p %{SOURCE1} %{rescan_script}
|
cp -p %{SOURCE1} %{rescan_script}
|
||||||
%patch100 -p1 -b .orig
|
|
||||||
|
|
||||||
|
|
||||||
%build
|
%build
|
||||||
@ -99,6 +97,9 @@ rm -rf $RPM_BUILD_ROOT
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Apr 4 2012 Dan Horák <dan@danny.cz> - 1.33-2
|
||||||
|
- include rescan-scsi-bus script 1.56
|
||||||
|
|
||||||
* Tue Apr 3 2012 Dan Horák <dan@danny.cz> - 1.33-1
|
* Tue Apr 3 2012 Dan Horák <dan@danny.cz> - 1.33-1
|
||||||
- update to version 1.33
|
- update to version 1.33
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user