Page MenuHomeFreeBSD

Strip leading spaces off of a SCSI disk's serial number
ClosedPublic

Authored by asomers on May 24 2016, 12:23 AM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 5 2024, 4:21 PM
Unknown Object (File)
Jan 5 2024, 4:21 PM
Unknown Object (File)
Dec 29 2023, 1:32 PM
Unknown Object (File)
Dec 19 2023, 11:51 PM
Unknown Object (File)
Dec 15 2023, 2:16 PM
Unknown Object (File)
Dec 15 2023, 1:07 PM
Unknown Object (File)
Jul 11 2023, 4:19 AM
Unknown Object (File)
Jun 20 2023, 10:40 PM
Subscribers

Details

Summary

sys/cam/scsi/scsi_xpt.c
Strip leading spaces off of a SCSI disk's reported serial number
when populating the CAM serial number. This affects the output of
"diskinfo -v" and the names of /dev/diskid/DISK-* device nodes,
among other things.

SPC5r05 says that the Product Serial Number field from the Unit
Serial Number VPD page is right-aligned. So any leading spaces are
not part of the actual serial number. Most devices don't left-pad
their serial numbers, but some do. In particular, the SN VPD page
that an LSI HBA emulates for a SATA drive contains enough
left-padding to fill a 20-byte field.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

asomers retitled this revision from to Strip leading spaces off of a SCSI disk's serial number.
asomers updated this object.
asomers edited the test plan for this revision. (Show Details)
asomers added reviewers: ken, mav.
ken edited edge metadata.

In general I like the idea. If we're going to do it, a major release is the time to do it.

This revision is now accepted and ready to land.May 26 2016, 2:13 AM

I am aware about this problem, but I don't know what is right here.

One more point where serial numbers are used is Intel metadata module of GEOM_RAID -- it uses last 16 bytes of serial number to find specific disk's position in global metadata. Trimming may not be a problem if serial number is bigger then 16 bytes, while otherwise RAID array may go south.

On the other side, I know that smartctl tool does trimming when displaying serial numbers.

In D6516#138836, @mav wrote:

I am aware about this problem, but I don't know what is right here.

One more point where serial numbers are used is Intel metadata module of GEOM_RAID -- it uses last 16 bytes of serial number to find specific disk's position in global metadata. Trimming may not be a problem if serial number is bigger then 16 bytes, while otherwise RAID array may go south.

On the other side, I know that smartctl tool does trimming when displaying serial numbers.

graid only works with ATA disks, whereas this change is for SCSI disks only. So there's nothing to worry about on that front.

In D6516#138836, @mav wrote:

I am aware about this problem, but I don't know what is right here.

One more point where serial numbers are used is Intel metadata module of GEOM_RAID -- it uses last 16 bytes of serial number to find specific disk's position in global metadata. Trimming may not be a problem if serial number is bigger then 16 bytes, while otherwise RAID array may go south.

On the other side, I know that smartctl tool does trimming when displaying serial numbers.

graid only works with ATA disks, whereas this change is for SCSI disks only. So there's nothing to worry about on that front.

I've never tried that, but I think Intel MatrixRAID worked for on-board SAS ports too. At least until Intel decided to leave that market.

I've never tried that, but I think Intel MatrixRAID worked for on-board SAS ports too. At least until Intel decided to leave that market.

The only time I've ever seen leading spaces on a SCSI device's serial number is when a SATA disk is connected to an LSI SAS HBA, which emulates a SCSI disk for it. Does Intel do the same thing? If you stick a SATA disk with fewer than 20 characters in its serial number into an Intel on-board SAS port, how does the Device Identification VPD page look? If it doesn't have leading spaces, then we have nothing to worry about.

If it does, then we need to figure out what the damage will be. If that metadata is used only the the BIOS, then we have nothing to worry about, because my change is only visible in the OS. If that metadata is used by the OS for finding the raid's members, and the graid code uses the serial number as reported by CAM, then we have a potential problem. But, it's a problem that we can probably solve by ignoring leading spaces when matching the serial numbers in the graid code. Can you please point me to the code that uses this metadata?

This revision was automatically updated to reflect the committed changes.