Description of problem: When there are multiple scsi_id entries to choose from, and there often are, lsscsi stops scanning at the first one that matches the device, unfortunately the order of scsi id entries in /dev/disk/by-id directory are not guaranteed to be consistently ordered by prefix type so, in one case scsi-3<wwid> is output and for another scsi-0<id> is output although in the 2nd case a scsi-3<wwid> is present. Order is unsorted directory order based (see ls -lUo output) Output should be consistent and choose best identifier option available. Version-Release number of selected component (if applicable): 0.31 latest upstream and shipped How reproducible: 100% Steps to Reproduce: 1. lsscsi --scsi_id 2. 3. Actual results: # lsscsi --scsi_id [0:0:0:0] storage HP P410i 6.60 - - [0:1:0:0] disk HP LOGICAL VOLUME 6.60 /dev/sda SHP_LOGICAL_VOLUME_50014380145A2900 [0:1:0:1] disk HP LOGICAL VOLUME 6.60 /dev/sdb 0HP_LOGICAL_VOLUME_01000000 [1:0:0:0] cd/dvd hp DVD A DS8A8SH KHE4 /dev/sr0 - so first device has a 'S' prefix and 2nd '0' type id (using vendor binary id in page 83), but both devices have '3' NAA wwid, 'S' and '0' scsi identifiers available to choose from Expected results: # ./lsscsi.dbg --scsi_id [0:0:0:0] storage HP P410i 6.60 - - [0:1:0:0] disk HP LOGICAL VOLUME 6.60 /dev/sda 3600508b1001cf6d83cad2f9741e23e51 [0:1:0:1] disk HP LOGICAL VOLUME 6.60 /dev/sdb 3600508b1001c033030ea6dada3776da9 [1:0:0:0] cd/dvd hp DVD A DS8A8SH KHE4 /dev/sr0 - Additional info: # ls -lUo /dev/disk/by-id | egrep "sda|sdb" | egrep -v "sda[1-9]|sdb[1-9]" lrwxrwxrwx. 1 root 9 May 18 18:07 scsi-SHP_LOGICAL_VOLUME_50014380145A2900 -> ../../sda << first for sda lrwxrwxrwx. 1 root 9 May 18 18:07 scsi-0HP_LOGICAL_VOLUME_00000000 -> ../../sda lrwxrwxrwx. 1 root 9 May 18 18:07 scsi-0HP_LOGICAL_VOLUME_01000000 -> ../../sdb << first for sdb lrwxrwxrwx. 1 root 9 May 18 18:07 wwn-0x600508b1001c033030ea6dada3776da9 -> ../../sdb lrwxrwxrwx. 1 root 9 May 18 18:07 scsi-3600508b1001c033030ea6dada3776da9 -> ../../sdb << "best" sdb choice lrwxrwxrwx. 1 root 9 May 18 18:07 wwn-0x600508b1001cf6d83cad2f9741e23e51 -> ../../sda lrwxrwxrwx. 1 root 9 May 18 18:07 scsi-3600508b1001cf6d83cad2f9741e23e51 -> ../../sda << "best" sda choice Instead of stopping at first match, process the directory for "best" match. For example, an 'S' identifier is less likely to be world wide unique than a '3' (prefix) wwid. One order, might be (with '3' being 'best' or most desirable to '0' being least desirable. '3' for NAA based (identification record within scsi INQUIRY page 0x83) '2' for EUI-64 based (identification record within scsi INQUIRY page 0x83) '8' for SCSI name string from scsi INQUIRY page 0x83 'S' for string based (serial number from scsi INQUIRY page 0x80) '1' for T10 Vendor id based (identification record within scsi INQUIRY page 0x83) '0' for Vendor specific (identification record within scsi INQUIRY page 0x83) From pg83: Table 466 - Designator Type field Code Description Reference 0h Vendor Specific 7.7.3.3 1h T10 Vendor ID based 7.7.3.4 2h EUI-64 based 7.7.3.5 3h NAA 7.7.3.6 4h Relative target port identifier 7.7.3.7 5h Target port group 7.7.3.8 6h Logical unit group 7.7.3.9 7h MD5 logical unit identifier 7.7.3.10 8h SCSI name string 7.7.3.11 9h-Fh <Reserved> The "expected" output is from code that added an order to lookup_dev(): scsi_id = lookup_dev(dev_disk_byid_dir, "scsi-", "328S10", dev_node); Then code captures first of the best prefix type it can find within the by-id directory by scanning all entries. This then generates consistent output regardless of order within the directory.
Hello, I have a similar issue with the other case. Environment: Red Hat Enterprise Linux release 8.3 4.18.0-240.15.1.el8_3.x86_64 lsscsi-0.30-1.el8.x86_64 Issue: I can see the difference in the behaviour of $lsscsi RHEL 8.1 [root@~]# ls -l /dev/disk/by-id/scsi-* lrwxrwxrwx 1 root root 9 Mar 22 16:17 /dev/disk/by-id/scsi-36000c2925341bf94b5bd0493157xxxxx -> ../../sdc ^^^^---it should be like this. RHEl 8.3 --> same device with the S* lrwxrwxrwx 1 root root 9 Mar 22 16:17 /dev/disk/by-id/scsi-SVMware_Virtual_disk_6000c2925341bf94b5bd049315xxxxx -> ../../sdc ^^^^^^^^^^^^^^^^^^^^ The customer is looking for a patch release. Regards, Pratapsingh
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 (lsscsi bug fix and enhancement update), 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-2021:1634