diff --git a/0008-rescan-scsi-bus.sh-speed-testonline.patch b/0008-rescan-scsi-bus.sh-speed-testonline.patch new file mode 100644 index 0000000000000000000000000000000000000000..535bd1a8b54e0008782109b74f2495f730c6c502 --- /dev/null +++ b/0008-rescan-scsi-bus.sh-speed-testonline.patch @@ -0,0 +1,33 @@ +From e680e840140d19cb3419ff92595bc2c91de3368a Mon Sep 17 00:00:00 2001 +From: Douglas Gilbert +Date: Mon, 26 Sep 2022 21:41:45 +0000 +Subject: [PATCH 1/2] rescan-scsi-bus.sh speed testonline() + +speed testonline() function when +peripheral_qualifier != 0 in the standard INQUIRY +response. See: +https://github.com/doug-gilbert/sg3_utils/issues/24 + +git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@972 6180dd3e-e324-4e3e-922d-17de1ae2f315 + +Conflict: Reserve changes about rescan-scsi-bus only +--- + scripts/rescan-scsi-bus.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/scripts/rescan-scsi-bus.sh b/scripts/rescan-scsi-bus.sh +index 67dccf3..0e7697b 100755 +--- a/scripts/rescan-scsi-bus.sh ++++ b/scripts/rescan-scsi-bus.sh +@@ -276,7 +276,7 @@ testonline () + + # Handle in progress of becoming ready and unit attention + while [ $RC = 2 -o $RC = 6 ] && [ $ctr -le 30 ] ; do +- if [ $RC = 2 ] && [ "$RMB" != "1" ] ; then ++ if [ $RC = 2 ] && [ "$RMB" != "1" ] && [ sg_inq /dev/$SGDEV | grep -q -i "PQual=0" ] ; then + echo -n "." + let LN+=1 + sleep 1 +-- +2.35.3 + diff --git a/0009-rescan-scsi-bus-speed-large-multipath-scans.patch b/0009-rescan-scsi-bus-speed-large-multipath-scans.patch new file mode 100644 index 0000000000000000000000000000000000000000..513b8ce6b0349f39c055eb0df6349d60a711512b --- /dev/null +++ b/0009-rescan-scsi-bus-speed-large-multipath-scans.patch @@ -0,0 +1,130 @@ +From fe62f3e9ce96927bf9bcfb19b33447b54aafdc1f Mon Sep 17 00:00:00 2001 +From: Douglas Gilbert +Date: Fri, 30 Sep 2022 08:58:39 +0000 +Subject: [PATCH 2/2] rescan-scsi-bus: speed large multipath scans + +Speed multipath scans with many LUNs by caching multipath +LUN info in temporary file, see: + https://github.com/doug-gilbert/sg3_utils/issues/22 +Fix small bug in last commit, see: + https://github.com/doug-gilbert/sg3_utils/issues/24 + +git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@973 6180dd3e-e324-4e3e-922d-17de1ae2f315 + +Conflict: reserve changes about rescan-scsi-bus only +--- + scripts/rescan-scsi-bus.sh | 57 ++++++++++++++++++++++++++------------ + 1 file changed, 40 insertions(+), 17 deletions(-) + +diff --git a/scripts/rescan-scsi-bus.sh b/scripts/rescan-scsi-bus.sh +index 0e7697b..7508dba 100755 +--- a/scripts/rescan-scsi-bus.sh ++++ b/scripts/rescan-scsi-bus.sh +@@ -6,6 +6,7 @@ + + VERSION="20180615" + SCAN_WILD_CARD=4294967295 ++TMPLUNINFOFILE="/tmp/rescan-scsi-mpath-info.txt" + + setcolor () + { +@@ -276,7 +277,7 @@ testonline () + + # Handle in progress of becoming ready and unit attention + while [ $RC = 2 -o $RC = 6 ] && [ $ctr -le 30 ] ; do +- if [ $RC = 2 ] && [ "$RMB" != "1" ] && [ sg_inq /dev/$SGDEV | grep -q -i "PQual=0" ] ; then ++ if [ $RC = 2 ] && [ "$RMB" != "1" ] && sg_inq /dev/$SGDEV | grep -q -i "PQual=0" ; then + echo -n "." + let LN+=1 + sleep 1 +@@ -777,6 +778,33 @@ searchexisting() + done + } + ++getallmultipathinfo() ++{ ++ local mp= ++ local uuid= ++ local dmtmp= ++ local maj_min= ++ local tmpfile= ++ ++ truncate -s 0 $TMPLUNINFOFILE ++ for mp in $($DMSETUP ls --target=multipath | cut -f 1) ; do ++ [ "$mp" = "No" ] && break; ++ maj_min=$($DMSETUP status "$mp" | cut -d " " -f14) ++ if [ ! -L /dev/mapper/${mp} ]; then ++ echo "softlink /dev/mapper/${mp} not available." ++ continue ++ fi ++ local ret=$(readlink /dev/mapper/$mp 2>/dev/null) ++ if [[ $? -ne 0 || -z "$ret" ]]; then ++ echo "readlink /dev/mapper/$mp failed. check multipath status." ++ continue ++ fi ++ dmtmp=$(basename $ret) ++ uuid=$(cut -f2 -d- "/sys/block/$dmtmp/dm/uuid") ++ echo "$mp $maj_min $dmtmp $uuid" >> $TMPLUNINFOFILE ++ done ++} ++ + # Go through all of the existing devices and figure out any that have been remapped + findremapped() + { +@@ -815,6 +843,8 @@ findremapped() + udevadm_settle 2>&1 /dev/null + echo "Done" + ++ getallmultipathinfo ++ + # See what changed and reload the respective multipath device if applicable + while read -r hctl sddev id_serial_old ; do + remapped=0 +@@ -945,7 +975,6 @@ findmultipath() + local dev="$1" + local find_mismatch="$2" + local mp= +- local mp2= + local found_dup=0 + local maj_min= + +@@ -955,27 +984,21 @@ findmultipath() + fi + + maj_min=$(cat "/sys/block/$dev/dev") +- for mp in $($DMSETUP ls --target=multipath | cut -f 1) ; do +- [ "$mp" = "No" ] && break; +- if "$DMSETUP" status "$mp" | grep -q " $maj_min "; then +- # With two arguments, look up current uuid from sysfs +- # if it doesn't match what was passed, this multipath +- # device is not updated, so this is a remapped LUN +- if [ -n "$find_mismatch" ] ; then +- mp2=$($MULTIPATH -l "$mp" | egrep -o "dm-[0-9]+") +- mp2=$(cut -f2 -d- "/sys/block/$mp2/dm/uuid") +- if [ "$find_mismatch" != "$mp2" ] ; then +- addmpathtolist "$mp" +- found_dup=1 +- fi +- continue ++ mp=$(cat $TMPLUNINFOFILE | grep -w "$maj_min" | cut -d " " -f1) ++ if [ -n "$mp" ]; then ++ if [ -n "$find_mismatch" ] ; then ++ uuid=$(cat $TMPLUNINFOFILE | grep -w "$maj_min" | cut -d " " -f4) ++ if [ "$find_mismatch" != "$uuid" ] ; then ++ addmpathtolist "$mp" ++ found_dup=1 + fi ++ else + # Normal mode: Find the first multipath with the sdev + # and add it to the list + addmpathtolist "$mp" + return + fi +- done ++ fi + + # Return 1 to signal that a duplicate was found to the calling function + if [ $found_dup -eq 1 ] ; then +-- +2.35.3 + diff --git a/sg3_utils.spec b/sg3_utils.spec index 577989f6901f06c616eaa619ff3092a09f2e356d..0c6a1614d9c2c4dcde01e4b12336c2e051c529b2 100644 --- a/sg3_utils.spec +++ b/sg3_utils.spec @@ -1,6 +1,6 @@ Name: sg3_utils Version: 1.45 -Release: 9 +Release: 10 Summary: Utilities that send SCSI commands to devices. License: GPL-2.0-or-later AND BSD URL: http://sg.danny.cz/sg/sg3_utils.html @@ -14,6 +14,8 @@ Patch4: 0004-sg_ses-fix-crash-when-m-LEN-252.patch Patch5: 0005-sg3_utils-rescan-scsi-bus-list-all-LUNs-in-one-line.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 +Patch8: 0008-rescan-scsi-bus.sh-speed-testonline.patch +Patch9: 0009-rescan-scsi-bus-speed-large-multipath-scans.patch Provides: %{name}-libs Obsoletes: %{name}-libs @@ -77,6 +79,9 @@ rm -rf $RPM_BUILD_ROOT/%{_libdir}/*.la %{_mandir}/man8/* %changelog +* Fri Nov 4 2022 Zhiqiang Liu - 1.45-10 +- backport speed multipath scan patches from mainline + * Fri Sep 2 2022 Wenchao Hao - 1.45-9 - backport rescan-scsi-bus patches from mainline