backport rescan-scsi-bus patches from mainline
rescan-scsi-bus: sgdevice26: do not traverse sg class if scsi_device isnot added, which would speed up the rescan flow. rescan-scsi-bus.sh: add option --no-lip-scan, which would make FC can rescan device with specific channel and target Signed-off-by: Wenchao Hao <haowenchao@huawei.com>
This commit is contained in:
parent
c5e5eef3e9
commit
bde7a88707
@ -0,0 +1,57 @@
|
|||||||
|
From 4ea97e60c544ad44ee7396c815064d87f0d25874 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Douglas Gilbert <dgilbert@interlog.com>
|
||||||
|
Date: Sun, 7 Aug 2022 02:49:03 +0000
|
||||||
|
Subject: [PATCH] rescan-scsi-bus: sgdevice26: do not traverse sg class if
|
||||||
|
scsi_device isnot added
|
||||||
|
|
||||||
|
For system which has a massive number of scsi_devices, it would takes a long time to
|
||||||
|
traverse /sys/class/scsi_generic to find a related sg. If the scsi_device of specific
|
||||||
|
scsiid host:channel:target:lun did not added, the traverse would find no sg neither.
|
||||||
|
|
||||||
|
Signed-off-by: Wenchao Hao <haowenchao@huawei.com>
|
||||||
|
|
||||||
|
From: https://github.com/doug-gilbert/sg3_utils/pull/21
|
||||||
|
|
||||||
|
|
||||||
|
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@965 6180dd3e-e324-4e3e-922d-17de1ae2f315
|
||||||
|
---
|
||||||
|
scripts/rescan-scsi-bus.sh | 19 +++++++++++--------
|
||||||
|
1 file changed, 11 insertions(+), 8 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/scripts/rescan-scsi-bus.sh b/scripts/rescan-scsi-bus.sh
|
||||||
|
index 0c33384..f3e3b2c 100755
|
||||||
|
--- a/scripts/rescan-scsi-bus.sh
|
||||||
|
+++ b/scripts/rescan-scsi-bus.sh
|
||||||
|
@@ -184,18 +184,21 @@ sgdevice26 ()
|
||||||
|
{
|
||||||
|
local gendev
|
||||||
|
|
||||||
|
+ # if the scsi device has not been added, then there would not
|
||||||
|
+ # a related sgdev. So it's pointless to scan all sgs to find
|
||||||
|
+ # a related sg.
|
||||||
|
+ scsidev=/sys/class/scsi_device/${host}:${channel}:${id}:${lun}
|
||||||
|
+ if [ ! -e "$scsidev" ]; then
|
||||||
|
+ SGDEV=""
|
||||||
|
+ return
|
||||||
|
+ fi
|
||||||
|
+
|
||||||
|
gendev=/sys/class/scsi_device/${host}:${channel}:${id}:${lun}/device/generic
|
||||||
|
if [ -e "$gendev" ] ; then
|
||||||
|
SGDEV=$(basename "$(readlink "$gendev")")
|
||||||
|
- else
|
||||||
|
- for SGDEV in /sys/class/scsi_generic/sg*; do
|
||||||
|
- DEV=$(readlink "$SGDEV/device")
|
||||||
|
- if [ "${DEV##*/}" = "$host:$channel:$id:$lun" ] ; then
|
||||||
|
- SGDEV=$(basename "$SGDEV"); return
|
||||||
|
- fi
|
||||||
|
- done
|
||||||
|
- SGDEV=""
|
||||||
|
+ return
|
||||||
|
fi
|
||||||
|
+ SGDEV=""
|
||||||
|
}
|
||||||
|
|
||||||
|
# Find sg device with 2.4 report-devs extensions
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
62
0007-rescan-scsi-bus.sh-add-option-no-lip-scan.patch
Normal file
62
0007-rescan-scsi-bus.sh-add-option-no-lip-scan.patch
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
From b109bf4c5bacf65d32d2ab4fb990efb5230fda27 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Douglas Gilbert <dgilbert@interlog.com>
|
||||||
|
Date: Fri, 12 Aug 2022 02:55:43 +0000
|
||||||
|
Subject: [PATCH] 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
|
||||||
|
---
|
||||||
|
scripts/rescan-scsi-bus.sh | 5 ++++-
|
||||||
|
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/scripts/rescan-scsi-bus.sh b/scripts/rescan-scsi-bus.sh
|
||||||
|
index 31ae736..67dccf3 100755
|
||||||
|
--- a/scripts/rescan-scsi-bus.sh
|
||||||
|
+++ b/scripts/rescan-scsi-bus.sh
|
||||||
|
@@ -1158,6 +1158,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"
|
||||||
|
@@ -1226,6 +1227,7 @@ mp_enable=
|
||||||
|
lipreset=-1
|
||||||
|
declare -i scan_flags=0
|
||||||
|
ignore_rev=0
|
||||||
|
+no_lip_scan=0
|
||||||
|
|
||||||
|
# Scan options
|
||||||
|
opt="$1"
|
||||||
|
@@ -1260,6 +1262,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 ;;
|
||||||
|
@@ -1337,7 +1340,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
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
Name: sg3_utils
|
Name: sg3_utils
|
||||||
Version: 1.47
|
Version: 1.47
|
||||||
Release: 1
|
Release: 2
|
||||||
Summary: Utilities that send SCSI commands to devices.
|
Summary: Utilities that send SCSI commands to devices.
|
||||||
License: GPL-2.0-or-later AND BSD
|
License: GPL-2.0-or-later AND BSD
|
||||||
URL: http://sg.danny.cz/sg/sg3_utils.html
|
URL: http://sg.danny.cz/sg/sg3_utils.html
|
||||||
@ -12,6 +12,8 @@ Patch2: 0002-bugfix-sg3_utils-fix-syntax-error.patch
|
|||||||
Patch3: 0003-sg3_utils-1.42-delete-lun-rescan-scsi-bus-report-error.patch
|
Patch3: 0003-sg3_utils-1.42-delete-lun-rescan-scsi-bus-report-error.patch
|
||||||
Patch4: 0004-sg3_utils-rescan-scsi-bus-list-all-LUNs-in-one-line.patch
|
Patch4: 0004-sg3_utils-rescan-scsi-bus-list-all-LUNs-in-one-line.patch
|
||||||
Patch5: 0005-rescan-scsi-bus.sh-apply-fix-for-r-from-https-github.patch
|
Patch5: 0005-rescan-scsi-bus.sh-apply-fix-for-r-from-https-github.patch
|
||||||
|
Patch6: 0006-rescan-scsi-bus-sgdevice26-do-not-traverse-sg-class-.patch
|
||||||
|
Patch7: 0007-rescan-scsi-bus.sh-add-option-no-lip-scan.patch
|
||||||
|
|
||||||
Provides: %{name}-libs
|
Provides: %{name}-libs
|
||||||
Obsoletes: %{name}-libs
|
Obsoletes: %{name}-libs
|
||||||
@ -75,6 +77,9 @@ rm -rf $RPM_BUILD_ROOT/%{_libdir}/*.la
|
|||||||
%{_mandir}/man8/*
|
%{_mandir}/man8/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri Sep 2 2022 Wenchao Hao <haowenchao@huawei.com> - 1.47-2
|
||||||
|
- backport rescan-scsi-bus patches from mainline
|
||||||
|
|
||||||
* Sat Aug 13 2022 volcanodragon <linfeilong@huawei.com> - 1.47-1
|
* Sat Aug 13 2022 volcanodragon <linfeilong@huawei.com> - 1.47-1
|
||||||
- update version to 1.47
|
- update version to 1.47
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user