Bugzilla – Bug 909111
sg3_utils: rescan-scsi-bus.sh is broken since SuSE-13.1
Last modified: 2021-08-26 13:51:33 UTC
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:33.0) Gecko/20100101 Firefox/33.0 Build Identifier: This script no longer "finds new" or "removes no longer attached" scsi devices. As shown below, I have a scsi disk at scsi ID-0 at /dev/sg5. # lsscsi -g [0:0:0:0] disk ATA ST3320620AS K /dev/sda /dev/sg0 [13:0:0:0] process Marvell 91xx Config 1.01 - /dev/sg1 [16:0:0:0] disk IMPRIMIS 94601-15 4614 /dev/sdd /dev/sg5 [17:0:0:0] cd/dvd LITE-ON DVDRW LH-20A1P KL0G /dev/sr0 /dev/sg2 [18:0:0:0] disk ATA ST3160811AS E /dev/sdb /dev/sg3 [18:0:1:0] disk ATA ST3160815AS B /dev/sdc /dev/sg4 I remove the drive at scsi ID-0 drive and install an additional drive at scsi ID-1 then run the script. # rescan-scsi-bus.sh Scanning SCSI subsystem for new devices Scanning host 0 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning for device 0 0 0 0 ... OLD: Host: scsi0 Channel: 00 Id: 00 Lun: 00 Vendor: ATA Model: ST3320620AS Rev: K Type: Direct-Access ANSI SCSI revision: 05 Scanning host 1 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 2 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 3 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 4 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 5 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 6 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 7 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 8 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 9 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 10 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 11 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 12 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 13 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning for device 13 0 0 0 ... OLD: Host: scsi13 Channel: 00 Id: 00 Lun: 00 Vendor: Marvell Model: 91xx Config Rev: 1.01 Type: Processor ANSI SCSI revision: 05 Scanning host 14 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 15 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 16 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning for device 16 0 0 0 ... OLD: Host: scsi16 Channel: 00 Id: 00 Lun: 00 Vendor: IMPRIMIS Model: 94601-15 Rev: 4614 Type: Direct-Access ANSI SCSI revision: 01 Scanning host 17 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning for device 17 0 0 0 ... OLD: Host: scsi17 Channel: 00 Id: 00 Lun: 00 Vendor: LITE-ON Model: DVDRW LH-20A1P Rev: KL0G Type: CD-ROM ANSI SCSI revision: 05 Scanning host 18 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning for device 18 0 0 0 ... OLD: Host: scsi18 Channel: 00 Id: 00 Lun: 00 Vendor: ATA Model: ST3160811AS Rev: E Type: Direct-Access ANSI SCSI revision: 05 Scanning for device 18 0 1 0 ... OLD: Host: scsi18 Channel: 00 Id: 01 Lun: 00 Vendor: ATA Model: ST3160815AS Rev: B 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. # lsscsi -g [0:0:0:0] disk ATA ST3320620AS K /dev/sda /dev/sg0 [13:0:0:0] process Marvell 91xx Config 1.01 - /dev/sg1 [16:0:0:0] disk IMPRIMIS 94601-15 4614 /dev/sdd /dev/sg5 [17:0:0:0] cd/dvd LITE-ON DVDRW LH-20A1P KL0G /dev/sr0 /dev/sg2 [18:0:0:0] disk ATA ST3160811AS E /dev/sdb /dev/sg3 [18:0:1:0] disk ATA ST3160815AS B /dev/sdc /dev/sg4 It not only did not remove the one at ID-0 that was removed, but did not find the new one attached. Below is an "lsscsi -g" after a reboot with BOTH drives attached. #lsscsi -g [0:0:0:0] disk ATA ST3320620AS K /dev/sda /dev/sg0 [13:0:0:0] process Marvell 91xx Config 1.01 - /dev/sg1 [16:0:0:0] disk IMPRIMIS 94601-15 4614 /dev/sdd /dev/sg5 [16:0:1:0] disk IMPRIMIS 94601-15 4614 /dev/sde /dev/sg6 [17:0:0:0] cd/dvd LITE-ON DVDRW LH-20A1P KL0G /dev/sr0 /dev/sg2 [18:0:0:0] disk ATA ST3160811AS E /dev/sdb /dev/sg3 [18:0:1:0] disk ATA ST3160815AS B /dev/sdc /dev/sg4 Reproducible: Always Steps to Reproduce: 1. See details 2. 3. Actual Results: This script, before SuSE-13.1 would remove any disks physically removed and add any physically added since boot. It is broken This is NOT kernel related as the same thing happens with a vanilla 3.16.7 kernel. I'm fairly certain this is a systemd issue.
This bug is still valid in opensuse-13.2
Created attachment 633844 [details] Updated rescan-scsi-bus.sh Please re-test using the attached rescan-scsi-bus.sh version
OK i tried the new script but nothing changed. My SCSI devices before: # lsscsi -g [0:0:0:0] disk ATA ST3160815AS B /dev/sda /dev/sg0 [1:0:0:0] disk ATA ST3160815AS D /dev/sdb /dev/sg1 [2:0:0:0] disk ATA ST3160811AS E /dev/sdc /dev/sg2 [3:0:0:0] disk ATA ST3160815AS D /dev/sdd /dev/sg3 [6:0:0:0] disk ATA ST3500320NS SN06 /dev/sde /dev/sg4 [7:0:0:0] disk ATA ST3500320NS SN04 /dev/sdf /dev/sg5 [8:0:0:0] cd/dvd SONY DVD RW AD-7260S 1.61 /dev/sr0 /dev/sg6 [8:0:1:0] disk ATA ST3500418AS CC38 /dev/sdg /dev/sg7 [10:0:2:0] tape HP 88780 A674 /dev/st1 /dev/sg10 [10:0:6:0] tape EXABYTE EXB-8500-85Qanx0 0446 /dev/st2 /dev/sg11 [11:0:0:0] disk SEAGATE ST15150N 5055 /dev/sdh /dev/sg8 [11:0:3:0] tape SONY SDT-10000 0110 /dev/st0 /dev/sg9 I removed the SONY tape drive on bus 11 at /dev/st0 , /dev/sg9 and added another SEAGATE SCSI disk at SCSI ID 1 on bus 11. #./rescan-scsi-bus.sh Scanning SCSI subsystem for new devices Scanning host 0 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs sg0 changed: device 0 0 0 0 ... from:Direct-Access : 00 to: Direct-Access Model: ST3160815AS Rev: B Type: Direct-Access ANSI SCSI revision: 05 Scanning host 1 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs sg1 changed: device 1 0 0 0 ... from:Direct-Access : 00 to: Direct-Access Model: ST3160815AS Rev: D Type: Direct-Access ANSI SCSI revision: 05 Scanning host 2 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs sg2 changed: device 2 0 0 0 ... from:Direct-Access : 00 to: Direct-Access Model: ST3160811AS Rev: E Type: Direct-Access ANSI SCSI revision: 05 Scanning host 3 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs sg3 changed: device 3 0 0 0 ... from:Direct-Access : 00 to: Direct-Access Model: ST3160815AS Rev: D Type: Direct-Access ANSI SCSI revision: 05 Scanning host 4 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 5 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 6 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs sg4 changed: device 6 0 0 0 ... from:Direct-Access : 00 to: Direct-Access Model: ST3500320NS Rev: SN06 Type: Direct-Access ANSI SCSI revision: 05 Scanning host 7 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs sg5 changed: device 7 0 0 0 ... from:Direct-Access : 00 to: Direct-Access Model: ST3500320NS Rev: SN04 Type: Direct-Access ANSI SCSI revision: 05 Scanning host 8 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs sg6 changed: device 8 0 0 0 ... from:CD-ROM : 00 to: CD-ROM : SONY Model: DVD RW AD-7260S Rev: 1.61 Type: CD-ROM ANSI SCSI revision: 05 sg7 changed: device 8 0 1 0 ... from:Direct-Access : 00 to: Direct-Access Model: ST3500418AS Rev: CC38 Type: Direct-Access ANSI SCSI revision: 05 Scanning host 9 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs Scanning host 10 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs sg10 changed: device 10 0 2 0 ... from:Sequential-Access n: 00 to: Sequential-Access Model: 88780 Rev: A674 Type: Sequential-Access ANSI SCSI revision: 01 sg11 changed: device 10 0 6 0 ... from:Sequential-Access n: 00 to: Sequential-Access Model: EXB-8500-85Qanx0 Rev: 0446 Type: Sequential-Access ANSI SCSI revision: 02 Scanning host 11 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs sg8 changed: device 11 0 0 0 ... from:Direct-Access n: 00 to: Direct-Access TE Model: ST15150N Rev: 5055 Type: Direct-Access ANSI SCSI revision: 02 sg9 changed: INQUIRY failed .. OLD: Host: scsi11 Channel: 00 Id: 03 Lun: 00 Vendor: SONY Model: SDT-10000 Rev: 0110 Type: Sequential-Access ANSI SCSI revision: 02 0 new or changed device(s) found. 0 remapped or resized device(s) found. 0 device(s) removed. harley:/home/markh # lsscsi -g [0:0:0:0] disk ATA ST3160815AS B /dev/sda /dev/sg0 [1:0:0:0] disk ATA ST3160815AS D /dev/sdb /dev/sg1 [2:0:0:0] disk ATA ST3160811AS E /dev/sdc /dev/sg2 [3:0:0:0] disk ATA ST3160815AS D /dev/sdd /dev/sg3 [6:0:0:0] disk ATA ST3500320NS SN06 /dev/sde /dev/sg4 [7:0:0:0] disk ATA ST3500320NS SN04 /dev/sdf /dev/sg5 [8:0:0:0] cd/dvd SONY DVD RW AD-7260S 1.61 /dev/sr0 /dev/sg6 [8:0:1:0] disk ATA ST3500418AS CC38 /dev/sdg /dev/sg7 [10:0:2:0] tape HP 88780 A674 /dev/st1 /dev/sg10 [10:0:6:0] tape EXABYTE EXB-8500-85Qanx0 0446 /dev/st2 /dev/sg11 [11:0:0:0] disk SEAGATE ST15150N 5055 /dev/sdh /dev/sg8 [11:0:3:0] tape SONY SDT-10000 0110 /dev/st0 /dev/sg9
Could you please run the script with sh -x and attach the logs here, so I can have a look what's actually going wrong. Thanks
Created attachment 634136 [details] Output from "sh -x rescan-scsi-bus.sh" Had to xz the text attachment because it exceeded the 10240kb attachment file limit
Seems like my error, I've only attached a patched version of the rescan-scsi-bus.sh script, but forgot to update sg_turs as well. I'll build an updated rpm shortly and notice you once it is done. Sorry for the inconvenience.
Can you please try the sg_turs from https://build.opensuse.org/package/show/home:morbidrsa:branches:Base:System/sg3_utils Maybe you'll need to use the rescan-scsi-bus.sh from this ticket. Thanks
I can't seem to find an rpm to try??
Sorry, somehow the publish flag was cleared... Should be accessible now
OK, I got and installed them. No change though?? Mark
The problem (with the old sg_turs from sg3_utils) was that it had a return code of 99, which isn't known by the script. This should be fixed with the preliminary sg3_utils package I gave you. Can you verify it? What's the output of sg_turs /dev/sg9; echo $? assuming sg9 still is the SONY tape drive in question. Have you tried with the rescan-scsi-bus.sh from the rpm or with the one attached to this bug?
With the tape installed 0 is returned. With it powered off, the following is returned. #sg_turs /dev/sg11; echo $? test unit ready: transport: Host_status=0x01 [DID_NO_CONNECT] Driver_status=0x00 [DRIVER_OK, SUGGEST_OK] Sense category: -1 99 This is using the 2 rpms. Note that devices removed were never actually removed from the output of the "lsscsi -g" command even though the script would report it was removed and when reinstalled and the script re-ran it would still show it's original designation via "lsscsi -g". But new devices were reported and always added and would be available for use after running the script. Devices added are my biggest concern.
FYI, the rescan-scsi-bus.sh script from the 12.3 distribution works when run on my 13.2 system. It correctly finds new devices and they are available for use after running that script. Removed devices are still not shown as removed but that is not really important. New devices found are what is critical and that works using the rescan-scsi-bus.sh from the 12.3 dist on my 13.2 system.
Hi, We've updated sg3_utils to the newest version in Factory [1], can you have a look at it? I'm sorry that this is more try and error than anything else but I don't know how to solve this issue. Thanks [1] https://build.opensuse.org/package/show?project=Base%3ASystem&package=sg3_utils
That does not fix it. As I said: "FYI, the rescan-scsi-bus.sh script from the 12.3 distribution works when run on my 13.2 system. It correctly finds new devices and they are available for use after running that script. Removed devices are still not shown as removed but that is not really important. New devices found are what is critical and that works using the rescan-scsi-bus.sh from the 12.3 dist on my 13.2 system." ????
Who is the official maintainer of this package and script. I can't find anything on the web as to who to report bugs to. The script from the SuSE-12.3 package works just fine. Someone either just needs to swap it out or ask the "real" owner of this package to fix it.
(In reply to Mark Hounschell from comment #15) > That does not fix it. As I said: > > "FYI, the rescan-scsi-bus.sh script from the 12.3 distribution works when > run on my 13.2 system. It correctly finds new devices and they are available > for use after running that script. Removed devices are still not shown as > removed but that is not really important. New devices found are what is > critical and that works using the rescan-scsi-bus.sh from the 12.3 dist on > my 13.2 system." > > ???? Can you please check if it work with the new script if you call it with rescan-scsi-bus.sh -r ? If not, can you please provide the output of 'bash -x rescan-scsi-bus.sh -r' from both, the old, working one and the new one? Thanks.
Created attachment 651181 [details] Output of 'sh -x /usr/bin/rescan-scsi-bus-12.3.sh -r'
Created attachment 651182 [details] Output of 'sh -x /usr/bin/rescan-scsi-bus.sh -r'
Using the libsgutils2-1_41-2-1.41-64.1.x86_64.rpm and sg3_utils-1.41-64.1.x86_64.rpm packages from factory, the 'rescan-scsi-bus.sh -r' command did not find a new device. I've attached the output of the rescan scripts from the above and the 12.3 script
Have just tried this on Tumbleweed with sg3_utils 1.43 - added a drive, rescan-scsi-bus.sh did not find it.
I'd rather lay this bug to rest; please open another bug if it's still an issue.
This bug is still as valid today as it was when it was filed. Why should I refile it when you all will just let it rot again. Shameful...
Because it has been filed against a (now unsupported) version. Can you please re-file it against the most recent version? Thanks.
It is still broken in Leap 42.3. I see no valid reason to refile this bug.
So change the Version: tags of the bug?
This bu has not been FIXED
I have verified that this bug is still a bug on leap 42.3 and also on leap-15 beta-197.1. I can also that the rescan-scsi-bus script from the SuSE-12.3 sg_utils package does in fact work properly on leap-42.3 and leap-15 beta-197.1 I have also changed the VERSION ID from 42.3 to 15. Lets see this bug is now over 4 years old.
This bug still exists even though the original BUG report was back in 2015. The last rescan-scsi-bus.sh that actually worked was from the 12.3 dist. I have had to keep the version for 12.3 on my system every since because I use it constantly. Please fix this BUG. I would be happy to attach the 12.3 version of this script but find no way to do it but inline here.
Created attachment 852026 [details] diff between 12.3 and 13.1 versions obtained with unrpm on /mounts/schnell/CD-ARCHIVE/openSUSE/12.3/POOL/suse/x86_64/sg3_utils-1.33-5.1.1.x86_64.rpm /mounts/schnell/CD-ARCHIVE/openSUSE/13.1/POOL/suse/x86_64/sg3_utils-1.36-3.1.2.x86_64.rpm
The only change from comment 31 that could have caused the change in behavior is this, afaics: - # We used to always trigger a rescan for FC to update channels and targets - # Commented out -- as discussed with Hannes we should rely - # on the main loop doing the scan, no need to do it here. - #echo "- - -" > /sys/class/scsi_host/host$host/scan 2> /dev/null; - #udevadm_settle One thing that stands out is the removed "udevadm settle". Could you locate this code: > idlist () > { > local tmpid > local newid > local oldid > > oldlist=$(ls /sys/class/scsi_device/ | sed -n "s/${host}:${channel}:\([0-9]*:[0-9]*\)/\1/p" | uniq) > # Rescan LUN 0 to check if we found new targets > echo "${channel} - -" > /sys/class/scsi_host/host${host}/scan and put an "udevadm settle" below the last line ('echo "${channel} - -"...') and see if it helps?
correction: put "udevadm_settle" like in the original code (with underscore), not just "udevadm settle".
I've added it. # Returns the list of existing targets per host idlist () { local tmpid local newid local oldid oldlist=$(ls /sys/class/scsi_device/ | sed -n "s/${host}:${channel}:\([0-9]*:[0-9]*\)/\1/p" | uniq) # Rescan LUN 0 to check if we found new targets echo "${channel} - -" > /sys/class/scsi_host/host${host}/scan udevadm_settle newlist=$(ls /sys/class/scsi_device/ | sed -n "s/${host}:${channel}:\([0-9]*:[0-9]*\)/\1/p" | uniq) It did not help though.
Let me go back and verify which version actually broke it. I went from 12.3 to 13.2. I never used 13.1.
The rescan-scsi-bus.sh from the 13.1 dist also works. It breaks at 13.2. I just now verified this.
That would be good. I think there must be more differences than those in comment 31. 12.3 GA: 1.33 12.3 Update: 1.33 + some patches 13.1: 1.36 13.2: 1.39 However, rescan-scsi-bus.sh may have changed without being reflected in the version number, there's notes like this: > ------------------------------------------------------------------- > Mon Aug 4 18:13:25 UTC 2014 - spargaonkar@suse.com > > - Replaced rescan-scsi-bush.sh in sg3_utils-1.36.tar.xz ... good we aren't working like that any more ...
Just an FYI, I am running these scripts on 15.3. I have plenty of SCSI devices to play with so anything you want me to try, I can.
This coincides with the introduction of the exisiting_targets logic. Maybe it's as simple as running 'rescan-scsi-bus.sh -a --hosts=11' ?
Please run the current script with the "-a" flag, and (if it doesn't work) provide a sh -x log file like you did earlier.
Ah, the "-a" flag seems to do the trick. Do you still want the "sh -x" log file?
No. Please confirm that it works without the change from comment 34. It's true that the addition of "-a" was a change in the semantics of the script. This was before my time, I don't know why it has been done (I wasn't involved in sg3_utils at that time, 2013). The changelog doesn't say anything, either. If you're ok, I'm going to close this bug. Apologies that it took so long.
Yes, I have verified that the rescan script in 15.3 works with the "-a" flag as far as discovering newly added devices. This script originally discovered new and removed devices with no "-flags". It appears now that in order for it to work as it did originally you must pass not only the "-a" but the "-r" flag also. The "-r" flag removes removed devices from the list displayed by the "lsscsi -g" command. Yes, you can close this bug now. Thank you.
So "-r" worked for you? In some cases you may need `--forceremove` to actually delete the devices from the host. Thanks for your patience.