Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1380346

Summary: `rescan-scsi-bus.sh --luns` scans all luns.
Product: Red Hat Enterprise Linux 6 Reporter: Wu Siu Wa <siwu>
Component: sg3_utilsAssignee: Gris Ge <fge>
Status: CLOSED ERRATA QA Contact: guazhang <guazhang>
Severity: high Docs Contact:
Priority: high    
Version: 6.9CC: cww, djez, jkurik, knoha, rhandlin
Target Milestone: rcKeywords: Patch, Regression, Reopened
Target Release: 6.10   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: sg3_utils-1.28-13.el6 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1380744 (view as bug list) Environment:
Last Closed: 2018-06-19 05:11:46 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1380744, 1507140    

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