diff --git a/SOURCES/59-fc-wwpn-id.rules b/SOURCES/59-fc-wwpn-id.rules new file mode 100644 index 0000000..81a20ad --- /dev/null +++ b/SOURCES/59-fc-wwpn-id.rules @@ -0,0 +1,17 @@ +# +# FC WWPN-based by-path links +# + +ACTION!="add|change", GOTO="fc_wwpn_end" +KERNEL!="sd*", GOTO="fc_wwpn_end" + +ENV{DEVTYPE}=="disk", IMPORT{program}="fc_wwpn_id %p" +ENV{DEVTYPE}=="partition", IMPORT{parent}="FC_*" +ENV{FC_TARGET_WWPN}!="$*"; GOTO="fc_wwpn_end" +ENV{FC_INITIATOR_WWPN}!="$*"; GOTO="fc_wwpn_end" +ENV{FC_TARGET_LUN}!="$*"; GOTO="fc_wwpn_end" + +ENV{DEVTYPE}=="disk", SYMLINK+="disk/by-path/fc-$env{FC_INITIATOR_WWPN}-$env{FC_TARGET_WWPN}-lun-$env{FC_TARGET_LUN}" +ENV{DEVTYPE}=="partition", SYMLINK+="disk/by-path/fc-$env{FC_INITIATOR_WWPN}-$env{FC_TARGET_WWPN}-lun-$env{FC_TARGET_LUN}-part%n" + +LABEL="fc_wwpn_end" diff --git a/SOURCES/fc_wwpn_id b/SOURCES/fc_wwpn_id new file mode 100644 index 0000000..c8d0189 --- /dev/null +++ b/SOURCES/fc_wwpn_id @@ -0,0 +1,49 @@ +#!/bin/bash +# +# fc_wwpn_id +# +# Generates device node names links based on FC WWPN +# Copyright (c) 2016 Hannes Reinecke, SUSE Linux GmbH +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation version 2 of the License. +# + +DEVPATH=$1 +SCSIPATH=$(cd -P "/sys$DEVPATH/device" || exit; echo "$PWD") + +d=$SCSIPATH +[ -d "$d/scsi_disk" ] || exit 0 +target_lun=${d##*:} + +while [ -n "$d" ] ; do + d=${d%/*} + e=${d##*/} + case "$e" in + rport*) + rport=$e + rport_dir="/sys/class/fc_remote_ports/$rport" + if [ -d "$rport_dir" ] ; then + rport_wwpn=$(cat "$rport_dir/port_name") + fi + ;; + host*) + host=$e + host_dir="/sys/class/fc_host/$host" + if [ -d "$host_dir" ] ; then + host_wwpn=$(cat "$host_dir/port_name") + break; + fi + esac +done + +echo "FC_TARGET_LUN=$target_lun" + +if [ -n "$rport_wwpn" ] ; then + echo "FC_TARGET_WWPN=$rport_wwpn" +fi + +if [ -n "$host_wwpn" ] ; then + echo "FC_INITIATOR_WWPN=$host_wwpn" +fi diff --git a/SPECS/sg3_utils.spec b/SPECS/sg3_utils.spec index 826c4fe..b092619 100644 --- a/SPECS/sg3_utils.spec +++ b/SPECS/sg3_utils.spec @@ -3,12 +3,16 @@ Summary: Utilities for devices that use SCSI command sets Name: sg3_utils Version: 1.37 -Release: 18%{?dist} +Release: 18%{?dist}.1 License: GPLv2+ and BSD Group: Applications/System Source0: http://sg.danny.cz/sg/p/sg3_utils-%{version}.tgz Source1: rescan-scsi-bus.sh.8 Source2: scsi-rescan.8 +# https://bugzilla.redhat.com/show_bug.cgi?id=1684302 +# [HPE 7.6 Bug] Fibre Channel NPIV - device names in /dev/disk/by-path are not persistent / unique +Source3: 59-fc-wwpn-id.rules +Source4: fc_wwpn_id # https://bugzilla.redhat.com/show_bug.cgi?id=920687 Patch0: sg3_utils-1.37-dont-open-dev-snapshot.patch # https://bugzilla.redhat.com/show_bug.cgi?id=948463 @@ -107,6 +111,11 @@ install -p -m 755 scripts/%{rescan_script} $RPM_BUILD_ROOT%{_bindir} install -p -m 644 %{SOURCE1} $RPM_BUILD_ROOT%{_mandir}/man8 install -p -m 644 %{SOURCE2} $RPM_BUILD_ROOT%{_mandir}/man8 +mkdir -p $RPM_BUILD_ROOT%{_udevrulesdir}/ +install -p -m 644 %{SOURCE3} $RPM_BUILD_ROOT%{_udevrulesdir}/ +mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/udev/rules.d +install -m 0755 %{SOURCE4} $RPM_BUILD_ROOT%{_prefix}/lib/udev/ + %post libs -p /sbin/ldconfig @@ -117,6 +126,8 @@ install -p -m 644 %{SOURCE2} $RPM_BUILD_ROOT%{_mandir}/man8 %doc AUTHORS BSD_LICENSE COPYING COVERAGE CREDITS ChangeLog README README.sg_start %{_bindir}/* %{_mandir}/man8/* +%{_udevrulesdir}/59-fc-wwpn-id.rules +%{_prefix}/lib/udev/fc_wwpn_id %files libs %doc BSD_LICENSE COPYING @@ -128,6 +139,9 @@ install -p -m 644 %{SOURCE2} $RPM_BUILD_ROOT%{_mandir}/man8 %changelog +* Fri Aug 16 2019 Tomas Bzatek 1.37-18.el7_7.1 +- Add 59-fc-wwpn-id.rules (#1684302) + * Tue Feb 26 2019 Tomas Bzatek 1.37-18 - Fix sg_turs help invocation in an old mode (#1601797)