|
|
923a60 |
From 05004e584a76645dcbcaaa4d5c2d3d3255900770 Mon Sep 17 00:00:00 2001
|
|
|
923a60 |
From: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
|
|
|
923a60 |
Date: Tue, 23 Feb 2016 15:02:02 -0300
|
|
|
923a60 |
Subject: [PATCH] udev: path-id: fibre channel NPIV - use fc_vport's port_name
|
|
|
923a60 |
|
|
|
923a60 |
With the Fibre Channel NPIV (N_Port ID Virtualization) feature,
|
|
|
923a60 |
a single physical N_Port (e.g., PCI address) can have multiple
|
|
|
923a60 |
N_Port IDs (e.g., different fc_host nodes) - which can connect
|
|
|
923a60 |
to the same target LUN (e.g., fc_remote_port's port_name and
|
|
|
923a60 |
LUN number).
|
|
|
923a60 |
|
|
|
923a60 |
Thus, in order to be unique, the device persistent path should
|
|
|
923a60 |
include the fc_vport's port_name (only if the fc_vport is used),
|
|
|
923a60 |
in addition to the already in use PCI address, fc_remote_port's
|
|
|
923a60 |
port_name and LUN number.
|
|
|
923a60 |
|
|
|
923a60 |
The patch merges the 2 proposals submitted upstream, addressing
|
|
|
923a60 |
some problems with both:
|
|
|
923a60 |
- #2500 (don't replace the fc_rport's port_name with fc_vport's)
|
|
|
923a60 |
- #2665 (don't add a fc_host/fc_vport's port_name if not needed)
|
|
|
923a60 |
|
|
|
923a60 |
Links
|
|
|
923a60 |
- https://github.com/systemd/systemd/pull/2500/
|
|
|
923a60 |
- https://github.com/systemd/systemd/pull/2665/
|
|
|
923a60 |
|
|
|
923a60 |
Built, checked, tested on RHEL Server 7.1 with no regressions.
|
|
|
923a60 |
|
|
|
923a60 |
With the patch, /dev/disk/by-path symlinks are created correctly,
|
|
|
923a60 |
and are unique, backward-compatible with the physical port case:
|
|
|
923a60 |
- physical port (no vport field)
|
|
|
923a60 |
- virtual ports (w/ vport field)
|
|
|
923a60 |
|
|
|
923a60 |
# ls -l /dev/disk/by-path | grep 0001:09:00.0
|
|
|
923a60 |
<...> pci-0001:09:00.0-fc-0x500507680b2255fe-lun-0 -> ../../sdh
|
|
|
923a60 |
<...> pci-0001:09:00.0-fc-0x500507680b2255ff-lun-0 -> ../../sdi
|
|
|
923a60 |
<...> pci-0001:09:00.0-vport-0x5001a4aaf00a6785-fc-0x500507680b2255fe-lun-0 -> ../../sde
|
|
|
923a60 |
<...> pci-0001:09:00.0-vport-0x5001a4aaf00a6785-fc-0x500507680b2255ff-lun-0 -> ../../sdd
|
|
|
923a60 |
<...> pci-0001:09:00.0-vport-0x5001a4ad99d8c2de-fc-0x500507680b2255fe-lun-0 -> ../../sdc
|
|
|
923a60 |
<...> pci-0001:09:00.0-vport-0x5001a4ad99d8c2de-fc-0x500507680b2255ff-lun-0 -> ../../sdb
|
|
|
923a60 |
|
|
|
923a60 |
Accordingly w/ sysfs:
|
|
|
923a60 |
|
|
|
923a60 |
# ls -ld /sys/block/sd* | grep host1
|
|
|
923a60 |
<...> /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
|
|
|
923a60 |
<...> /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
|
|
|
923a60 |
<...> /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
|
|
|
923a60 |
<...> /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
|
|
|
923a60 |
<...> /sys/block/sdh -> ../devices/pci0001:00/<...>/0001:09:00.0/host1/rport-1:0-3/target1:0:0/1:0:0:0/block/sdh
|
|
|
923a60 |
<...> /sys/block/sdi -> ../devices/pci0001:00/<...>/0001:09:00.0/host1/rport-1:0-4/target1:0:1/1:0:1:0/block/sdi
|
|
|
923a60 |
|
|
|
923a60 |
The symlinks still include the fc_remote_port's (target) port_name:
|
|
|
923a60 |
|
|
|
923a60 |
# grep . /sys/class/fc_remote_ports/rport-{3:0-{1,2},5:0-{1,2},1:0-{3,4}}/port_name
|
|
|
923a60 |
/sys/class/fc_remote_ports/rport-3:0-1/port_name:0x500507680b2255ff
|
|
|
923a60 |
/sys/class/fc_remote_ports/rport-3:0-2/port_name:0x500507680b2255fe
|
|
|
923a60 |
/sys/class/fc_remote_ports/rport-5:0-1/port_name:0x500507680b2255ff
|
|
|
923a60 |
/sys/class/fc_remote_ports/rport-5:0-2/port_name:0x500507680b2255fe
|
|
|
923a60 |
/sys/class/fc_remote_ports/rport-1:0-3/port_name:0x500507680b2255fe
|
|
|
923a60 |
/sys/class/fc_remote_ports/rport-1:0-4/port_name:0x500507680b2255ff
|
|
|
923a60 |
|
|
|
923a60 |
And now include the fc_vport's (virtual host) port_name *if* it's from a fc_vport:
|
|
|
923a60 |
|
|
|
923a60 |
# grep . /sys/class/fc_host/host1/port_name /sys/class/fc_vports/vport-1:0-{0,2}/port_name
|
|
|
923a60 |
/sys/class/fc_host/host1/port_name:0x10000090fa8f0ebc
|
|
|
923a60 |
/sys/class/fc_vports/vport-1:0-0/port_name:0x5001a4ad99d8c2de
|
|
|
923a60 |
/sys/class/fc_vports/vport-1:0-2/port_name:0x5001a4aaf00a6785
|
|
|
923a60 |
|
|
|
923a60 |
Signed-off-by: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
|
|
|
923a60 |
Reported-by: Srikanth B. Aithal <bssrikanth@in.ibm.com>
|
|
|
923a60 |
|
|
|
923a60 |
Cherry-picked from: 6a3d3f9e5970cf982ac37c65d0b856146b675a12
|
|
|
923a60 |
Resolves: #1266934
|
|
|
923a60 |
---
|
|
|
923a60 |
src/udev/udev-builtin-path_id.c | 30 ++++++++++++++++++++++++++++++
|
|
|
923a60 |
1 file changed, 30 insertions(+)
|
|
|
923a60 |
|
|
|
923a60 |
diff --git a/src/udev/udev-builtin-path_id.c b/src/udev/udev-builtin-path_id.c
|
|
|
923a60 |
index 9ca608468c..3b72922d48 100644
|
|
|
923a60 |
--- a/src/udev/udev-builtin-path_id.c
|
|
|
923a60 |
+++ b/src/udev/udev-builtin-path_id.c
|
|
|
923a60 |
@@ -92,7 +92,11 @@ static struct udev_device *skip_subsystem(struct udev_device *dev, const char *s
|
|
|
923a60 |
static struct udev_device *handle_scsi_fibre_channel(struct udev_device *parent, char **path) {
|
|
|
923a60 |
struct udev *udev = udev_device_get_udev(parent);
|
|
|
923a60 |
struct udev_device *targetdev;
|
|
|
923a60 |
+ struct udev_device *rportdev;
|
|
|
923a60 |
+ struct udev_device *hostdev;
|
|
|
923a60 |
+ struct udev_device *vportdev;
|
|
|
923a60 |
struct udev_device *fcdev = NULL;
|
|
|
923a60 |
+ struct udev_device *fc_vportdev = NULL;
|
|
|
923a60 |
const char *port;
|
|
|
923a60 |
char *lun = NULL;
|
|
|
923a60 |
|
|
|
923a60 |
@@ -113,6 +117,32 @@ static struct udev_device *handle_scsi_fibre_channel(struct udev_device *parent,
|
|
|
923a60 |
path_prepend(path, "fc-%s-%s", port, lun);
|
|
|
923a60 |
if (lun)
|
|
|
923a60 |
free(lun);
|
|
|
923a60 |
+
|
|
|
923a60 |
+ /* NPIV */
|
|
|
923a60 |
+ rportdev = udev_device_get_parent(targetdev);
|
|
|
923a60 |
+ if (rportdev == NULL)
|
|
|
923a60 |
+ goto out;
|
|
|
923a60 |
+
|
|
|
923a60 |
+ hostdev = udev_device_get_parent(rportdev);
|
|
|
923a60 |
+ if (hostdev == NULL)
|
|
|
923a60 |
+ goto out;
|
|
|
923a60 |
+
|
|
|
923a60 |
+ vportdev = udev_device_get_parent(hostdev);
|
|
|
923a60 |
+ if (vportdev == NULL)
|
|
|
923a60 |
+ goto out;
|
|
|
923a60 |
+
|
|
|
923a60 |
+ fc_vportdev = udev_device_new_from_subsystem_sysname(udev, "fc_vports", udev_device_get_sysname(vportdev));
|
|
|
923a60 |
+ if (fc_vportdev == NULL)
|
|
|
923a60 |
+ goto out;
|
|
|
923a60 |
+
|
|
|
923a60 |
+ port = udev_device_get_sysattr_value(fc_vportdev, "port_name");
|
|
|
923a60 |
+ if (port == NULL)
|
|
|
923a60 |
+ goto out_npiv;
|
|
|
923a60 |
+
|
|
|
923a60 |
+ path_prepend(path, "vport-%s", port);
|
|
|
923a60 |
+
|
|
|
923a60 |
+out_npiv:
|
|
|
923a60 |
+ udev_device_unref(fc_vportdev);
|
|
|
923a60 |
out:
|
|
|
923a60 |
udev_device_unref(fcdev);
|
|
|
923a60 |
return parent;
|