MPT fusion SAS target numbering...
Hello Eric, I have a question about the behavior of the Linux MPT Fusion SAS driver, and I hope you can clue me in.
The microcode of these cards tracks physical devices and once seen makes sure the device shows up with the same physical target number even if you hotplug the SAS disk into a different slot or similar.
But it seems that the Linux driver is totally ignoring the topology target numbering provided by the SAS topology scan and simply assigning consequetive indexes, starting at 0, for the target numbers presented to the Linux SCSI layer.
It puts a virtual target shim in between these two things so that the mptsas driver can convert the "virtual target" IDs presented to the Linux SCSI layer into the ones indicated by the SAS topology information.
Why does it do this? This breaks a lot of things for me on Sparc, for example. There, the device target numbers used by the firmware use the SAS toplogy provided target numbering, whereas the Linux driver uses this (seemingly arbitrary) linear assignment.
the sas transport layer is assigning the target id's
________________________________________
From: David Miller [[email protected]]
Sent: Saturday, May 02, 2009 4:15 PM
To: Moore, Eric
Cc: [email protected]; [email protected]; [email protected]
Subject: MPT fusion SAS target numbering...
Hello Eric, I have a question about the behavior of the Linux MPT Fusion SAS driver, and I hope you can clue me in.
The microcode of these cards tracks physical devices and once seen makes sure the device shows up with the same physical target number even if you hotplug the SAS disk into a different slot or similar.
But it seems that the Linux driver is totally ignoring the topology target numbering provided by the SAS topology scan and simply assigning consequetive indexes, starting at 0, for the target numbers presented to the Linux SCSI layer.
It puts a virtual target shim in between these two things so that the mptsas driver can convert the "virtual target" IDs presented to the Linux SCSI layer into the ones indicated by the SAS topology information.
Why does it do this? This breaks a lot of things for me on Sparc, for example. There, the device target numbers used by the firmware use the SAS toplogy provided target numbering, whereas the Linux driver uses this (seemingly arbitrary) linear assignment.
From: "Moore, Eric" <[email protected]>
Date: Sat, 2 May 2009 16:44:54 -0600
Quoted 1 line
the sas transport layer is assigning the target id's
Can you show me where that happens and how the MPT fusion SAS driver exports the SAS topology target IDs to that layer?
From: David Miller <[email protected]>
Date: Sat, 02 May 2009 15:51:55 -0700 (PDT)
Quoted 8 lines
From: "Moore, Eric" <[email protected]>
Date: Sat, 2 May 2009 16:44:54 -0600Quoted 1 line
the sas transport layer is assigning the target id's
Can you show me where that happens and how the MPT fusion SAS driver exports the SAS topology target IDs to that layer?
Just so you have a concrete example of the problem I am having. The SAS scan shows:
[ 69.492431] mptsas_sas_device_pg0() [ 69.497824] mptsas: ioc0: ---- SAS DEVICE PAGE 0 --------- [ 69.497829] mptsas: ioc0: Handle=0x1 [ 69.497832] mptsas: ioc0: Parent Handle=0x0 [ 69.497836] mptsas: ioc0: Enclosure Handle=0x1 [ 69.497840] mptsas: ioc0: Slot=0x0 [ 69.497843] mptsas: ioc0: SAS Address=0x5080020000002999 [ 69.497847] mptsas: ioc0: Target ID=0x3 [ 69.497851] mptsas: ioc0: Bus=0x0 [ 69.497854] mptsas: ioc0: Parent Phy Num=0x0 [ 69.497857] mptsas: ioc0: Access Status=0x0 [ 69.497861] mptsas: ioc0: Device Info=0x1071 [ 69.497865] mptsas: ioc0: Flags=0x1 [ 69.497868] mptsas: ioc0: Physical Port=0x0 [ 69.497870] [ 69.497874] mptsas_sas_device_pg0() [ 69.503148] mptsas: ioc0: ---- SAS DEVICE PAGE 0 --------- [ 69.503153] mptsas: ioc0: Handle=0x5 [ 69.503156] mptsas: ioc0: Parent Handle=0x1 [ 69.503160] mptsas: ioc0: Enclosure Handle=0x1 [ 69.503163] mptsas: ioc0: Slot=0x0 [ 69.503166] mptsas: ioc0: SAS Address=0x1221000000000000 [ 69.503170] mptsas: ioc0: Target ID=0x0 [ 69.503174] mptsas: ioc0: Bus=0x0 [ 69.503177] mptsas: ioc0: Parent Phy Num=0x0 [ 69.503180] mptsas: ioc0: Access Status=0x0 [ 69.503184] mptsas: ioc0: Device Info=0x881 [ 69.503187] mptsas: ioc0: Flags=0x2F3 [ 69.503191] mptsas: ioc0: Physical Port=0x0
Targets 3 and 0, what I expect.
Yet the SCSI layer assigns targets 0 and 1 to these devices:
[ 69.528237] mptsas_target_alloc: starget->id == 0 [ 69.531525] mptsas_target_alloc: rphy == fffff8127d3bb000 sas_address=0x12210 00000000000 [ 69.538112] mptsas_target_alloc: using phy_info id == 0 [ 69.543938] scsi 0:0:0:0: Direct-Access ATA HITACHI HDS7225S A94A PQ : 0 ANSI: 5 [ 69.552860] sd 0:0:0:0: [sda] 488390625 512-byte hardware sectors: (250 GB/23 2 GiB) [ 69.552950] mptsas_target_alloc: starget->id == 1 [ 69.552955] mptsas_target_alloc: rphy == fffff8127d3ab600 sas_address=0x12210 00003000000 [ 69.552959] mptsas_target_alloc: using phy_info id == 3 [ 69.554458] scsi 0:0:1:0: Direct-Access ATA INTEL SSDSA2MH08 8610 PQ
: 0 ANSI: 5
I want to know why this disconnect? Shouldn't the SAS topology provided target IDs be used instead?
James Bottomley
maintainerQuoted 8 lines · David Miller
From: "Moore, Eric" <[email protected]>
Date: Sat, 2 May 2009 16:44:54 -0600Quoted 1 line
the sas transport layer is assigning the target id's
Can you show me where that happens and how the MPT fusion SAS driver exports the SAS topology target IDs to that layer?
It happens in scsi_transport_sas.c:sas_rphy_add() which uses the sas_host_attr's next_target_id to track a monotonically increasing number for the SCSI target id (it gets incremented every time a remote port is added to the system).
What the SAS spec defines as the target id is really a 64 bit WWPN, which was difficult at the time to place in the SCSI mid layer SPI based
concept of a target. If the fusion is also defining some number as a
target id that isn't the WWPN, then we could export that as well somewhere ... that's essentially what we did for the qlogic and emulex persistent bindings.
James
From: James Bottomley <[email protected]>
Date: Sat, 02 May 2009 18:30:38 -0500
Quoted 15 lines · David Miller
Quoted 8 lines
From: "Moore, Eric" <[email protected]>
Date: Sat, 2 May 2009 16:44:54 -0600Quoted 1 line
the sas transport layer is assigning the target id's
Can you show me where that happens and how the MPT fusion SAS driver exports the SAS topology target IDs to that layer?
It happens in scsi_transport_sas.c:sas_rphy_add() which uses the sas_host_attr's
next_target_idto track a monotonically increasing number for the SCSI target id (it gets incremented every time a remote port is added to the system).
Quoted 6 lines
What the SAS spec defines as the target id is really a 64 bit WWPN, which was difficult at the time to place in the SCSI mid layer SPI based
concept of a target. If the fusion is also defining some number as a
target id that isn't the WWPN, then we could export that as well somewhere ... that's essentially what we did for the qlogic and emulex persistent bindings.
It's not a WWPN, the SAS topology scan on the MPT Fusion SAS card provides a SCSI target ID to use.
This way when disks are popped in and out of slots, the SCSI target remains the same. The microcode on the card keeps a WWPN to SCSI target ID mapping. Once it sees a WWPN for the first time, it creates a new mapping in it's table.
The system firmware, and the Solaris MPT Fusion driver, both use this value in this way.
Without using this mapping, Linus makes it insanely difficult for me to install boot loaders correctly. Because I have to be able to map from Linux device to firmware device and the only way I can sanely do that is if the Linux device driver respects the SAS topology provided target ID given the the MPT SAS card.
James Bottomley
maintainerQuoted 33 lines · David Miller
From: James Bottomley <[email protected]>
Date: Sat, 02 May 2009 18:30:38 -0500Quoted 15 lines · David Miller
Quoted 8 lines
From: "Moore, Eric" <[email protected]>
Date: Sat, 2 May 2009 16:44:54 -0600Quoted 1 line
the sas transport layer is assigning the target id's
Can you show me where that happens and how the MPT fusion SAS driver exports the SAS topology target IDs to that layer?
It happens in scsi_transport_sas.c:sas_rphy_add() which uses the sas_host_attr's
next_target_idto track a monotonically increasing number for the SCSI target id (it gets incremented every time a remote port is added to the system).Quoted 6 lines
What the SAS spec defines as the target id is really a 64 bit WWPN, which was difficult at the time to place in the SCSI mid layer SPI based
concept of a target. If the fusion is also defining some number as a
target id that isn't the WWPN, then we could export that as well somewhere ... that's essentially what we did for the qlogic and emulex persistent bindings.It's not a WWPN, the SAS topology scan on the MPT Fusion SAS card provides a SCSI target ID to use.
This way when disks are popped in and out of slots, the SCSI target remains the same. The microcode on the card keeps a WWPN to SCSI target ID mapping. Once it sees a WWPN for the first time, it creates a new mapping in it's table.
Quoted 8 lines
The system firmware, and the Solaris MPT Fusion driver, both use this value in this way.
Without using this mapping, Linus makes it insanely difficult for me to install boot loaders correctly. Because I have to be able to map from Linux device to firmware device and the only way I can sanely do that is if the Linux device driver respects the SAS topology provided target ID given the the MPT SAS card.
I Understand, that's why it's like the Fibre persistent bindings. There are, unfortunately, good reasons why it can't be used as the target id, but if we just exported the id, udev can create a device node using it and you can mount via that device node in an across boot consistent manner ... will that do?
James
From: James Bottomley <[email protected]>
Date: Sat, 02 May 2009 23:10:33 -0500
Quoted 5 lines
I Understand, that's why it's like the Fibre persistent bindings. There are, unfortunately, good reasons why it can't be used as the target id, but if we just exported the id, udev can create a device node using it and you can mount via that device node in an across boot consistent manner ... will that do?
I see no reason why you wouldn't want to use known perfectly good persistent SCSI target IDs computed by the card.
It doesn't make any sense, and it is inconsistent with how any other piece of code in the world handles these values provided by the card.
James Bottomley
maintainerQuoted 11 lines · David Miller
From: James Bottomley <[email protected]>
Date: Sat, 02 May 2009 23:10:33 -0500Quoted 5 lines
I Understand, that's why it's like the Fibre persistent bindings. There are, unfortunately, good reasons why it can't be used as the target id, but if we just exported the id, udev can create a device node using it and you can mount via that device node in an across boot consistent manner ... will that do?
I see no reason why you wouldn't want to use known perfectly good persistent SCSI target IDs computed by the card.
The technical reason is that the lifetime rules for the IDs in the card firmware don't match the lifetime rules in the mid layer and target ids in the mid layer have to be unique. It's not a problem absent hotplug, but SAS is a hotplug bus.
... unplug from phy1 and plug immediately into phy2 is the most
pathological case for this.
We could take the fusion target ID as a hint and only overrule it if it would cause duplicate IDs, so get it right 95% of the time ... but I can just bet we'd see a large number of complaints about the surprise factor involved in the 5% of cases where we had to allocate a new id.
Quoted 3 lines
It doesn't make any sense, and it is inconsistent with how any other piece of code in the world handles these values provided by the card.
We can export the values provided by the card, and udev can create a device node based on them, thus giving apparent persistence to device nodes with this, so that would solve the boot from and mount from issue.
James
James
The SAS1.0 mpt fusion controllers have device mapping in the firmware. Meaning there is persistent target ids maintained by fusion firmware. Our device driver finds out the target ids at driver load time when it scans the sas device page 0 config pages. Also the target ids are provided in the hotplug events. When scsi commands are sent to firmware, devices are are addressed using firmware target ids via the SCSI_IO message frame. Our driver has to convert the target ids passed in by scmd->device->id, to the target ids needed by our firmware. The mapping is stored in the sdev hostdata. Obviously what this means is our persistent ids mapping set by our controller firmware is thrown out when we call sas_rphy_add(). I debated this problem with you and Christoph back when we design
ed the sas transport layer several years back. You guys said that persistency will be handled by udev (device ids or path), and the debate ended with that. If you want to change this now, that would be great (making many customers much happier).
However, the SAS2.0 mpt2sas fusion controller doesn't have device mapping, that was pushed up to the drivers. Addressing of devices are using device handles.
The windows device driver guys have implemented device mapping in the sas2.0 drivers, I didn't.
Eric
________________________________________
From: David Miller [[email protected]]
Sent: Saturday, May 02, 2009 6:09 PM
To: [email protected]
Cc: Moore, Eric; [email protected]; [email protected]; [email protected]
Subject: Re: MPT fusion SAS target numbering...
From: James Bottomley <[email protected]>
Date: Sat, 02 May 2009 18:30:38 -0500
Quoted 15 lines · David Miller
Quoted 8 lines
From: "Moore, Eric" <[email protected]>
Date: Sat, 2 May 2009 16:44:54 -0600Quoted 1 line
the sas transport layer is assigning the target id's
Can you show me where that happens and how the MPT fusion SAS driver exports the SAS topology target IDs to that layer?
It happens in scsi_transport_sas.c:sas_rphy_add() which uses the sas_host_attr's
next_target_idto track a monotonically increasing number for the SCSI target id (it gets incremented every time a remote port is added to the system).
Quoted 6 lines
What the SAS spec defines as the target id is really a 64 bit WWPN, which was difficult at the time to place in the SCSI mid layer SPI based
concept of a target. If the fusion is also defining some number as a
target id that isn't the WWPN, then we could export that as well somewhere ... that's essentially what we did for the qlogic and emulex persistent bindings.
It's not a WWPN, the SAS topology scan on the MPT Fusion SAS card provides a SCSI target ID to use.
This way when disks are popped in and out of slots, the SCSI target remains the same. The microcode on the card keeps a WWPN to SCSI target ID mapping. Once it sees a WWPN for the first time, it creates a new mapping in it's table.
The system firmware, and the Solaris MPT Fusion driver, both use this value in this way.
Without using this mapping, Linus makes it insanely difficult for me to install boot loaders correctly. Because I have to be able to map from Linux device to firmware device and the only way I can sanely do that is if the Linux device driver respects the SAS topology provided target ID given the the MPT SAS card.
From: "Moore, Eric" <[email protected]>
Date: Sat, 2 May 2009 22:20:28 -0600
Quoted 5 lines
I debated this problem with you and Christoph back when we designed the sas transport layer several years back. You guys said that persistency will be handled by udev (device ids or path), and the debate ended with that. If you want to change this now, that would be great (making many customers much happier).
Please do this.
The current situation is absolutely awful :-(