Understanding SCSI addressing on Red Hat Enterprise Linux

Updated

In common with the SCSI protocol definitions Linux represents scsi addresses as a sequence of 4 ID numbers that uniquely identify the location of a SCSI device within the system. These are referred to as Host, Bus, Target, Lun (HBTL) or Host, Channel, Id, Lun (HCIL ) SCSI addresses. HBTL is the most commonly used acronym in the SCSI literature however some commands and log files label this HCIL instead (the numeric address values are identical in either case). HBTL is also sometimes known as a SCSI address quad.

For example:

The format used is the following :

[Host:Bus:Target:Lun] or [H:B:T:L]

In the examples below, taken from the sg_map command (included in the sg3_utils package available from Red Hat Network), we can see that the SCSI Generic devices sg0 through sg3 are mapped in the system and using different modules of the upper SCSI layer. For instance, we can see:

# sg_map -x  
/dev/sg0  0 0 0 0  8  
/dev/sg1  0 0 1 0  1  /dev/nst0  
/dev/sg2  1 0 0 0  0  /dev/sda  
/dev/sg3  1 0 1 0  0  /dev/sdb
     sgN  H:B:T:L  ^       ^^^
                   |        +---- scsi upper layer device name
                   |
                   +------------- scsi device type number

The output of sg_map shows the SCSI generic device number (sgN device name), the SCSI H:B:T:L value, the SCSI device type value, and then if any, the device name for the device using the SCSI upper layer driver (ie, sda for sd_mod (scsi disk), sr0 for sr_mod (scsi cdrom/dvd) , st0 for st_mod (scsi tape), etc.) on the /dev filesystem. To find out the values and corresponding device types displayed on fifth numeric column of the sg_map command please refer to the file /usr/include/scsi/scsi.h and look for the DEVICE TYPES section. For example:

  • /dev/sg0 has H:B:T:L [0:0:0:0], device type 0x8 which is a TYPE_MEDIUM_CHANGER and no extra /dev entry because it is only accessed as a SCSI generic device.
  • /dev/sg1 has H:B:T:L [0:0:1:0], device type 0x1 which is a TYPE_TAPE and /dev/nst0 because it is accessed as a SCSI tape device via st_mod.ko linked in the kernel.
  • /dev/sg2 has H:B:T:L [1:0:0:0], device type 0x0 which is a TYPE_DISK and /dev/sda because it is accessed as a SCSI disk device via sd_mod.ko linked in the kernel.
  • /dev/sg3 has H:B:T:L [1:0:1:0], device type 0x0 which is a TYPE_DISK and /dev/sdb because it is accessed as a SCSI disk device via sd_mod.ko linked in the kernel.

where :

  • H: SCSI Host ID is the ID of the SCSI Host Bus Adapter (HBA) card, also referred to as the scsi controller. This identifier is assigned by the kernel in order of HBA card discovery order (1st scsi HBA assigned scsi host0, 2nd scsi host1, and so forth).
  • `B': Bus used within the HBA. It is also known as Channel. This identifier is assigned by the kernel and reflects part of the hardware/firmware architecture of the HBA design. Most scsi controllers with have only 1 bus/channel assigned index 0. Backplane raid controllers such as HP's Smart Array or LSI MegaRaid controllers are one example of an HBA that can have multiple channels.
  • T: Target is the destination device within this bus also known as Id of the device. This identifier, similar to hostN, is assigned by the kernel in order of target discovery... within a given HBA. Therefore these values are a relative scsi target index associated with the scsi host. So the first scsi storage target discovered attached to host0 is assigned scsi target (relative index) 0, then 1, and 2 and so forth. Similarly the first scsi target discovered attached to host1 is also assigned scsi target (relative index) 0, then 1, and 2 and so forth. This means that scsi target id is scsi hostN relative. Within FC and FCoE, the scsi target is a storage port within the san storage box.
  • L: Logical Unit Number (LUN) is the logical device within the SCSI target, as seen by the operating system. Typically a logical disk, or a tape device. The LUN number is assigned by storage -- the only part of the scsi address that is not assigned by the kernel.

The following illustrates the nature of a scsi address providing a "route" from host to scsi device.


   HBA (Host Bus Adapter)                                                     SCSI
 e.g. PCI storage controller                                                  address
+---------------------------+              +----------------------------+     h:b:t:l
| SCSI      | Bus/Channel(0)+------------->+ SCSI Target (0) |  LUN 0   |  << 0:0:0:0
| Host (0)  +---------------+              |                 +----------+
|           | Bus/Channel(1)+------+       |                 |  LUN 1   |  << 0:0:0:1
+---------------------------+      |       |                 +----------+
                                   |       |                 :          |
                                   |       |                 +----------+
                                   |       |                 |  LUN n   |  << 0:0:0:n
                                   |       +----------------------------+
                                   |
                                   |
                                   |       +----------------------------+
                                   +------>+ SCSI Target (0) |  LUN 0   |  << 0:1:0:0
                                           |                 +----------+
                                           |                 |  LUN 1   |  << 0:1:0:1
                                           |                 +----------+
                                           |                 |  LUN 2   |  << 0:1:0:2
                                           |                 +----------+
                                           |                 :          |
                                           |                 +----------+
                                           |                 |  LUN n   |  << 0:1:0:n
                                           +----------------------------+

A couple things to note within the above: each subsequent piece of the scsi address is unique and relative to the peice before it. So while there is only one scsi host 0 within a server, there could be multiple bus/channel 0s -- one associated with each unique scsi host. The same holds true for scsi targets: in the above diagram there are two SCSI target 0s - but one is 0:0:0 (host:bus:target) and the other is 0:1:0 (host:bus:target) and thus represent unique individual routes.

The following illustrates the nature of scsi address providing a multiple paths or "routes" from multiple HBA to the same set of scsi devices within a Fibre Channel environment.

   HBA (Host Bus Adapter)
 e.g. PCI storage controller                                                   SCSI
+---------------------------+    +-----+   +----------------------------+      Addresses
| SCSI      | Bus/Channel(0)+--->+  F  +-->+ SCSI Target (n) |  LUN 0   |   << 0:0:0:0 AND 1:0:2:0
| Host (0)  |               |    |  C  |   |                 +----------+
|           |               |    |     |   |                 |  LUN 1   |   << 0:0:0:1 AND 1:0:2:1
+---------------------------+    |  S  |   |                 +----------+
                                 |  w  |   |                 :          |
+---------------------------+    |  i  |   |                 +----------+
| SCSI      | Bus/Channel(0)+--->+  t  |   |                 |  LUN n   |   << 0:0:0:n AND 1:0:2:n
| Host (1)  |               |    |  c  |   +----------------------------+
|           |               |    |  h  |
+---------------------------+    +-----+

While SCSI host 0 may discover the SCSI target "n" as its first SCSI target and thus is assigned target id 0, SCSI host 1 in the diagram above discovered this particular SCSI target as the 3rd target and thus was assigned an id of 2 (after target ids 0 and 1 were assigned to previously disovered targets accessible via host1 -- target ids 1:0:0 and 1:0:1 not shown).

You will be able to find the scsi LUNs in /proc/scsi/scsi. For example, still on the same host as above, we can see:


# cat /proc/scsi/scsi 
Attached devices:  
Host: scsi0 Channel: 00 Id: 00 Lun: 00                                   
  Vendor: ADIC     Model: FastStor DLT     Rev: D116  
  Type:   Medium Changer                   ANSI SCSI revision: 02  
Host: scsi0 Channel: 00 Id: 01 Lun: 00                                   
  Vendor: Quantum  Model: DLT4000          Rev: D782  
  Type:   Sequential-Access                ANSI SCSI revision: 02  
Host: scsi1 Channel: 00 Id: 00 Lun: 00                                   
  Vendor: FUJITSU  Model: MAJ3091MC        Rev: 5508  
  Type:   Direct-Access                    ANSI SCSI revision: 04  
Host1: scsi1 Channel: 00 Id: 01 Lun: 00                                  
  Vendor: FUJITSU  Model: MAJ3091MC        Rev: 5508  
  Type:   Direct-Access                    ANSI SCSI revision: 04  
Host: scsi1 Channel: 00 Id: 02 Lun: 00  
  Vendor: IBM      Model: DDYS-T36950M     Rev: S96H  
  Type:   Direct-Access                    ANSI SCSI revision: 03  
Host: scsi1 Channel: 00 Id: 06 Lun: 00  
  Vendor: DELL     Model: 1x5 U2W SCSI BP  Rev: 1.16  
  Type:   Processor                        ANSI SCSI revision: 02

as expected on:


Host: scsi0 Channel: 00 Id: 00 Lun: 00 -> HBTL [0:0:0:0] - Medium Changer              
Host: scsi0 Channel: 00 Id: 01 Lun: 00 -> HBTL [0:0:1:0] - Sequential-Access (TAPE)
Host: scsi1 Channel: 00 Id: 00 Lun: 00 -> HBTL [1:0:0:0] - Direct-Access (Disk)     

Another command to output the same data is lsscsi from the package of the same name:

# lsscsi -g
[0:0:0:0]    changer ADIC     FastStor DLT     D116  /dev/sg0
[0:0:1:0]    tape    Quantum  DLT4000          D782  /dev/st0   /dev/sg1
[1:0:0:0]    disk    FUJITSU  MAJ3091MC        5508  /dev/sda   /dev/sg2
[1:0:1:0]    disk    IBM      DDYS-T36950M     S96H  /dev/sdb   /dev/sg3
:

As another illustrative example, below shows two S-ATA disks, on two scsi controllers:

# cat /proc/scsi/scsi  
Attached devices:  
Host: scsi0 Channel: 00 Id: 00 Lun: 00  
  Vendor: ATA      Model: WDC WD2500JS-75N Rev: 10.0  
  Type:   Direct-Access                    ANSI SCSI revision: 05  
Host: scsi1 Channel: 00 Id: 00 Lun: 00  
  Vendor: ATA      Model: WDC WD7500AACS-0 Rev: 01.0  
  Type:   Direct-Access                    ANSI SCSI revision: 05

In the first entry, we can see an ATA disk of model WDC WD2500JS-75N, which is located on:

Host: scsi0 Channel: 00 Id: 00 Lun: 00 or simply [0:0:0:0]

On Red Hat Enterprise Linux 5 most of the information for SCSI devices can be found within the /sys filesystem. For further information, refer to the article below for the systool command, which is designed to traverse the /sys filesystem gracefully.

Why is the /proc/scsi/qla2xxx/ or /proc/scsi/lpfc/ directory missing in Red Hat Enterprise Linux 5 and what has replaced it?

Category
Tags