Bug 1380346 - `rescan-scsi-bus.sh --luns` scans all luns.
Summary: `rescan-scsi-bus.sh --luns` scans all luns.
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: sg3_utils
Version: 6.9
Hardware: Unspecified
OS: Linux
high
high
Target Milestone: rc
: 6.10
Assignee: Gris Ge
QA Contact: guazhang@redhat.com
URL:
Whiteboard:
Depends On:
Blocks: 1380744 1507140
TreeView+ depends on / blocked
 
Reported: 2016-09-29 11:27 UTC by Wu Siu Wa
Modified: 2021-12-10 14:45 UTC (History)
5 users (show)

Fixed In Version: sg3_utils-1.28-13.el6
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1380744 (view as bug list)
Environment:
Last Closed: 2018-06-19 05:11:46 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2018:1872 0 None None None 2018-06-19 05:11:55 UTC

Description Wu Siu Wa 2016-09-29 11:27:30 UTC
Description of problem:


Version-Release number of selected component (if applicable):

From sg3_utils-1.28-6.el6

In sg3_utils-1.28-5, `rescan-scsi-bus.sh --luns=1` will only rescan luns numbered 1, which is expected.

Starting from sg3_utils-1.28-6, `rescan-scsi-bus.sh --luns=1` will scan all luns, which we don't like.


How reproducible:


Steps to Reproduce:
1. Attach multiple SCSI disk to a RHEL6 VM.
2. Run `rescan-scsi-bus.sh --luns=1`


Actual results:

It scan all luns.

 ~]# ./rescan-scsi-bus-test2.sh --luns=1
which: no multipath in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)
Scanning SCSI subsystem for new devices
Scanning host 0 for  SCSI target IDs  0 1 2 3 4 5 6 7, LUNs  1
 Scanning for device 0 0 0 0 ...          
OLD: Host: scsi0 Channel: 00 Id: 00 Lun: 00
      Vendor: QEMU     Model: QEMU DVD-ROM     Rev: 1.5.
      Type:   CD-ROM                           ANSI SCSI revision: 05
Scanning host 1 for  SCSI target IDs  0 1 2 3 4 5 6 7, LUNs  1
Scanning host 2 for  SCSI target IDs  0 1 2 3 4 5 6 7, LUNs  1
 Scanning for device 2 0 0 0 ...
OLD: Host: scsi2 Channel: 00 Id: 00 Lun: 00
      Vendor: QEMU     Model: QEMU HARDDISK    Rev: 1.5.
      Type:   Direct-Access                    ANSI SCSI revision: 05
 Scanning for device 2 0 0 1 ...
OLD: Host: scsi2 Channel: 00 Id: 00 Lun: 01
      Vendor: QEMU     Model: QEMU HARDDISK    Rev: 1.5.
      Type:   Direct-Access                    ANSI SCSI revision: 05
0 new or changed device(s) found.          
0 remapped or resized device(s) found.         
0 device(s) removed.



Expected results:

Should only scan lun 1.

 ~]# ./rescan-scsi-bus-test1.sh --luns=1
Host adapter 0 (ata_piix) found.
Host adapter 1 (ata_piix) found.
Host adapter 2 (virtio_scsi) found.
Scanning SCSI subsystem for new devices
Scanning host 0 for  SCSI target IDs  0 1 2 3 4 5 6 7, LUNs  1
Scanning host 1 channels  0 for  SCSI target IDs  0 1 2 3 4 5 6 7, LUNs  1
Scanning host 2 channels  0 for  SCSI target IDs  0 1 2 3 4 5 6 7, LUNs  1
Scanning for device 2 0 0 1 ...
OLD: Host: scsi2 Channel: 00 Id: 00 Lun: 01
      Vendor: QEMU     Model: QEMU HARDDISK    Rev: 1.5.
      Type:   Direct-Access                    ANSI SCSI revision: 05
0 new device(s) found.              
0 device(s) removed.


Additional info:

This unexpected behavior was introduced by:

* Tue Jun 24 2014 Dan Horák <dhorak> - 1.28-6
- update rescan-scsi-bus.sh to 1.57 (#857200)
- Resolves: #857200

Comment 2 Ondrej Vasik 2016-09-30 10:45:31 UTC
Thanks for report, I believe this was reported and fixed upstream as well - https://github.com/hreinecke/sg3_utils/issues/3 ... 

https://github.com/hreinecke/sg3_utils/pull/4/commits/66af0c64749682e5d5dfcb372e2e521b5a583794 patch is supposed to correct this wrong behaviour. Can you please check this and confirm the fix if possible?

Comment 8 Gris Ge 2017-11-17 08:25:51 UTC
The patch would be:

diff --git a/scripts/rescan-scsi-bus.sh b/scripts/rescan-scsi-bus.sh
index fad4868..bbe2228 100755
--- a/scripts/rescan-scsi-bus.sh
+++ b/scripts/rescan-scsi-bus.sh
@@ -715,7 +715,16 @@ searchexisting()
     else
       match=1
     fi
-    test $match -eq 1 && doreportlun
+
+    test $match -eq 0 && continue
+
+    if [ -z "$lunsearch" ] ; then
+      doreportlun
+    else
+      for lun in $lunsearch ; do
+        dolunscan
+      done
+    fi
   done
 }

Comment 12 guazhang@redhat.com 2017-12-15 06:22:29 UTC
Hello

I have tested  sg3_utils-1.28-13.el6 and passed, move to verified

Comment 15 errata-xmlrpc 2018-06-19 05:11:46 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:1872


Note You need to log in before you can comment on or make changes to this bug.