Skip to contentSkip to conversation

/dev/disk/by-id incomplete and unhelpful for SATA drives

PATCH In review Chris Paulson-Ellis 7 participants 18 messages Dec 21, 2005 – Mar 7, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

I have a couple of problems with udev /dev/disk/by-id (missing entries and entries with unhelpful names) which is described in this gentoo bug...

http://bugs.gentoo.org/show_bug.cgi?id9582

I'm currently running udev-078 on vanilla 2.6.15-rc6. I carefully uninstalled all of hotplug, coldplug & udev and then re-installed udev just to make sure I've got a cleanly installed udev environment.

Can anyone help?

Chris.

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#1 lore raw
Quoted 10 lines · Chris Paulson-Ellis

I have a couple of problems with udev /dev/disk/by-id (missing entries and entries with unhelpful names) which is described in this gentoo bug...

http://bugs.gentoo.org/show_bug.cgi?id9582

I'm currently running udev-078 on vanilla 2.6.15-rc6. I carefully uninstalled all of hotplug, coldplug & udev and then re-installed udev just to make sure I've got a cleanly installed udev environment.

Can anyone help?

Maxtor has a long history of doing broken serial numbers, they even shipped disks with serials like: "M0000000000000000000". Regarding this, the first suspect here is the disk itself.

Are the examples with the sata/pata in the bug:
/dev/disk
|-- by-id
| |-- ata-Maxtor_4D080H4_D41S8XWE -> ../../hde

/dev/disk
|-- by-id
| |-- scsi-0ATA_Maxtor_6Y160M0_Linux_ATA-SCSI_simulator -> ../../sdb

from the same disk model in a different box, or is it a different disk model?

What does:
scsi_id -g -p0x80 -x -s /block/sda
scsi_id -g -p0x83 -x -s /block/sda
print?

Any chance to check the failing disk on an interface in pata mode, so you get a hd* entry instead?

Thanks,
Kay

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#2 lore raw
In reply to Chris Paulson-Ellis
Quoted 11 lines · Kay Sievers
Quoted 5 lines · Chris Paulson-Ellis

[snip]
http://bugs.gentoo.org/show_bug.cgi?id9582

I'm currently running udev-078 on vanilla 2.6.15-rc6 [snip]

Maxtor has a long history of doing broken serial numbers, they even shipped disks with serials like: "M0000000000000000000". Regarding this, the first suspect here is the disk itself.

I'm not suprised. I've also found Maxtor to be a manafacturer of poor quality drives. I hope Seagate know what they're buying! This doesn't explain why one of the drives is missing altogether from by-id, while the other drive of the same model is present, albeit with a duff name.

Quoted 6 lines

Are the examples with the sata/pata in the bug:
/dev/disk
|-- by-id
| |-- ata-Maxtor_4D080H4_D41S8XWE -> ../../hde

Quoted 6 lines

/dev/disk
|-- by-id
| |-- scsi-0ATA_Maxtor_6Y160M0_Linux_ATA-SCSI_simulator -> ../../sdb

from the same disk model in a different box, or is it a different disk model?

Different models (PATA/SATA). The drive models shown in the first part of the by-id name are correct.

Quoted 4 lines

What does:
scsi_id -g -p0x80 -x -s /block/sda
scsi_id -g -p0x83 -x -s /block/sda
print?

It looks like you're on to something (though I don't understand what); The first command reveals the correct serial number...

# scsi_id -g -p0x80 -x -s /block/sda
ID_VENDOR=ATA
ID_MODEL=Maxtor_6Y160M0
ID_REVISION=YAR5
ID_SERIAL=SATA_Maxtor_6Y160M0_Y4DCTR3E
ID_TYPE=disk
ID_BUS=scsi
# scsi_id -g -p0x83 -x -s /block/sda
ID_VENDOR=ATA
ID_MODEL=Maxtor_6Y160M0
ID_REVISION=YAR5
ID_SERIAL
TA_Maxtor_6Y160M0_Linux_ATA-SCSI_simulator
ID_TYPE=disk
ID_BUS=scsi
Quoted 2 lines

Any chance to check the failing disk on an interface in pata mode, so you get a hd* entry instead?

I thought the SATA as PATA driver had been replaced by libata? It may be hard to change them anyway as they are in a pre-existing RAID array which may not appreciate the change of naming! I'll give it a go if the above is not sufficient.

Chris.

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#3 lore raw
In reply to Chris Paulson-Ellis
Quoted 9 lines · Chris Paulson-Ellis
Quoted 8 lines · Kay Sievers
Quoted 5 lines · Chris Paulson-Ellis

[snip]
http://bugs.gentoo.org/show_bug.cgi?id9582

I'm currently running udev-078 on vanilla 2.6.15-rc6 [snip]

Quoted 8 lines
Quoted 3 lines

Maxtor has a long history of doing broken serial numbers, they even shipped disks with serials like: "M0000000000000000000". Regarding this, the first suspect here is the disk itself.

I'm not suprised. I've also found Maxtor to be a manafacturer of poor quality drives. I hope Seagate know what they're buying! This doesn't explain why one of the drives is missing altogether from by-id, while the other drive of the same model is present, albeit with a duff name.

Sure, both disks have the same "serial number", which will create the same links, so the last one wins and replaces the links of the other disk.

Quoted 10 lines
Quoted 10 lines

Are the examples with the sata/pata in the bug:
/dev/disk
|-- by-id
| |-- ata-Maxtor_4D080H4_D41S8XWE -> ../../hde

/dev/disk
|-- by-id
| |-- scsi-0ATA_Maxtor_6Y160M0_Linux_ATA-SCSI_simulator -> ../../sdb

Quoted 5 lines
Quoted 2 lines

from the same disk model in a different box, or is it a different disk model?

Different models (PATA/SATA). The drive models shown in the first part of the by-id name are correct.

Ok.

Quoted 7 lines
Quoted 4 lines

What does:
scsi_id -g -p0x80 -x -s /block/sda
scsi_id -g -p0x83 -x -s /block/sda
print?

It looks like you're on to something (though I don't understand what); The first command reveals the correct serial number...

These are the pages requested from the disk which contain all the product information. It's defined by the SCSI standard.

Quoted 4 lines
# scsi_id -g -p0x80 -x -s /block/sda
ID_VENDOR=ATA
ID_MODEL=Maxtor_6Y160M0
ID_REVISION=YAR5
Quoted 8 lines
ID_SERIAL=SATA_Maxtor_6Y160M0_Y4DCTR3E
ID_TYPE=disk
ID_BUS=scsi
# scsi_id -g -p0x83 -x -s /block/sda
ID_VENDOR=ATA
ID_MODEL=Maxtor_6Y160M0
ID_REVISION=YAR5
ID_SERIAL

TA_Maxtor_6Y160M0_Linux_ATA-SCSI_simulator

Quoted 11 lines

ID_TYPE=disk
ID_BUS=scsi

Quoted 2 lines

Any chance to check the failing disk on an interface in pata mode, so you get a hd* entry instead?

I thought the SATA as PATA driver had been replaced by libata? It may be hard to change them anyway as they are in a pre-existing RAID array which may not appreciate the change of naming! I'll give it a go if the above is not sufficient.

No, the page 0x80 is fine, I hope. Try if putting:
vendor="ATA",options=-p 0x80
in:
/etc/scsi_id.config
helps.

Kay

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#4 lore raw
In reply to Chris Paulson-Ellis
Quoted 10 lines · Kay Sievers
Quoted 5 lines · Chris Paulson-Ellis
Quoted 4 lines · Kay Sievers
Quoted 3 lines · Chris Paulson-Ellis

[snip]
http://bugs.gentoo.org/show_bug.cgi?id9582
[snip]

Sure, both disks have the same "serial number", which will create the same links, so the last one wins and replaces the links of the other disk.

Of course. I could have worked that out by myself if I'd thought about it for more than 2 minutes!

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

[snip]
What does:
scsi_id -g -p0x80 -x -s /block/sda
scsi_id -g -p0x83 -x -s /block/sda
print?

Quoted 17 lines
Quoted 1 line

[snip]

These are the pages requested from the disk which contain all the product information. It's defined by the SCSI standard.

Quoted 12 lines
# scsi_id -g -p0x80 -x -s /block/sda
ID_VENDOR=ATA
ID_MODEL=Maxtor_6Y160M0
ID_REVISION=YAR5
ID_SERIAL=SATA_Maxtor_6Y160M0_Y4DCTR3E
ID_TYPE=disk
ID_BUS=scsi
# scsi_id -g -p0x83 -x -s /block/sda
ID_VENDOR=ATA
ID_MODEL=Maxtor_6Y160M0
ID_REVISION=YAR5
ID_SERIAL

TA_Maxtor_6Y160M0_Linux_ATA-SCSI_simulator

Quoted 10 lines
Quoted 4 lines

ID_TYPE=disk
ID_BUS=scsi

Quoted 1 line

[snip]

Try if putting:
vendor="ATA",options=-p 0x80
in:
/etc/scsi_id.config
helps.

Bingo. I added the following to /etc/scsi_id.config...

# Make SATA drives report sensible serial numbers

# instead of "Linux_ATA-SCSI_simulator"
vendor="ATA", options="-p 0x80"

...and now it works:

# tree /dev/disk
/dev/disk
|-- by-id
|   |-- scsi-SATA_Maxtor_6Y160M0_Y4DCTR3E -> ../../sda
|   |-- scsi-SATA_Maxtor_6Y160M0_Y4DCTR3E-part1 -> ../../sda1
|   |-- scsi-SATA_Maxtor_6Y160M0_Y4DCTR3E-part2 -> ../../sda2
|   |-- scsi-SATA_Maxtor_6Y160M0_Y4DCTR3E-part3 -> ../../sda3
|   |-- scsi-SATA_Maxtor_6Y160M0_Y4DCTVFE -> ../../sdb
|   |-- scsi-SATA_Maxtor_6Y160M0_Y4DCTVFE-part1 -> ../../sdb1
|   |-- scsi-SATA_Maxtor_6Y160M0_Y4DCTVFE-part2 -> ../../sdb2
|   |-- scsi-SATA_Maxtor_6Y160M0_Y4DCTVFE-part3 -> ../../sdb3
|   |-- usb-Maxtor_OneTouch_Y3LYJVEE -> ../../sdc
|   `-- usb-Maxtor_OneTouch_Y3LYJVEE-part1 -> ../../sdc1
|-- by-path
|   |-- pci-0000:00:1f.2-scsi-0:0:0:0 -> ../../sda
|   |-- pci-0000:00:1f.2-scsi-0:0:0:0-part1 -> ../../sda1
|   |-- pci-0000:00:1f.2-scsi-0:0:0:0-part2 -> ../../sda2
|   |-- pci-0000:00:1f.2-scsi-0:0:0:0-part3 -> ../../sda3
|   |-- pci-0000:00:1f.2-scsi-1:0:0:0 -> ../../sdb
|   |-- pci-0000:00:1f.2-scsi-1:0:0:0-part1 -> ../../sdb1
|   |-- pci-0000:00:1f.2-scsi-1:0:0:0-part2 -> ../../sdb2
|   |-- pci-0000:00:1f.2-scsi-1:0:0:0-part3 -> ../../sdb3
|   |-- usb-Y3LYJVEE:0:0:0 -> ../../sdc
|   `-- usb-Y3LYJVEE:0:0:0-part1 -> ../../sdc1
`-- by-uuid
     |-- 2b9ac501-a3c8-4860-a251-d639c78335fc -> ../../md/2
     |-- 5a4f4464-0b58-1068-a788-5c5b3e1f109d -> ../../sda1
     |-- 7293013d-38d3-5da5-73a1-1aa2d8ed4f07 -> ../../sda2
     |-- a5c7e1a4-0c32-4a43-8adb-e3d57ca82984 -> ../../md/0
     |-- c05c061d-124c-4011-9ec5-bfb794a31de2 -> ../../sdc1
     `-- cf90252c-3fef-9382-56cc-56dc7ce36f8e -> ../../sda3

I was also able to fix the problem by adding a udev rule to recognise the broken serial number and switch to using scsi_id with page 0x80, just after the first call to scsi_id in the by-id section:

KERNEL="sd*[!0-9]", ENV{ID_SERIAL}="*_Linux_ATA-SCSI_simulator", IMPORT="/sbin/scsi_id -g -x -s %p -d %N -p 0x80"

I'm not sure which fix is better. Perhaps the scsi_id.config fix, as the udev rule could contradict an entry in scsi_id.config, confusing the user. Then again, the rule is only run if neccessary and I prefer to have only one place to look (the udev rules) to see what is happening.

Either fix would be a useful addition to the default scsi_id.config or udev rules, unless the libata driver is changed to report different results from page 0x83 (but perhaps it is doing the right thing!).

Or perhaps scsi_id should use page 0x80 rather than 0x83 by default...

I was curious as to why my USB mass storage device, which is also presented as a SCSI device by the kernel doesn't have the same problem. Looking at the udev rules, it seems that "usb_id -x" is run first, then scsi_id is run only if the serial number is still unknown. usb_id works and it appears that scsi_id would work for the USB drive too, but again only if page 0x80 is used:

# usb_id -x /sys/block/sdc
ID_VENDOR=Maxtor
ID_MODEL=OneTouch
ID_REVISION00
ID_SERIAL=Maxtor_OneTouch_Y3LYJVEE
ID_TYPE=disk
ID_BUS=usb
# scsi_id -g -p 0x80 -x -s /block/sdc
ID_VENDOR=Maxtor
ID_MODEL=OneTouch
ID_REVISION00
ID_SERIAL=SMaxtor_OneTouch_Y3LYJVEE
ID_TYPE=disk
ID_BUS=scsi
# scsi_id -g -p 0x83 -x -s /block/sdc
2:0:0:0: Invalid page 0x83

Thanks for your help,
Chris.

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#5 lore raw
In reply to Chris Paulson-Ellis
Quoted 7 lines · Chris Paulson-Ellis

KERNEL="sd*[!0-9]", ENV{ID_SERIAL}="*_Linux_ATA-SCSI_simulator", IMPORT="/sbin/scsi_id -g -x -s %p -d %N -p 0x80"

I'm not sure which fix is better. Perhaps the scsi_id.config fix, as the udev rule could contradict an entry in scsi_id.config, confusing the user. Then again, the rule is only run if neccessary and I prefer to have only one place to look (the udev rules) to see what is happening.

Why not just fix the kernel when it's filling in the page 83 data to pull the serial from page 80 instead of putting *that* there?

Bill

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#6 lore raw
In reply to Chris Paulson-Ellis

I can see the ID of my SATA drive with

# scsi_id -g -p0x80 -x -s /block/sda
ID_VENDOR=ATA
ID_MODEL=ST3400832AS
ID_REVISION=3.03
ID_SERIAL=SATA_ST3400832AS_5NF14TVY
ID_TYPE=disk
ID_BUS=scsi

or with

# sdparm --page=sn /dev/sda
    /dev/sda: ATA       ST3400832AS       3.03
Unit serial number VPD page:
              5NF14TVY

On a Debian sid (amd64) with udev 0.076-6, however, I don't have a /etc/scsi_id.config.
Can I give my drives mount points using only /etc/udev.rules?

Another possibility would be to use label, which shows correctly in tree:

# tree /dev/disk
/dev/disk
|-- by-id
|   |-- ata-Maxtor_7B250R0_B61NS9FH -> ../../hda
|   |-- ata-Maxtor_7B250R0_B61NS9FH-part1 -> ../../hda1
|   |-- ata-Maxtor_7B250R0_B61NS9FH-part2 -> ../../hda2
|   |-- ata-Maxtor_7B250R0_B61NS9FH-part3 -> ../../hda3
|   |-- ata-Maxtor_7B250R0_B61NS9FH-part4 -> ../../hda4
|   |-- ata-Maxtor_7B250R0_B61NS9FH-part5 -> ../../hda5
|   |-- ata-Maxtor_7B250R0_B61NS9FH-part6 -> ../../hda6
|   |-- ata-Maxtor_7B250R0_B61NS9FH-part7 -> ../../hda7
|   |-- ata-Maxtor_7B250R0_B61NS9FH-part8 -> ../../hda8
|   |-- scsi-0ATA_ST3400832AS_Linux_ATA-SCSI_simulator -> ../../sda
|   `-- scsi-0ATA_ST3400832AS_Linux_ATA-SCSI_simulator-part1 -> ../../sda1
|-- by-label
|   |-- bc5 -> ../../sda1
|   |-- bc6 -> ../../sdb1
|   `-- bcspare -> ../../hda8

I have drives with several different filesystems, but perhaps that makes no difference? These three labels are all XFS.

The board has two SATA chips, sata_sil and sata_nv, and device nodes vary depending on how many drives are present. I remove drives as they fill and put them in SATA-to-USB enclosures. Ideally I'd have them mount to the same location also as external drives.

Dave

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#7 lore raw
In reply to Chris Paulson-Ellis
Quoted 6 lines · David Liontooth

I can see the ID of my SATA drive with

# scsi_id -g -p0x80 -x -s /block/sda
[snip]
On a Debian sid (amd64) with udev 0.076-6, however, I don't have a
/etc/scsi_id.config.

Create it. See man scsi_id; It should mention the config file. All you need is the line from my earlier post.

Quoted 1 line

Can I give my drives mount points using only /etc/udev.rules?

I gave a way to do this instead of using scsi_id.config in my earlier post.

Good luck.

Chris.

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#8 lore raw
In reply to Chris Paulson-Ellis
Quoted 11 lines · Bill Nottingham
Quoted 7 lines · Chris Paulson-Ellis

KERNEL="sd*[!0-9]", ENV{ID_SERIAL}="*_Linux_ATA-SCSI_simulator", IMPORT="/sbin/scsi_id -g -x -s %p -d %N -p 0x80"

I'm not sure which fix is better. Perhaps the scsi_id.config fix, as the udev rule could contradict an entry in scsi_id.config, confusing the user. Then again, the rule is only run if neccessary and I prefer to have only one place to look (the udev rules) to see what is happening.

Quoted 4 lines

Why not just fix the kernel when it's filling in the page 83 data to pull the serial from page 80 instead of putting *that* there?

Bill

Indeed. Here's the patch. Now I have 3 ways to fix this. Any more anyone?

scsi/libata-scsi.c 2005-12-22 23:56:14.000000000 +0000 renamed from scsi/libata-scsi.c.orig 2005-12-22 23:23:55.000000000 +0000 +6 -8
@@ -1532,16 +1532,13 @@
         return 0;
  }
 
-static const char *inq_83_str = "Linux ATA-SCSI simulator";
-
  /**
   *     ata_scsiop_inq_83 - Simulate INQUIRY EVPD page 83, device identity
   *     @args: device IDENTIFY data / SCSI command of interest.
   *     @rbuf: Response buffer, to which simulated SCSI cmd output is sent.
   *     @buflen: Response buffer length.
   *
- *     Returns device identification.  Currently hardcoded to
- *     return "Linux ATA-SCSI simulator".
+ *     Returns ATA device serial number (as for page 80).
   *
   *     LOCKING:
   *     spin_lock_irqsave(host_set lock)
@@ -1551,13 +1548,14 @@
                               unsigned int buflen)
  {
         rbuf[1] = 0x83;                 /* this page code */
-       rbuf[3] = 4 + strlen(inq_83_str);       /* page len */
+       rbuf[3] = 4 + ATA_SERNO_LEN;    /* page len */
 
         /* our one and only identification descriptor (vendor-specific) */
-       if (buflen > (strlen(inq_83_str) + 4 + 4 - 1)) {
+       if (buflen > (ATA_SERNO_LEN + 4 + 4 - 1)) {
                 rbuf[4 + 0] = 2;        /* code set: ASCII */
-               rbuf[4 + 3] = strlen(inq_83_str);
-               memcpy(rbuf + 4 + 4, inq_83_str, strlen(inq_83_str));
+               rbuf[4 + 3] = ATA_SERNO_LEN;
+               ata_dev_id_string(args->id, (unsigned char *) rbuf + 4 + 4,
+                                 ATA_ID_SERNO_OFS, ATA_SERNO_LEN);
         }
 
         return 0;

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#9 lore raw
Quoted 6 lines · Chris Paulson-Ellis
Quoted 4 lines

Why not just fix the kernel when it's filling in the page 83 data to pull the serial from page 80 instead of putting *that* there?

Bill

Indeed. Here's the patch. Now I have 3 ways to fix this. Any more anyone?

This is the best approach, I think you could even remove page 0x83 support and still be SCSI compliant. You should add a sign-off and re-send the patch to linux-scsi (cc-ed here) and jeff garzik.

What was scsi_id output before and after the patch?

Quoted 26 lines
scsi/libata-scsi.c 2005-12-22 23:56:14.000000000 +0000 renamed from scsi/libata-scsi.c.orig 2005-12-22 23:23:55.000000000 +0000 +2 -5
@@ -1532,16 +1532,13 @@
        return 0;
 }
 
-static const char *inq_83_str = "Linux ATA-SCSI simulator";
-
 /**
  *     ata_scsiop_inq_83 - Simulate INQUIRY EVPD page 83, device identity
  *     @args: device IDENTIFY data / SCSI command of interest.
  *     @rbuf: Response buffer, to which simulated SCSI cmd output is sent.
  *     @buflen: Response buffer length.
  *
- *     Returns device identification.  Currently hardcoded to
- *     return "Linux ATA-SCSI simulator".
+ *     Returns ATA device serial number (as for page 80).
  *
  *     LOCKING:
  *     spin_lock_irqsave(host_set lock)
@@ -1551,13 +1548,14 @@
                              unsigned int buflen)
 {
        rbuf[1] = 0x83;                 /* this page code */
-       rbuf[3] = 4 + strlen(inq_83_str);       /* page len */
+       rbuf[3] = 4 + ATA_SERNO_LEN;    /* page len */

scsi/libata-scsi.c 2005-12-22 23:56:14.000000000 +0000 line 1558

Quoted 10 lines
scsi/libata-scsi.c 2005-12-22 23:56:14.000000000 +0000 renamed from scsi/libata-scsi.c.orig 2005-12-22 23:23:55.000000000 +0000 +4 -3
 
        /* our one and only identification descriptor (vendor-specific) */
-       if (buflen > (strlen(inq_83_str) + 4 + 4 - 1)) {
+       if (buflen > (ATA_SERNO_LEN + 4 + 4 - 1)) {
                rbuf[4 + 0] = 2;        /* code set: ASCII */
-               rbuf[4 + 3] = strlen(inq_83_str);
-               memcpy(rbuf + 4 + 4, inq_83_str, strlen(inq_83_str));
+               rbuf[4 + 3] = ATA_SERNO_LEN;
+               ata_dev_id_string(args->id, (unsigned char *) rbuf + 4 + 4,
+                                 ATA_ID_SERNO_OFS, ATA_SERNO_LEN);

-- Patrick Mansfield

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#10 lore raw
Quoted 6 lines · [email protected] wrote:
Quoted 3 lines · Chris Paulson-Ellis
Quoted 3 lines

Why not just fix the kernel when it's filling in the page 83 data to pull the serial from page 80 instead of putting *that* there?

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Bill

Indeed. Here's the patch. Now I have 3 ways to fix this. Any more anyone?

This is the best approach, I think you could even remove page 0x83 support and still be SCSI compliant.

Pat,
Not since 2000/2001 ... The VPD device identification page (0x83) and the "Supported VPD pages" page (0x0) are mandatory in SPC-2 (ANSI INCITS 351-2001), SPC-3 (soon to be a standard) and SPC-4. Recent SCSI to ATA Translation drafts (e.g. sat-r07a.pdf) define a mapping for the naa-5 identifier defined in ATA/ATAPI-7 and ATA/ATAPI-8 (IDENTIFY DEVICE response words 108 to 111) to VPD page 0x83. There are also moves afoot to get a similar wwn identifier into the IDENTIFY PACKET DEVICE response.

SAT defines two device id descriptors for VPD page 0x83:
- based on WWN naa-5 (described above)
- based on model number and serial number (IDENTIFY

    DEVICE response words 27-46 and 10-19)

So removing VPD page 0x83 would be a retrograde step IMO. The libata implementation should be enhanced to support one or both of the above descriptors as they have a defined format (unlike serial number VPD page (0x80)). libata's current approach to yield "Linux ATA-SCSI simulator" for the loosely formatted ASCII identification descriptor is just a place holder.

libata should do a lot more work in the VPD 0x83 page area. For example when SATA disk is connected via SAS (behind an expander rather that directly connected) then a "device port" association descriptor should have the SAS address (also naa-5) of the SATA bridge (in the expander).

libata is not the only way that the SCSI subsystem will be seeing SATA disks. There are FC exclosures out there filled with SATA disks that have a SAT layer in the enclosure.

Doug Gilbert
cc-ed to linux-ide

#11 lore raw

PATCH 1/1 /dev/disk/by-id incomplete and unhelpful for SATA drives

Quoted 35 lines · Douglas Gilbert
Quoted 7 lines · [email protected] wrote:
Quoted 3 lines · Chris Paulson-Ellis
Quoted 3 lines

Why not just fix the kernel when it's filling in the page 83 data to pull the serial from page 80 instead of putting *that* there?

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Bill

Indeed. Here's the patch. Now I have 3 ways to fix this. Any more anyone?

This is the best approach, I think you could even remove page 0x83 support and still be SCSI compliant.

Pat,
Not since 2000/2001 ... The VPD device identification page (0x83) and the "Supported VPD pages" page (0x0) are mandatory in SPC-2 (ANSI INCITS 351-2001), SPC-3 (soon to be a standard) and SPC-4. Recent SCSI to ATA Translation drafts (e.g. sat-r07a.pdf) define a mapping for the naa-5 identifier defined in ATA/ATAPI-7 and ATA/ATAPI-8 (IDENTIFY DEVICE response words 108 to 111) to VPD page 0x83. There are also moves afoot to get a similar wwn identifier into the IDENTIFY PACKET DEVICE response.

SAT defines two device id descriptors for VPD page 0x83:
- based on WWN naa-5 (described above)
- based on model number and serial number (IDENTIFY

    DEVICE response words 27-46 and 10-19)
Quoted 7 lines

So removing VPD page 0x83 would be a retrograde step IMO. The libata implementation should be enhanced to support one or both of the above descriptors as they have a defined format (unlike serial number VPD page (0x80)). libata's current approach to yield "Linux ATA-SCSI simulator" for the loosely formatted ASCII identification descriptor is just a place holder.

The attachment adds the second item above to the patch suggested by Chris Paulson-Ellis <[email protected]> in:
http://marc.theaimsgroup.com/?l=linux-hotplug-devel&m=113529667019652&w=2

The patch is against lk 2.6.15 and was tested on a sil controller with a Seagate ST380013AS sata disk.

Changelog:
- make existing libata VPD device identification page (0x83) supply the ATA serial number in the libata "vendor specific" designator (from Chris Paulson-Ellis)
- add a "t10 vendor id based" designator as defined in SAT rev 07a (section 10.3.4.2.3) that supplies ATA model and serial numbers
- make the libata VPD page 0x83 more extensible (for adding more designators in the future).

Doug Gilbert

drivers/scsi/libata-scsi.c2615vpd renamed from drivers/scsi/libata-scsi.c +34 -11
@@ -1532,16 +1532,16 @@
 	return 0;
 }
 
-static const char *inq_83_str = "Linux ATA-SCSI simulator";
-
 /**
  *	ata_scsiop_inq_83 - Simulate INQUIRY EVPD page 83, device identity
  *	@args: device IDENTIFY data / SCSI command of interest.
  *	@rbuf: Response buffer, to which simulated SCSI cmd output is sent.
  *	@buflen: Response buffer length.
  *
- *	Returns device identification.  Currently hardcoded to
- *	return "Linux ATA-SCSI simulator".
+ *	Yields two logocal unit device identification designators:
+ *	  - vendor specific ASCII containing the ATA serial number
+ *	  - SAT defined "t10 vendor id based" containing ASCII vendor
+ *	    name ("ATA     "), model and serial numbers.
  *
  *	LOCKING:
  *	spin_lock_irqsave(host_set lock)
@@ -1550,16 +1550,39 @@
 unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf,
 			      unsigned int buflen)
 {
+	int num;
+	const int sat_model_serial_desc_len = 68;
+	const int ata_model_byte_len = 40;
+
 	rbuf[1] = 0x83;			/* this page code */
-	rbuf[3] = 4 + strlen(inq_83_str);	/* page len */
+	num = 4;
 
-	/* our one and only identification descriptor (vendor-specific) */
-	if (buflen > (strlen(inq_83_str) + 4 + 4 - 1)) {
-		rbuf[4 + 0] = 2;	/* code set: ASCII */
-		rbuf[4 + 3] = strlen(inq_83_str);
-		memcpy(rbuf + 4 + 4, inq_83_str, strlen(inq_83_str));
+	if (buflen > (ATA_SERNO_LEN + num + 3)) {
+		/* piv=0, assoc=lu, code_set=ACSII, designator=vendor */
+		rbuf[num + 0] = 2;	
+		rbuf[num + 3] = ATA_SERNO_LEN;
+		num += 4;
+		ata_dev_id_string(args->id, (unsigned char *) rbuf + num,
+				  ATA_ID_SERNO_OFS, ATA_SERNO_LEN);
+		num += ATA_SERNO_LEN;
 	}
-
+	if (buflen > (sat_model_serial_desc_len + num + 3)) {
+		/* SAT defined lu model and serial numbers descriptor */
+		/* piv=0, assoc=lu, code_set=ACSII, designator=t10 vendor id */
+		rbuf[num + 0] = 2;	
+		rbuf[num + 1] = 1;	
+		rbuf[num + 3] = sat_model_serial_desc_len;
+		num += 4;
+		strncpy(rbuf + num, "ATA     ", 8);
+		num += 8;
+		ata_dev_id_string(args->id, (unsigned char *) rbuf + num,
+				  ATA_ID_PROD_OFS, ata_model_byte_len);
+		num += ata_model_byte_len;
+		ata_dev_id_string(args->id, (unsigned char *) rbuf + num,
+				  ATA_ID_SERNO_OFS, ATA_SERNO_LEN);
+		num += ATA_SERNO_LEN;
+	}
+	rbuf[3] = num - 4;    /* page len (assume less than 256 bytes) */
 	return 0;
 }
 
#12 lore raw
Quoted 2 lines · Douglas Gilbert

Douglas Gilbert wrote:
[snip]

I can confirm that your patch works for me too.

Original scsi_id output:

# scsi_id -g -x -s /block/sda | grep ID_SERIAL
ID_SERIAL
TA_Maxtor_6Y160M0_Linux_ATA-SCSI_simulator

After my patch:

# scsi_id -g -x -s /block/sda | grep ID_SERIAL
ID_SERIAL
TA_Maxtor_6Y160M0_Y4DCTR3E

After your patch:

# scsi_id -g -x -s /block/sda | grep ID_SERIAL
ID_SERIALTA_Maxtor_6Y160M0_Y4DCTR3E

Note that it is still a bit different to the page 0x80 output, but I don't think this matters (unless that '0' or '1' is a bug not a feature). For my purposes, it just needs to be unique.

# ( scsi_id -p 0x80 -g -x -s /block/sda ; \
     scsi_id -p 0x83 -g -x -s /block/sda ) | grep ID_SERIAL

ID_SERIAL=SATA_Maxtor_6Y160M0_Y4DCTR3E
ID_SERIALTA_Maxtor_6Y160M0_Y4DCTR3E

Many thanks,
Chris.

Quoted 88 lines

The attachment adds the second item above to the patch suggested by Chris Paulson-Ellis <[email protected]> in:
http://marc.theaimsgroup.com/?l=linux-hotplug-devel&m3529667019652&w=2

The patch is against lk 2.6.15 and was tested on a sil controller with a Seagate ST380013AS sata disk.

Changelog:
- make existing libata VPD device identification page (0x83) supply the ATA serial number in the libata "vendor specific" designator (from Chris Paulson-Ellis)
- add a "t10 vendor id based" designator as defined in SAT rev 07a (section 10.3.4.2.3) that supplies ATA model and serial numbers
- make the libata VPD page 0x83 more extensible (for adding more designators in the future).

Doug Gilbert

------------------------------------------------------------------------

drivers/scsi/libata-scsi.c2615vpd renamed from drivers/scsi/libata-scsi.c +27 -11
@@ -1532,16 +1532,16 @@
 	return 0;
 }
 
-static const char *inq_83_str = "Linux ATA-SCSI simulator";
-
 /**
  *	ata_scsiop_inq_83 - Simulate INQUIRY EVPD page 83, device identity
  *	@args: device IDENTIFY data / SCSI command of interest.
  *	@rbuf: Response buffer, to which simulated SCSI cmd output is sent.
  *	@buflen: Response buffer length.
  *
- *	Returns device identification.  Currently hardcoded to
- *	return "Linux ATA-SCSI simulator".
+ *	Yields two logocal unit device identification designators:
+ *	  - vendor specific ASCII containing the ATA serial number
+ *	  - SAT defined "t10 vendor id based" containing ASCII vendor
+ *	    name ("ATA     "), model and serial numbers.
  *
  *	LOCKING:
  *	spin_lock_irqsave(host_set lock)
@@ -1550,16 +1550,39 @@
 unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf,
 			      unsigned int buflen)
 {
+	int num;
+	const int sat_model_serial_desc_len = 68;
+	const int ata_model_byte_len = 40;
+
 	rbuf[1] = 0x83;			/* this page code */
-	rbuf[3] = 4 + strlen(inq_83_str);	/* page len */
+	num = 4;
 
-	/* our one and only identification descriptor (vendor-specific) */
-	if (buflen > (strlen(inq_83_str) + 4 + 4 - 1)) {
-		rbuf[4 + 0] = 2;	/* code set: ASCII */
-		rbuf[4 + 3] = strlen(inq_83_str);
-		memcpy(rbuf + 4 + 4, inq_83_str, strlen(inq_83_str));
+	if (buflen > (ATA_SERNO_LEN + num + 3)) {
+		/* piv=0, assoc=lu, code_set¬SII, designator=vendor */
+		rbuf[num + 0] = 2;	
+		rbuf[num + 3] = ATA_SERNO_LEN;
+		num += 4;
+		ata_dev_id_string(args->id, (unsigned char *) rbuf + num,
+				  ATA_ID_SERNO_OFS, ATA_SERNO_LEN);
+		num += ATA_SERNO_LEN;
 	}
-
+	if (buflen > (sat_model_serial_desc_len + num + 3)) {
+		/* SAT defined lu model and serial numbers descriptor */
+		/* piv=0, assoc=lu, code_set¬SII, designator=t10 vendor id */
+		rbuf[num + 0] = 2;	
+		rbuf[num + 1] = 1;	
+		rbuf[num + 3] = sat_model_serial_desc_len;
+		num += 4;
+		strncpy(rbuf + num, "ATA     ", 8);
+		num += 8;
+		ata_dev_id_string(args->id, (unsigned char *) rbuf + num,

drivers/scsi/libata-scsi.c2615vpd line 1588

Quoted 10 lines
drivers/scsi/libata-scsi.c2615vpd renamed from drivers/scsi/libata-scsi.c +7 -0
+				  ATA_ID_PROD_OFS, ata_model_byte_len);
+		num += ata_model_byte_len;
+		ata_dev_id_string(args->id, (unsigned char *) rbuf + num,
+				  ATA_ID_SERNO_OFS, ATA_SERNO_LEN);
+		num += ATA_SERNO_LEN;
+	}
+	rbuf[3] = num - 4;    /* page len (assume less than 256 bytes) */
 	return 0;
 }
 

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#13 lore raw
Quoted 8 lines · Chris Paulson-Ellis

Note that it is still a bit different to the page 0x80 output, but I don't think this matters (unless that '0' or '1' is a bug not a feature). For my purposes, it just needs to be unique.

# ( scsi_id -p 0x80 -g -x -s /block/sda ; \
    scsi_id -p 0x83 -g -x -s /block/sda ) | grep ID_SERIAL

ID_SERIAL=SATA_Maxtor_6Y160M0_Y4DCTR3E
ID_SERIALTA_Maxtor_6Y160M0_Y4DCTR3E

Yes, the above is a feature. The SATA in the above is actually S + ATA, the 'S' is added to guarantee no overlap with page 83 names.

For page 80 the output is concatenation of 'S', vendor, model, and page 80 result,

For page 83 the output puts the id type as a prefix, so the name spaces for page 83 can't collide - they are mostly unique across a given id type, but not for vendor specific, hence we also add model + vendor for vendor specific.

And for '-x', extra spaces are removed and then spaces converted to '_'.

-- Patrick Mansfield

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#14 lore raw
In reply to Douglas Gilbert
Quoted 44 lines · Douglas Gilbert

Changelog:
- make existing libata VPD device identification page (0x83) supply the ATA serial number in the libata "vendor specific" designator (from Chris Paulson-Ellis)
- add a "t10 vendor id based" designator as defined in SAT rev 07a (section 10.3.4.2.3) that supplies ATA model and serial numbers

drivers/scsi/libata-scsi.c2615vpd renamed from drivers/scsi/libata-scsi.c +20 -7
 
 unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf,
 			      unsigned int buflen)
 {
+	int num;
+	const int sat_model_serial_desc_len = 68;
+	const int ata_model_byte_len = 40;
+
 	rbuf[1] = 0x83;			/* this page code */
-	rbuf[3] = 4 + strlen(inq_83_str);	/* page len */
+	num = 4;
 
-	/* our one and only identification descriptor (vendor-specific) */
-	if (buflen > (strlen(inq_83_str) + 4 + 4 - 1)) {
-		rbuf[4 + 0] = 2;	/* code set: ASCII */
-		rbuf[4 + 3] = strlen(inq_83_str);
-		memcpy(rbuf + 4 + 4, inq_83_str, strlen(inq_83_str));
+	if (buflen > (ATA_SERNO_LEN + num + 3)) {
+		/* piv=0, assoc=lu, code_set¬SII, designator=vendor */
+		rbuf[num + 0] = 2;	
+		rbuf[num + 3] = ATA_SERNO_LEN;
+		num += 4;
+		ata_dev_id_string(args->id, (unsigned char *) rbuf + num,
+				  ATA_ID_SERNO_OFS, ATA_SERNO_LEN);
+		num += ATA_SERNO_LEN;
 	}
-
+	if (buflen > (sat_model_serial_desc_len + num + 3)) {
+		/* SAT defined lu model and serial numbers descriptor */
+		/* piv=0, assoc=lu, code_set¬SII, designator=t10 vendor id */
+		rbuf[num + 0] = 2;	
+		rbuf[num + 1] = 1;	
+		rbuf[num + 3] = sat_model_serial_desc_len;
+		num += 4;

drivers/scsi/libata-scsi.c2615vpd line 1585

Quoted 10 lines
drivers/scsi/libata-scsi.c2615vpd renamed from drivers/scsi/libata-scsi.c +10 -0
+		strncpy(rbuf + num, "ATA     ", 8);
+		num += 8;
+		ata_dev_id_string(args->id, (unsigned char *) rbuf + num,
+				  ATA_ID_PROD_OFS, ata_model_byte_len);
+		num += ata_model_byte_len;
+		ata_dev_id_string(args->id, (unsigned char *) rbuf + num,
+				  ATA_ID_SERNO_OFS, ATA_SERNO_LEN);
+		num += ATA_SERNO_LEN;
+	}
+	rbuf[3] = num - 4;    /* page len (assume less than 256 bytes) */

I was trying to figure out if we are guranteed will have unique values across all ATA devices with Doug's patch. I am not familiar with ATA and IDENTIFY DEVICE.

For page 0x83, Doug's change above gives us:

ATA + 40 bytes of model/product (must have white space) + serial number

Under "10.3.4.2.3 Logical unit name derived from the model number and serial number" the spec says:

NOTE 9 The logical unit name using the T10 vendor identification format is not guaranteed to be worldwide unique, since ATA/ATAPI-7 only requires the combination of the MODEL NUMBER field and SERIAL NUMBER field to be unique for a given manufacturer but defines no manufacturer identification field.

I don't know why they have this given the above. So it is possible (though unlikely?) that model numbers will overlap, and so scsi_id values too?

If we put had an actual vendor in the sdev->vendor, we could use page 0x83 type 0 with no name collisions (if that vendor + model actually gives us unique serial numbers).

Why does the SAT translation spec have the vendor identification of ATA???

The "logical unit name derived from the world wide name" looks nicer, but I assume not all vendors support that.

-- Patrick Mansfield

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#15 lore raw
Quoted 2 lines · Patrick Mansfield

On Fri, Jan 06, 2006 at 10:39:34PM +1000, Douglas Gilbert wrote:

<snip>

Quoted 4 lines

I was trying to figure out if we are guranteed will have unique values across all ATA devices with Doug's patch. I am not familiar with ATA and IDENTIFY DEVICE.

http://www.t13.org/docs2005/D1699r2a-ATA8-ACS.pdf
is the most recent draft of the ATA-8 command set.

Quoted 7 lines

For page 0x83, Doug's change above gives us:

ATA + 40 bytes of model/product (must have white space) + serial number

Under "10.3.4.2.3 Logical unit name derived from the model number and serial number" the spec says:

Quoted 8 lines

NOTE 9 The logical unit name using the T10 vendor identification format is not guaranteed to be worldwide unique, since ATA/ATAPI-7 only requires the combination of the MODEL NUMBER field and SERIAL NUMBER field to be unique for a given manufacturer but defines no manufacturer identification field.

I don't know why they have this given the above. So it is possible (though unlikely?) that model numbers will overlap, and so scsi_id values too?

Unlikely but two vendors could use the same model and serial numbers.

Quoted 5 lines

If we put had an actual vendor in the sdev->vendor, we could use page 0x83 type 0 with no name collisions (if that vendor + model actually gives us unique serial numbers).

Why does the SAT translation spec have the vendor identification of ATA???

I guess because there is no requirement for a manufacturer of (s)ATA disks to have a registered t10 vendor id ... IEEE wants money for OUI registrations, t10 probably wants money for a t10 vendor id, t13 probably wants money etc ... BTW As I have mentioned in the past, linux probably should have a OUI registration (paid by whom??).

Quoted 2 lines

The "logical unit name derived from the world wide name" looks nicer, but I assume not all vendors support that.

Yes and not yet, until it becomes mandatory, if ever. ATA8-ACS shows a naa-5 (8 byte, 4 word) identifier
starting at word 108 in the IDENTIFY DEVICE response. I like the ACS wording: "Words 111-108 shall contain the optional value of the world wide name"! The "shall" implies it is mandatory but obviously the "optional" doesn't. Perhaps it was written by a lawyer :-)

We probably could and should add the naa-5 designator in VPD page 0x83, perhaps dependent on whether there is a 0x5 in word 108 bits 15-12 . For example, an old-ish Seagate ST380013AS sata disks has zero in those 8 bytes.

Perhaps others could check their sata disks and report back if any have a real naa-5 wwn starting at word 108. ["sg_inq -AH" on a (s/p)ATA disk will dump the IDENTIFY DEVICE response in hex.]

Doug Gilbert

#16 lore raw
In reply to Douglas Gilbert
Quoted 72 lines · Douglas Gilbert

Changelog:
- make existing libata VPD device identification page (0x83) supply the ATA serial number in the libata "vendor specific" designator (from Chris Paulson-Ellis)
- add a "t10 vendor id based" designator as defined in SAT rev 07a (section 10.3.4.2.3) that supplies ATA model and serial numbers
- make the libata VPD page 0x83 more extensible (for adding more designators in the future).

------------------------------------------------------------------------

drivers/scsi/libata-scsi.c2615vpd renamed from drivers/scsi/libata-scsi.c +25 -11
@@ -1532,16 +1532,16 @@
 	return 0;
 }
 
-static const char *inq_83_str = "Linux ATA-SCSI simulator";
-
 /**
  *	ata_scsiop_inq_83 - Simulate INQUIRY EVPD page 83, device identity
  *	@args: device IDENTIFY data / SCSI command of interest.
  *	@rbuf: Response buffer, to which simulated SCSI cmd output is sent.
  *	@buflen: Response buffer length.
  *
- *	Returns device identification.  Currently hardcoded to
- *	return "Linux ATA-SCSI simulator".
+ *	Yields two logocal unit device identification designators:
+ *	  - vendor specific ASCII containing the ATA serial number
+ *	  - SAT defined "t10 vendor id based" containing ASCII vendor
+ *	    name ("ATA     "), model and serial numbers.
  *
  *	LOCKING:
  *	spin_lock_irqsave(host_set lock)
@@ -1550,16 +1550,39 @@
 unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf,
 			      unsigned int buflen)
 {
+	int num;
+	const int sat_model_serial_desc_len = 68;
+	const int ata_model_byte_len = 40;
+
 	rbuf[1] = 0x83;			/* this page code */
-	rbuf[3] = 4 + strlen(inq_83_str);	/* page len */
+	num = 4;
 
-	/* our one and only identification descriptor (vendor-specific) */
-	if (buflen > (strlen(inq_83_str) + 4 + 4 - 1)) {
-		rbuf[4 + 0] = 2;	/* code set: ASCII */
-		rbuf[4 + 3] = strlen(inq_83_str);
-		memcpy(rbuf + 4 + 4, inq_83_str, strlen(inq_83_str));
+	if (buflen > (ATA_SERNO_LEN + num + 3)) {
+		/* piv=0, assoc=lu, code_set¬SII, designator=vendor */
+		rbuf[num + 0] = 2;	
+		rbuf[num + 3] = ATA_SERNO_LEN;
+		num += 4;
+		ata_dev_id_string(args->id, (unsigned char *) rbuf + num,
+				  ATA_ID_SERNO_OFS, ATA_SERNO_LEN);
+		num += ATA_SERNO_LEN;
 	}
-
+	if (buflen > (sat_model_serial_desc_len + num + 3)) {
+		/* SAT defined lu model and serial numbers descriptor */
+		/* piv=0, assoc=lu, code_set¬SII, designator=t10 vendor id */
+		rbuf[num + 0] = 2;	
+		rbuf[num + 1] = 1;	
+		rbuf[num + 3] = sat_model_serial_desc_len;
+		num += 4;
+		strncpy(rbuf + num, "ATA     ", 8);

drivers/scsi/libata-scsi.c2615vpd line 1586

Quoted 10 lines
drivers/scsi/libata-scsi.c2615vpd renamed from drivers/scsi/libata-scsi.c +9 -0
+		num += 8;
+		ata_dev_id_string(args->id, (unsigned char *) rbuf + num,
+				  ATA_ID_PROD_OFS, ata_model_byte_len);
+		num += ata_model_byte_len;
+		ata_dev_id_string(args->id, (unsigned char *) rbuf + num,
+				  ATA_ID_SERNO_OFS, ATA_SERNO_LEN);
+		num += ATA_SERNO_LEN;
+	}
+	rbuf[3] = num - 4;    /* page len (assume less than 256 bytes) */
 	return 0;

This removes the identifier that has existed since libata was created, which could break something.

At the very least, update the existing code to indicate assoc=port, and then append the other descriptor data you wish to add after that.

Jeff

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#17 lore raw
Quoted 85 lines · Jeff Garzik
Quoted 83 lines · Douglas Gilbert

Changelog:
- make existing libata VPD device identification page (0x83) supply the ATA serial number in the libata "vendor specific" designator (from Chris Paulson-Ellis)
- add a "t10 vendor id based" designator as defined in SAT rev 07a (section 10.3.4.2.3) that supplies ATA model and serial numbers
- make the libata VPD page 0x83 more extensible (for adding more designators in the future).

------------------------------------------------------------------------

--- linux/drivers/scsi/libata-scsi.c 2006-01-04 08:50:42.000000000
+1000
+++ linux/drivers/scsi/libata-scsi.c2615vpd 2006-01-06
20:16:25.000000000 +1000

drivers/scsi/libata-scsi.c2615vpd renamed from drivers/scsi/libata-scsi.c +0 -2
@@ -1532,16 +1532,16 @@
     return 0;
 }
 
-static const char *inq_83_str = "Linux ATA-SCSI simulator";
-
 /**
  *    ata_scsiop_inq_83 - Simulate INQUIRY EVPD page 83, device identity
  *    @args: device IDENTIFY data / SCSI command of interest.
  *    @rbuf: Response buffer, to which simulated SCSI cmd output is

sent.
* @buflen: Response buffer length.
*

- *    Returns device identification.  Currently hardcoded to
- *    return "Linux ATA-SCSI simulator".
+ *    Yields two logocal unit device identification designators:

+ * - vendor specific ASCII containing the ATA serial number
+ * - SAT defined "t10 vendor id based" containing ASCII vendor
+ * name ("ATA "), model and serial numbers.
*
* LOCKING:
* spin_lock_irqsave(host_set lock)

drivers/scsi/libata-scsi.c2615vpd renamed from drivers/scsi/libata-scsi.c +28 -7
@@ -1550,16 +1550,39 @@
 unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf,
                   unsigned int buflen)
 {
+    int num;
+    const int sat_model_serial_desc_len = 68;
+    const int ata_model_byte_len = 40;
+
     rbuf[1] = 0x83;            /* this page code */
-    rbuf[3] = 4 + strlen(inq_83_str);    /* page len */
+    num = 4;
 
-    /* our one and only identification descriptor (vendor-specific) */
-    if (buflen > (strlen(inq_83_str) + 4 + 4 - 1)) {
-        rbuf[4 + 0] = 2;    /* code set: ASCII */
-        rbuf[4 + 3] = strlen(inq_83_str);
-        memcpy(rbuf + 4 + 4, inq_83_str, strlen(inq_83_str));
+    if (buflen > (ATA_SERNO_LEN + num + 3)) {
+        /* piv=0, assoc=lu, code_set�SII, designator=vendor */
+        rbuf[num + 0] = 2;   
+        rbuf[num + 3] = ATA_SERNO_LEN;
+        num += 4;
+        ata_dev_id_string(args->id, (unsigned char *) rbuf + num,
+                  ATA_ID_SERNO_OFS, ATA_SERNO_LEN);
+        num += ATA_SERNO_LEN;
     }
-
+    if (buflen > (sat_model_serial_desc_len + num + 3)) {
+        /* SAT defined lu model and serial numbers descriptor */
+        /* piv=0, assoc=lu, code_set�SII, designator=t10 vendor id */
+        rbuf[num + 0] = 2;   
+        rbuf[num + 1] = 1;   
+        rbuf[num + 3] = sat_model_serial_desc_len;
+        num += 4;
+        strncpy(rbuf + num, "ATA     ", 8);
+        num += 8;
+        ata_dev_id_string(args->id, (unsigned char *) rbuf + num,
+                  ATA_ID_PROD_OFS, ata_model_byte_len);
+        num += ata_model_byte_len;
+        ata_dev_id_string(args->id, (unsigned char *) rbuf + num,
+                  ATA_ID_SERNO_OFS, ATA_SERNO_LEN);
+        num += ATA_SERNO_LEN;
Quoted 8 lines

drivers/scsi/libata-scsi.c2615vpd line 1586

Quoted 3 lines
drivers/scsi/libata-scsi.c2615vpd renamed from drivers/scsi/libata-scsi.c +2 -0
+    }
+    rbuf[3] = num - 4;    /* page len (assume less than 256 bytes) */
     return 0;

This removes the identifier that has existed since libata was created, which could break something.

Jeff,
That patch was sent on 6th January 2006. That is a long time to respond.

The existing "Linux ATA-SCSI simulator" has assoc=lu and designator_type=vendor. That claims to be the device identifier for the SATA disk (i.e. the logical unit) in vendor format. That is just plain wrong. Chris Paulson-Ellis was correct to replace it with identification information related to the SATA disk. I then went a step further and added the SAT defined way of doing a similar thing. In the future when SATA disks start supporting a naa-5 world wide unique identifier (word 108 to 111 in a IDENTIFY DEVICE response) then a third designator can be added (assoc=lu designator_type=naa).

Quoted 2 lines

At the very least, update the existing code to indicate assoc=port, and then append the other descriptor data you wish to add after that.

So change it (i.e. assoc=lu -> assoc=port) and keep the "Linux ATA-SCSI simulator" string for (partial) backward compatibility. Hmmmm.

A SAT layer identifiers itself generically with "ATA "
in the vendor string. It could also use a version descriptor in the standard INQUIRY response to identify which level of SAT it supported. As for identifying that this was the linux libata implementation of SAT, I'm not sure where that should go. VPD page 0x83 for device identification doesn't seem appropriate. If a linux box was being used as a FC to SATA bridge then the bridge should be putting FC related stuff in assoc=port and assoc�vice while keeping what libata put in assoc=lu.

Doug Gilbert

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel