aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2022-08-12 02:55:43 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2022-08-12 02:55:43 +0000
commit5a1cdabc085bc9ccaedc5aff7c49a2d0ea5d6e12 (patch)
tree6eac5ebd30eb2efe9d52da080cde33d375c5334b
parent048bd1272b7256331117b0e7b1ab5d22cf308067 (diff)
downloadsg3_utils-5a1cdabc085bc9ccaedc5aff7c49a2d0ea5d6e12.tar.gz
rescan-scsi-bus.sh: add option --no-lip-scan
lip is a FC operation and can be used to rescan device but it can not specify the channel and target. So add a new option to scan FC hosts according to the SCSI general interface in sysfs: /sys/class/scsi_host/hostX/scan. The default value of no_lip_scan is 0 which does not change the default behavior. Fix https://github.com/doug-gilbert/sg3_utils/issues/20 Signed-off-by: Wenchao Hao <haowenchao@huawei.com> git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@967 6180dd3e-e324-4e3e-922d-17de1ae2f315
-rw-r--r--ChangeLog1
-rw-r--r--doc/rescan-scsi-bus.sh.816
-rwxr-xr-xscripts/rescan-scsi-bus.sh7
3 files changed, 16 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 66a99646..ab1413b9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -25,6 +25,7 @@ Changelog for pre-release sg3_utils-1.48 [20220811] [svn: r966]
- fix handling of '-I <secs>' option
- sgdevice26: do not traverse sg class if scsi_device
is not added
+ - add -no-lip-scan option
- sg_rep_zones: add Report zone starting LBA granularity
field in REPORT ZONES response [zbc2r12]
- add --brief option, show part of header and last
diff --git a/doc/rescan-scsi-bus.sh.8 b/doc/rescan-scsi-bus.sh.8
index 1533791d..96f86c33 100644
--- a/doc/rescan-scsi-bus.sh.8
+++ b/doc/rescan-scsi-bus.sh.8
@@ -1,4 +1,4 @@
-.TH RESCAN\-SCSI\-BUS.SH "1" "May 2022" "rescan\-scsi\-bus.sh" "User Commands"
+.TH RESCAN\-SCSI\-BUS.SH "1" "August 2022" "rescan\-scsi\-bus.sh" "User Commands"
.SH NAME
rescan-scsi-bus.sh \- script to add and remove SCSI devices without rebooting
.SH SYNOPSIS
@@ -9,11 +9,12 @@ rescan-scsi-bus.sh \- script to add and remove SCSI devices without rebooting
[\fI\-\-hosts=HLIST\fR] [\fI\-\-ids=TLIST\fR] [\fI\-\-ignore\-rev\fR]
[\fI\-\-issue\-lip\fR] [\fI\-i\fR] [\fI\-\-issue\-lip\-wait=SECS\fR]
[\fI\-I SECS\fR] [\fI\-l\fR] [\fI\-L NUM\fR] [\fI\-\-largelun\fR]
-[\fI\-\-luns=LLIST\fR] [\fI\-m\fR] [\fI\-\-multipath\fR] [\fI\-\-nooptscan\fR]
-[\fI\-\-nosync\fR] [\fI\-\-remove\fR] [\fI\-\-removelun2\fR]
-[\fI\-\-resize\fR] [\fI\-\-sparselun\fR] [\fI\-\-sync\fR]
-[\fI\-\-timeout=SECS\fR] [\fI\-\-update\fR] [\fI\-\-version\fR]
-[\fI\-\-wide\fR] [\fIHOST1 \fR[\fIHOST2 \fR...]]
+[\fI\-\-luns=LLIST\fR] [\fI\-m\fR] [\fI\-\-multipath\fR]
+[\fI\-\-no\-lip\-scan\fR] [\fI\-\-nooptscan\fR] [\fI\-\-nosync\fR]
+[\fI\-\-remove\fR] [\fI\-\-removelun2\fR] [\fI\-\-resize\fR]
+[\fI\-\-sparselun\fR] [\fI\-\-sync\fR] [\fI\-\-timeout=SECS\fR]
+[\fI\-\-update\fR] [\fI\-\-version\fR] [\fI\-\-wide\fR]
+[\fIHOST1 \fR[\fIHOST2 \fR...]]
.SH OPTIONS
Option are ordered by their long name. Those without a long name are ordered
as if their single letter was a long name.
@@ -79,6 +80,9 @@ scan only lun(s) in \fINLIST\fR
\fB\-m\fR, \fB\-\-multipath\fR
update multipath devices [default: disabled]
.TP
+\fB\-\-no\-lip\-scan\fR
+don't scan FC Host when the \fI\-\-issue\-lip\fR option is also given.
+.TP
\fB\-\-nooptscan\fR
don't stop looking for LUNs is 0 is not found
.TP
diff --git a/scripts/rescan-scsi-bus.sh b/scripts/rescan-scsi-bus.sh
index f3e3b2c6..e9bccbac 100755
--- a/scripts/rescan-scsi-bus.sh
+++ b/scripts/rescan-scsi-bus.sh
@@ -4,7 +4,7 @@
# (c) 2006--2022 Hannes Reinecke, GNU GPL v2 or later
# $Id: rescan-scsi-bus.sh,v 1.57 2012/03/31 14:08:48 garloff Exp $
-VERSION="20220622"
+VERSION="20220811"
SCAN_WILD_CARD=4294967295
setcolor ()
@@ -1151,6 +1151,7 @@ if [ "@$1" = @--help ] || [ "@$1" = @-h ] || [ "@$1" = "@-?" ] ; then
echo "--largelun: Tell kernel to support LUNs > 7 even on SCSI2 devs"
echo "--luns=LIST: Scan only lun(s) in LIST"
echo "--multipath: same as -m"
+ echo "--no-lip-scan: don't scan FC Host with issue-lip"
echo "--nooptscan: don't stop looking for LUNs if 0 is not found"
echo "--remove: same as -r"
echo "--reportlun2: Tell kernel to try REPORT_LUN even on SCSI2 devices"
@@ -1221,6 +1222,7 @@ lipreset=-1
timeout=30
declare -i scan_flags=0
ignore_rev=0
+no_lip_scan=0
# Scan options
opt="$1"
@@ -1256,6 +1258,7 @@ while [ ! -z "$opt" ] && [ -z "${opt##-*}" ] ; do
-largelun) scan_flags=$((scan_flags|0x200)) ;;
-luns=*) arg=${opt#-luns=}; lunsearch=$(expandlist "$arg") ;;
-multipath) mp_enable=1 ;;
+ -no-lip-scan) no_lip_scan=1 ;;
-nooptscan) optscan=0 ;;
-nosync) sync=0 ;;
-remove) remove=1 ;;
@@ -1334,7 +1337,7 @@ elif [ $resize -eq 1 ] ; then
else
for host in $hosts; do
echo -n "Scanning host $host "
- if [ -e "/sys/class/fc_host/host$host" ] ; then
+ if [ $no_lip_scan -eq 0 ] && [ -e "/sys/class/fc_host/host$host" ] ; then
# It's pointless to do a target scan on FC
issue_lip=/sys/class/fc_host/host$host/issue_lip
if [ -e "$issue_lip" ] && [ "$lipreset" -ge 0 ] ; then