[udev] /dev/disk/by-path link for scsi disks always has host "0", causing conflicts

Bug #1321816 reported by Phillip Susi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
systemd (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

The /dev/disk/by-path links to scsi disks are supposed to be of the form "scsi-$host:$bus:$device$lun". The host portion is always zero, leading to duplicates from different hosts. It appears these numbers are pulled from ID_PATH, and I can't figure out where this variable comes from.

I noticed this while playing around with the lio fake scsi target adapter. Here is the full udev info on a disk created on such an adapter. As you can see, it has been assigned scsi host id 13, so that is what it should be using for the $host digit, rather than zero.

P: /devices/tcm_loop_0/tcm_loop_adapter_5/host13/target13:0:1/13:0:1:0/block/sdg
N: sdg
S: disk/by-path/scsi-0:0:1:0
E: DEVLINKS=/dev/disk/by-path/scsi-0:0:1:0
E: DEVNAME=/dev/sdg
E: DEVPATH=/devices/tcm_loop_0/tcm_loop_adapter_5/host13/target13:0:1/13:0:1:0/block/sdg
E: DEVTYPE=disk
E: ID_BUS=scsi
E: ID_MODEL=FILEIO
E: ID_MODEL_ENC=FILEIO\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
E: ID_PART_TABLE_TYPE=dos
E: ID_PATH=scsi-0:0:1:0
E: ID_PATH_TAG=scsi-0_0_1_0
E: ID_REVISION=4.0
E: ID_SCSI=1
E: ID_TYPE=disk
E: ID_VENDOR=LIO-ORG
E: ID_VENDOR_ENC=LIO-ORG\x20
E: MAJOR=8
E: MINOR=96
E: SUBSYSTEM=block
E: USEC_INITIALIZED=400656927711
E: nomdmonddf=1
E: nomdmonisw=1

Revision history for this message
Martin Pitt (pitti) wrote :

> It appears these numbers are pulled from ID_PATH, and I can't figure out where this variable comes from.

From what used to be /lib/udev/path_id, which is now built into libudev-private for performance reasons. You can do that part manually with:

sudo udevadm test-builtin path_id /sys/block/sr0

summary: - udev uses wrong/conflicting /dev/disk/by-path link for scsi disks
+ /dev/disk/by-path link for scsi disks always has host "0", causing
+ conflicts
Revision history for this message
Martin Pitt (pitti) wrote : Re: /dev/disk/by-path link for scsi disks always has host "0", causing conflicts

Reproducible with scsi_debug:

sudo modprobe scsi_debug removable=1 ptype=5

Gives:
P: /devices/pseudo_0/adapter0/host10/target10:0:0/10:0:0:0/block/sr0
N: sr0
E: DEVLINKS=/dev/cdrom /dev/disk/by-id/scsi-353333330000055f0 /dev/disk/by-id/wwn-0x53333330000055f0 /dev/disk/by-path/scsi-0:0:0:0
E: DEVNAME=/dev/sr0
E: DEVPATH=/devices/pseudo_0/adapter0/host10/target10:0:0/10:0:0:0/block/sr0

Changed in systemd (Ubuntu):
status: New → Triaged
Revision history for this message
Martin Pitt (pitti) wrote :

Debugging notes:

       name = udev_device_get_sysname(parent);
        if (sscanf(name, "%d:%d:%d:%d", &host, &bus, &target, &lun) != 4)
                return NULL;

This works fine, host is "10" in the scsi_debug case above.

But then the code below which does "Rebase host offset to get the local relative number" turns host into a "0" as 10 is the smallest host number on that device. This code is a bit dubious to me, I'll ask Kay.

summary: - /dev/disk/by-path link for scsi disks always has host "0", causing
- conflicts
+ [udev] /dev/disk/by-path link for scsi disks always has host "0",
+ causing conflicts
Revision history for this message
Martin Pitt (pitti) wrote :

Discussed with Kay on IRC:

kay | pitti: the host number is a simple kernel *enumeration* which depends on discovery order, it can never be used to compose *predictable* identifier
kay | pitti: that ID_PATH=scsi-0:0:1:0 should never happen

The summary is that path_id should fail instead of computing a non-unique ID_PATH for generic SCSI devices. IOW, the whole handle_scsi_default() should go away.

Revision history for this message
Martin Pitt (pitti) wrote :
Changed in systemd (Ubuntu):
status: Triaged → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package systemd - 208-8ubuntu2

---------------
systemd (208-8ubuntu2) utopic; urgency=medium

  [ Ben Howard ]
  * 75-persistent-net-generator.rules: Fix matches of HyperV. (LP: #1361272)

  [ Martin Pitt ]
  * Add new autopkgtest boot_and_services which reboots the testbed with
    systemd as init and verifies that the most critical services like lightdm,
    D-BUS, NetworkManager, and cron work. (To be extended in the future)
  * Fix udev path in udev(7). (LP: #1357782)
  * path_id: suppress ID_PATH for devices with an unknown parent device type.
    (LP: #1321816)
  * udev-builtin-keyboard: Allow numeric key codes. (LP: #1247584)
 -- Martin Pitt <email address hidden> Mon, 08 Sep 2014 14:44:35 +0200

Changed in systemd (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.