Skip to content

Conversation

@mfoliveira
Copy link
Contributor

This patch merges the 2 proposals submitted upstream, addressing
some problems with both:

With the patch, /dev/disk/by-path symlinks are created correctly,
and are unique, backward-compatible with the physical port case:

  • physical port (no vport field)
  • virtual ports (w/ vport field)

Symlinks:

# ls -l /dev/disk/by-path | grep 0001:09:00.0
<...> pci-0001:09:00.0-fc-0x500507680b2255fe-lun-0 -> ../../sdh
<...> pci-0001:09:00.0-fc-0x500507680b2255ff-lun-0 -> ../../sdi
<...> pci-0001:09:00.0-vport-0x5001a4aaf00a6785-fc-0x500507680b2255fe-lun-0 -> ../../sde
<...> pci-0001:09:00.0-vport-0x5001a4aaf00a6785-fc-0x500507680b2255ff-lun-0 -> ../../sdd
<...> pci-0001:09:00.0-vport-0x5001a4ad99d8c2de-fc-0x500507680b2255fe-lun-0 -> ../../sdc
<...> pci-0001:09:00.0-vport-0x5001a4ad99d8c2de-fc-0x500507680b2255ff-lun-0 -> ../../sdb

Accordingly w/ sysfs:

# ls -ld /sys/block/sd* | grep host1
<...> /sys/block/sdb -> ../devices/pci0001:00/<...>/0001:09:00.0/host1/vport-1:0-0/host3/rport-3:0-1/target3:0:0/3:0:0:0/block/sdb
<...> /sys/block/sdc -> ../devices/pci0001:00/<...>/0001:09:00.0/host1/vport-1:0-0/host3/rport-3:0-2/target3:0:1/3:0:1:0/block/sdc
<...> /sys/block/sdd -> ../devices/pci0001:00/<...>/0001:09:00.0/host1/vport-1:0-2/host5/rport-5:0-1/target5:0:0/5:0:0:0/block/sdd
<...> /sys/block/sde -> ../devices/pci0001:00/<...>/0001:09:00.0/host1/vport-1:0-2/host5/rport-5:0-2/target5:0:1/5:0:1:0/block/sde
<...> /sys/block/sdh -> ../devices/pci0001:00/<...>/0001:09:00.0/host1/rport-1:0-3/target1:0:0/1:0:0:0/block/sdh
<...> /sys/block/sdi -> ../devices/pci0001:00/<...>/0001:09:00.0/host1/rport-1:0-4/target1:0:1/1:0:1:0/block/sdi

The symlinks still include the fc_remote_port's (target) port_name:

# grep . /sys/class/fc_remote_ports/rport-{3:0-{1,2},5:0-{1,2},1:0-{3,4}}/port_name
/sys/class/fc_remote_ports/rport-3:0-1/port_name:0x500507680b2255ff
/sys/class/fc_remote_ports/rport-3:0-2/port_name:0x500507680b2255fe
/sys/class/fc_remote_ports/rport-5:0-1/port_name:0x500507680b2255ff
/sys/class/fc_remote_ports/rport-5:0-2/port_name:0x500507680b2255fe
/sys/class/fc_remote_ports/rport-1:0-3/port_name:0x500507680b2255fe
/sys/class/fc_remote_ports/rport-1:0-4/port_name:0x500507680b2255ff

And now include the fc_vport's (virtual host) port_name if it's from a fc_vport:

# grep . /sys/class/fc_host/host1/port_name /sys/class/fc_vports/vport-1:0-{0,2}/port_name
/sys/class/fc_host/host1/port_name:0x10000090fa8f0ebc
/sys/class/fc_vports/vport-1:0-0/port_name:0x5001a4ad99d8c2de
/sys/class/fc_vports/vport-1:0-2/port_name:0x5001a4aaf00a6785

With the Fibre Channel NPIV (N_Port ID Virtualization) feature,
a single physical N_Port (e.g., PCI address) can have multiple
N_Port IDs (e.g., different fc_host nodes) - which can connect
to the same target LUN (e.g., fc_remote_port's port_name and
LUN number).

Thus, in order to be unique, the device persistent path should
include the fc_vport's port_name (only if the fc_vport is used),
in addition to the already in use PCI address, fc_remote_port's
port_name and LUN number.

The patch merges the 2 proposals submitted upstream, addressing
some problems with both:
- #2500 (don't replace the fc_rport's port_name with fc_vport's)
- #2665 (don't add a fc_host/fc_vport's port_name if not needed)

Links
- #2500
- #2665

Built, checked, tested on RHEL Server 7.1 with no regressions.

With the patch, /dev/disk/by-path symlinks are created correctly,
and are unique, backward-compatible with the physical port case:
- physical port (no vport field)
- virtual ports (w/ vport field)

    # ls -l /dev/disk/by-path | grep 0001:09:00.0
    <...> pci-0001:09:00.0-fc-0x500507680b2255fe-lun-0 -> ../../sdh
    <...> pci-0001:09:00.0-fc-0x500507680b2255ff-lun-0 -> ../../sdi
    <...> pci-0001:09:00.0-vport-0x5001a4aaf00a6785-fc-0x500507680b2255fe-lun-0 -> ../../sde
    <...> pci-0001:09:00.0-vport-0x5001a4aaf00a6785-fc-0x500507680b2255ff-lun-0 -> ../../sdd
    <...> pci-0001:09:00.0-vport-0x5001a4ad99d8c2de-fc-0x500507680b2255fe-lun-0 -> ../../sdc
    <...> pci-0001:09:00.0-vport-0x5001a4ad99d8c2de-fc-0x500507680b2255ff-lun-0 -> ../../sdb

Accordingly w/ sysfs:

    # ls -ld /sys/block/sd* | grep host1
    <...> /sys/block/sdb -> ../devices/pci0001:00/<...>/0001:09:00.0/host1/vport-1:0-0/host3/rport-3:0-1/target3:0:0/3:0:0:0/block/sdb
    <...> /sys/block/sdc -> ../devices/pci0001:00/<...>/0001:09:00.0/host1/vport-1:0-0/host3/rport-3:0-2/target3:0:1/3:0:1:0/block/sdc
    <...> /sys/block/sdd -> ../devices/pci0001:00/<...>/0001:09:00.0/host1/vport-1:0-2/host5/rport-5:0-1/target5:0:0/5:0:0:0/block/sdd
    <...> /sys/block/sde -> ../devices/pci0001:00/<...>/0001:09:00.0/host1/vport-1:0-2/host5/rport-5:0-2/target5:0:1/5:0:1:0/block/sde
    <...> /sys/block/sdh -> ../devices/pci0001:00/<...>/0001:09:00.0/host1/rport-1:0-3/target1:0:0/1:0:0:0/block/sdh
    <...> /sys/block/sdi -> ../devices/pci0001:00/<...>/0001:09:00.0/host1/rport-1:0-4/target1:0:1/1:0:1:0/block/sdi

The symlinks still include the fc_remote_port's (target) port_name:

    # grep . /sys/class/fc_remote_ports/rport-{3:0-{1,2},5:0-{1,2},1:0-{3,4}}/port_name
    /sys/class/fc_remote_ports/rport-3:0-1/port_name:0x500507680b2255ff
    /sys/class/fc_remote_ports/rport-3:0-2/port_name:0x500507680b2255fe
    /sys/class/fc_remote_ports/rport-5:0-1/port_name:0x500507680b2255ff
    /sys/class/fc_remote_ports/rport-5:0-2/port_name:0x500507680b2255fe
    /sys/class/fc_remote_ports/rport-1:0-3/port_name:0x500507680b2255fe
    /sys/class/fc_remote_ports/rport-1:0-4/port_name:0x500507680b2255ff

And now include the fc_vport's (virtual host) port_name *if* it's from a fc_vport:

    # grep . /sys/class/fc_host/host1/port_name /sys/class/fc_vports/vport-1:0-{0,2}/port_name
    /sys/class/fc_host/host1/port_name:0x10000090fa8f0ebc
    /sys/class/fc_vports/vport-1:0-0/port_name:0x5001a4ad99d8c2de
    /sys/class/fc_vports/vport-1:0-2/port_name:0x5001a4aaf00a6785

Signed-off-by: Mauricio Faria de Oliveira <[email protected]>
Reported-by: Srikanth B. Aithal <[email protected]>
@mfoliveira
Copy link
Contributor Author

@poettering I'm submitting this only for documentation purposes, I do realize per the previous discussions that this kind of change is not going to make upstream; sorry for the noise.

@mfoliveira
Copy link
Contributor Author

@arvidjaar I believe this address your comment on #2665 (keep physical port case as is, and only change the vport case)

@maurizio-lombardi
Copy link
Contributor

@mfoliveira You are right, this patch should be preferred over both #2665 and #2500

@mfoliveira
Copy link
Contributor Author

@maurizio-lombardi cool, thanks for the review.
On Feb 26, 2016 06:18, "Maurizio Lombardi" [email protected] wrote:

@mfoliveira https://github.com/mfoliveira You are right, this patch
should be preferred over both #2665
#2665 and #2500
#2500


Reply to this email directly or view it on GitHub
#2731 (comment).

@poettering
Copy link
Member

Closing, because this really should move into some other package. See #2665 and #2500 for more information

@poettering poettering closed this Feb 29, 2016
lnykryn added a commit to lnykryn/systemd that referenced this pull request Mar 23, 2016
Revert original NPIV support patch, instead use patch from systemd#2731
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants