systemd/rules.d
Lidong Zhong 9b3278d907 udev: rename the persistent link for ATA devices
ATA devices should use the ATA ids like port number and (possibly)
master/slave or multiplier id, not the generic SCSI ID.
Currently only port number is included in the link. With this patch
the link would be able to support more cases, which are a) when the
device is behind a port multiplexer b) the distinction between master
and slave (distinguished by target id).

I tried to verify scenario a) with this patch, but I failed to find a
machine with PMP SATA devices attached. But the link below
https://github.com/systemd/systemd/issues/3943
could show what's the difference. Here is my test for scenario b)

Current version:
linux-ql21:~ # ll /sys/class/block/sd[ab]
lrwxrwxrwx 1 root root 0 May  8 20:46 /sys/class/block/sda ->
../../devices/pci0000:00/0000:00:01.1/ata4/host3/target3:0:0/3:0:0:0/block/sda
lrwxrwxrwx 1 root root 0 May  8 20:46 /sys/class/block/sdb ->
../../devices/pci0000:00/0000:00:01.1/ata4/host3/target3:0:1/3:0:1:0/block/sdb
linux-ql21:~ # ll /dev/disk/by-path/pci-0000\:00\:01.1-ata-1
lrwxrwxrwx 1 root root 9 May  8 20:44
/dev/disk/by-path/pci-0000:00:01.1-ata-1 -> ../../sdb
linux-ql21:~ # udevadm info /sys/class/block/sda |grep by-path
S: disk/by-path/pci-0000:00:01.1-ata-1
E: DEVLINKS=/dev/disk/by-id/ata-VBOX_HARDDISK_VB3649e885-3e0cdd64
/dev/disk/by-id/scsi-0ATA_VBOX_HARDDISK_VB3649e885-3e0cdd64
/dev/disk/by-id/scsi-1ATA_VBOX_HARDDISK_VB3649e885-3e0cdd64
/dev/disk/by-path/pci-0000:00:01.1-ata-1
/dev/disk/by-id/scsi-SATA_VBOX_HARDDISK_VB3649e885-3e0cdd64
linux-ql21:~ # udevadm info /sys/class/block/sdb |grep by-path
S: disk/by-path/pci-0000:00:01.1-ata-1
E: DEVLINKS=/dev/disk/by-id/ata-VBOX_HARDDISK_VBc53b2498-d84ae8de
/dev/disk/by-id/scsi-SATA_VBOX_HARDDISK_VBc53b2498-d84ae8de
/dev/disk/by-id/scsi-1ATA_VBOX_HARDDISK_VBc53b2498-d84ae8de
/dev/disk/by-id/scsi-0ATA_VBOX_HARDDISK_VBc53b2498-d84ae8de
/dev/disk/by-path/pci-0000:00:01.1-ata-1

After patch applied:
linux-ql21:~ # ll /sys/class/block/sd[ab]
lrwxrwxrwx 1 root root 0 May  8 21:07 /sys/class/block/sda ->
../../devices/pci0000:00/0000:00:01.1/ata4/host3/target3:0:0/3:0:0:0/block/sda
lrwxrwxrwx 1 root root 0 May  8 21:07 /sys/class/block/sdb ->
../../devices/pci0000:00/0000:00:01.1/ata4/host3/target3:0:1/3:0:1:0/block/sdb
linux-ql21:~ # ll /dev/disk/by-path/pci-0000\:00\:01.1-ata-*
lrwxrwxrwx 1 root root  9 May  8 21:07
/dev/disk/by-path/pci-0000:00:01.1-ata-1.0 -> ../../sda
lrwxrwxrwx 1 root root  9 May  8 21:07
/dev/disk/by-path/pci-0000:00:01.1-ata-1.1 -> ../../sdb
linux-ql21:~ # udevadm info /sys/class/block/sda |grep by-path
S: disk/by-path/pci-0000:00:01.1-ata-1.0
E: DEVLINKS=/dev/disk/by-id/scsi-1ATA_VBOX_HARDDISK_VB3649e885-3e0cdd64
/dev/disk/by-id/scsi-0ATA_VBOX_HARDDISK_VB3649e885-3e0cdd64
/dev/disk/by-id/ata-VBOX_HARDDISK_VB3649e885-3e0cdd64
/dev/disk/by-path/pci-0000:00:01.1-ata-1.0
/dev/disk/by-id/scsi-SATA_VBOX_HARDDISK_VB3649e885-3e0cdd64
linux-ql21:~ # udevadm info /sys/class/block/sdb |grep by-path
S: disk/by-path/pci-0000:00:01.1-ata-1.1
E: DEVLINKS=/dev/disk/by-id/scsi-0ATA_VBOX_HARDDISK_VBc53b2498-d84ae8de
/dev/disk/by-id/ata-VBOX_HARDDISK_VBc53b2498-d84ae8de
/dev/disk/by-id/scsi-1ATA_VBOX_HARDDISK_VBc53b2498-d84ae8de
/dev/disk/by-id/scsi-SATA_VBOX_HARDDISK_VBc53b2498-d84ae8de
/dev/disk/by-path/pci-0000:00:01.1-ata-1.1

Changelog:
v5: add another parameter compat_link in handle_scsi()
v4: comment for ID_PATH_ATA_COMPAT
    get string length with pointer difference
    (suggested by Franck Bui<fbui@suse.com>)
v3: creating compatible link from env
    variables type change
v2: remove udev rules modification for compatible link
    setup a test scenario of master/slave ATA devices
v1: initial patch
2020-05-21 09:58:06 +02:00
..
50-udev-default.rules.in Rename udev's rules/ to rules.d/ 2019-10-10 00:53:09 +01:00
60-block.rules Rename udev's rules/ to rules.d/ 2019-10-10 00:53:09 +01:00
60-cdrom_id.rules Rename udev's rules/ to rules.d/ 2019-10-10 00:53:09 +01:00
60-drm.rules Rename udev's rules/ to rules.d/ 2019-10-10 00:53:09 +01:00
60-evdev.rules rules.d: import the keyboard builtin instead of running it 2020-03-01 14:04:30 +01:00
60-fido-id.rules udev: mark all ccid/security devices with a special tag 2019-12-09 19:25:25 +01:00
60-input-id.rules Rename udev's rules/ to rules.d/ 2019-10-10 00:53:09 +01:00
60-persistent-alsa.rules Rename udev's rules/ to rules.d/ 2019-10-10 00:53:09 +01:00
60-persistent-input.rules Rename udev's rules/ to rules.d/ 2019-10-10 00:53:09 +01:00
60-persistent-storage-tape.rules Rename udev's rules/ to rules.d/ 2019-10-10 00:53:09 +01:00
60-persistent-storage.rules udev: rename the persistent link for ATA devices 2020-05-21 09:58:06 +02:00
60-persistent-v4l.rules Rename udev's rules/ to rules.d/ 2019-10-10 00:53:09 +01:00
60-sensor.rules Rename udev's rules/ to rules.d/ 2019-10-10 00:53:09 +01:00
60-serial.rules Rename udev's rules/ to rules.d/ 2019-10-10 00:53:09 +01:00
61-autosuspend-manual.rules Rename udev's rules/ to rules.d/ 2019-10-10 00:53:09 +01:00
64-btrfs.rules.in Rename udev's rules/ to rules.d/ 2019-10-10 00:53:09 +01:00
70-joystick.rules Rename udev's rules/ to rules.d/ 2019-10-10 00:53:09 +01:00
70-mouse.rules Rename udev's rules/ to rules.d/ 2019-10-10 00:53:09 +01:00
70-touchpad.rules Rename udev's rules/ to rules.d/ 2019-10-10 00:53:09 +01:00
75-net-description.rules Rename udev's rules/ to rules.d/ 2019-10-10 00:53:09 +01:00
75-probe_mtd.rules Rename udev's rules/ to rules.d/ 2019-10-10 00:53:09 +01:00
78-sound-card.rules Rename udev's rules/ to rules.d/ 2019-10-10 00:53:09 +01:00
80-drivers.rules Rename udev's rules/ to rules.d/ 2019-10-10 00:53:09 +01:00
80-net-setup-link.rules Rename udev's rules/ to rules.d/ 2019-10-10 00:53:09 +01:00
99-systemd.rules.in rules: automatically pull in smartcard.target from all CCID devices 2020-05-21 09:23:06 +02:00
meson.build Rename udev's rules/ to rules.d/ 2019-10-10 00:53:09 +01:00