[prev in list] [next in list] [prev in thread] [next in thread] 

List:       systemd-devel
Subject:    Re: [systemd-devel] LibUdev: serial not displayed properly for scsi devices
From:       Martin Wilck <mwilck () suse ! de>
Date:       2019-02-07 21:08:18
Message-ID: cdc83359c29d6b45a416b24f45e4c700ac6739f8.camel () suse ! de
[Download RAW message or body]

On Thu, 2019-02-07 at 14:39 +0000, Sven Wiltink wrote:
> Hey all,
> 
> We've been running into the issue where lblk -O outputs the wwn
> instead of the serial for scsi devices. After some debugging I've
> come to the conclusing that /lib/udev/scsi_id is the underlying
> cause. It outputs the wwn of a disk in the ID_SERIAL_SHORT field, but
> does also export the actual serial in a separate field
> (ID_SCSI_SERIAL).

This is not a bug.

Check the code in scsi_serial.c to see that this is is done on purpose.
ID_SERIAL does *not* represent the hardware serial number, it is rather
something like "the best unique identifier for the device at hand".
This is typically an NAA identifier from the VPD page 0x83 ("device
identification"). VPD 0x83 may contain multiple identifiers, out of
which the code uses the "best" one according to a hard-coded internal
priority list (id_search_list in scsi_serial.c). ID_SERIAL_SHORT just
strips the first byte (NAA type) off ID_SERIAL.

You can override this behavior by using the parameter "-p 0x80" for
scsi_id, which forces scsi_id to use VPD page 0x80 ("serial number").

Don't be confused by the name ID_SERIAL, which is just historic AFAICT.
The variable name ID_SERIAL was introduced in 2005, in udev 59 (!).

https://git.kernel.org/pub/scm/linux/hotplug/udev.git/commit/?id=34129109a1f5dca72af2f3f2d3d14a9a0d0c43f6

The name might have been chosen after the variable name "serial" that
the code printed, but even at that time, the algorithm described above
was already followed.


> 
> I am unsure if the fix should be in udev or lsblk, but I wanted to
> bring it up for discussion because the serial not being displayed
> properly.

Yes, lsblk should be fixed (if anything). We can't change udev in this
regard. Too much code depends on the given semantics of ID_SERIAL.

Regards,
Martin


_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic