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 1846566 - lsscsi --scsi_id outputs inconsistent choices across devices
Summary: lsscsi --scsi_id outputs inconsistent choices across devices
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: lsscsi
Version: 8.3
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: rc
: 8.0
Assignee: Tomáš Bžatek
QA Contact: zguo
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-06-11 23:10 UTC by Dwight (Bud) Brown
Modified: 2021-09-06 15:27 UTC (History)
3 users (show)

Fixed In Version: lsscsi-0.32-1.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-05-18 14:56:54 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2021:1634 0 None None None 2021-05-18 14:57:11 UTC

Description Dwight (Bud) Brown 2020-06-11 23:10:30 UTC
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.

Comment 7 pratapsingh 2021-03-24 01:44:22 UTC
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

Comment 12 errata-xmlrpc 2021-05-18 14:56:54 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 (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


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