Skip to content

Conversation

@mfoliveira
Copy link
Contributor

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_host's port_name (in addition to the already in
use PCI address, fc_remote_port's port_name and LUN number).

The patch adds the analogous logic to that used for targetdev/
fcdev/port, now for hostdev/fchostdev/hostport, then includes
"fc-hostport" in the path string.

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

Example (non-unique links for PCI address/port_name/lun-number):

for sd in /dev/sd...; do

  udevadm info $sd | grep ^S: | grep by-path
done

S: disk/by-path/pci-0001:09:00.0-fc-0x500507680b2255fe-lun-0
S: disk/by-path/pci-0001:09:00.0-fc-0x500507680b2255ff-lun-0
S: disk/by-path/pci-0001:09:00.0-fc-0x500507680b2255ff-lun-0
S: disk/by-path/pci-0001:09:00.0-fc-0x500507680b2255fe-lun-0

... | sort -u

S: disk/by-path/pci-0001:09:00.0-fc-0x500507680b2255fe-lun-0
S: disk/by-path/pci-0001:09:00.0-fc-0x500507680b2255ff-lun-0

Example (with patch, unique links include fc_host's port_name):

for sd in /dev/sd...; do

  udevadm info $sd | grep ^S: | grep by-path
done

S: disk/by-path/pci-0001:09:00.0-fc-0x5001a4aaf00a6785-fc-0x500507680b2255fe-lun-0
S: disk/by-path/pci-0001:09:00.0-fc-0x5001a4aaf00a6785-fc-0x500507680b2255ff-lun-0
S: disk/by-path/pci-0001:09:00.0-fc-0x5001a4ad99d8c2de-fc-0x500507680b2255ff-lun-0
S: disk/by-path/pci-0001:09:00.0-fc-0x5001a4ad99d8c2de-fc-0x500507680b2255fe-lun-0

cat /sys/class/fc_host/host{8,9}/port_name

0x5001a4aaf00a6785
0x5001a4ad99d8c2de

Signed-off-by: Mauricio Faria de Oliveira mauricfo@linux.vnet.ibm.com

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_host's port_name (in addition to the already in
use PCI address, fc_remote_port's port_name and LUN number).

The patch adds the analogous logic to that used for targetdev/
fcdev/port, now for hostdev/fchostdev/hostport, then includes
"fc-<hostport>" in the path string.

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

Example (non-unique links for PCI address/port_name/lun-number):

  # for sd in /dev/sd...; do
      udevadm info $sd | grep ^S: | grep by-path
    done
  S: disk/by-path/pci-0001:09:00.0-fc-0x500507680b2255fe-lun-0
  S: disk/by-path/pci-0001:09:00.0-fc-0x500507680b2255ff-lun-0
  S: disk/by-path/pci-0001:09:00.0-fc-0x500507680b2255ff-lun-0
  S: disk/by-path/pci-0001:09:00.0-fc-0x500507680b2255fe-lun-0

  # ... | sort -u
  S: disk/by-path/pci-0001:09:00.0-fc-0x500507680b2255fe-lun-0
  S: disk/by-path/pci-0001:09:00.0-fc-0x500507680b2255ff-lun-0

Example (with patch, unique links include fc_host's port_name):

  # for sd in /dev/sd...; do
      udevadm info $sd | grep ^S: | grep by-path
    done
  S: disk/by-path/pci-0001:09:00.0-fc-0x5001a4aaf00a6785-fc-0x500507680b2255fe-lun-0
  S: disk/by-path/pci-0001:09:00.0-fc-0x5001a4aaf00a6785-fc-0x500507680b2255ff-lun-0
  S: disk/by-path/pci-0001:09:00.0-fc-0x5001a4ad99d8c2de-fc-0x500507680b2255ff-lun-0
  S: disk/by-path/pci-0001:09:00.0-fc-0x5001a4ad99d8c2de-fc-0x500507680b2255fe-lun-0

  # cat /sys/class/fc_host/host{8,9}/port_name
  0x5001a4aaf00a6785
  0x5001a4ad99d8c2de

Signed-off-by: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
@poettering
Copy link
Member

Please see #2500.

Please find a place for this in some package maintained by storage people, we cannot maintain this upstream, we have no understanding of this stuff.

@mfoliveira
Copy link
Contributor Author

Hi @poettering

Sure, that's certainly understandable.

Wondering if @hreinecke can review/comment, as he's mentioned in the header, if that helps with any reassurance.

Thanks

@hreinecke
Copy link
Contributor

And you propose ... what?
Remove path_id from udev/systemd package?

@hreinecke
Copy link
Contributor

'tis a bit odd, seeing that udev is the sole consumer of the path_id program.

@arvidjaar
Copy link
Contributor

This patch invalidates "by-path" design for physical HBA. Before this patch replacing one FC HBA with another would still produce the same by-path alias because physical connection point did not change. After this patch replacing FC HBA will change by-path alias. "By-path" aliases are intended to describe topology, not property of individual components.

This probably should leave physical by-path aliases as is, and only create additional label for true vports, may be using "vport" prefix to clearly mark them. I.e.

disk/by-path/pci-0001:09:00.0-fc-0x500507680b2255fe-lun-0
disk/by-path/pci-0001:09:00.0-vport-0x5001a4ad99d8c2de-fc-0x500507680b2255ff-lun-0

At lease with Emulex^WAvago you always need WWNN/WWPN to create new vport, so WWPN persistently identifies vport.

@msekletar
Copy link
Contributor

FWIW, in RHEL/CentOS we merged patch for path_id proposed in #2500. We should probably close this PR as duplicate of the former.

@hreinecke
Copy link
Contributor

Yep; this is a better solution than a wholesale change.
Which we cannot do, as the links are meant to be persistent, so we cannot change existing ones.

@kaysievers
Copy link
Contributor

The tools scsi_id, ata_id, , cdr_id, the storage part of path_id are all in maintenance mode and will not get any features merged. Only obvious bugs will be applied, nothing that changes any naming or extends functionality.

Someone with knowlegde in that area should move them to a separate package that can be maintained outside of systemd/udev. Hannes worked on moving parts of scsi_id to sg3_utils, finishing that would be the first step I assume.

Closing this pull request, for the above mentioned reasons.

@kaysievers kaysievers closed this Feb 19, 2016
@mfoliveira
Copy link
Contributor Author

@arvidjaar

Got it; thanks for the explanation.

@msekletar

Nice to know; that'd be enough for me at this time.

@hreinecke

Thanks for the review.

lnykryn pushed a commit to lnykryn/systemd-rhel that referenced this pull request Mar 4, 2016
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
- systemd/systemd#2500
- systemd/systemd#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 <mauricfo@linux.vnet.ibm.com>
Reported-by: Srikanth B. Aithal <bssrikanth@in.ibm.com>

Cherry-picked from: 6a3d3f9e5970cf982ac37c65d0b856146b675a12
Resolves: #1266934
msekletar added a commit to msekletar/udev that referenced this pull request Aug 30, 2016
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
- systemd/systemd#2500
- systemd/systemd#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 <mauricfo@linux.vnet.ibm.com>
Reported-by: Srikanth B. Aithal <bssrikanth@in.ibm.com>

(cherry-picked from commit 6a3d3f9e5970cf982ac37c65d0b856146b675a12)

Resolves: #1032218
apovichuk-stratoscale pushed a commit to Stratoscale/systemd that referenced this pull request Jun 19, 2017
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
- systemd/systemd#2500
- systemd/systemd#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 <mauricfo@linux.vnet.ibm.com>
Reported-by: Srikanth B. Aithal <bssrikanth@in.ibm.com>

Cherry-picked from: 6a3d3f9e5970cf982ac37c65d0b856146b675a12
Resolves: #1266934
apovichuk-stratoscale pushed a commit to Stratoscale/systemd that referenced this pull request Jun 20, 2017
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
- systemd/systemd#2500
- systemd/systemd#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 <mauricfo@linux.vnet.ibm.com>
Reported-by: Srikanth B. Aithal <bssrikanth@in.ibm.com>

Cherry-picked from: 6a3d3f9e5970cf982ac37c65d0b856146b675a12
Resolves: #1266934
caobinxin pushed a commit to caobinxin/systemd-lx that referenced this pull request Oct 19, 2019
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
- systemd/systemd#2500
- systemd/systemd#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 <mauricfo@linux.vnet.ibm.com>
Reported-by: Srikanth B. Aithal <bssrikanth@in.ibm.com>

Cherry-picked from: 6a3d3f9e5970cf982ac37c65d0b856146b675a12
Resolves: #1266934
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.

6 participants