Page MenuHomeFreeBSD

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

Authored by asomers on May 24 2016, 12:23 AM.

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
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

asomers updated this revision to Diff 16757.May 24 2016, 12:23 AM
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.
asomers updated this object.May 24 2016, 4:48 PM
asomers updated this revision to Diff 16804.May 24 2016, 4:48 PM

added a note in UPDATING

ken accepted this revision.May 26 2016, 2:13 AM
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
mav edited edge metadata.May 26 2016, 6:16 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.

mav added a comment.May 26 2016, 2:41 PM
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.