lszfcp: fix to show non-good target ports again

s390-tools-1.8.1 introduced a regression skipping all fc_rports
with port_state != Online. While we need to skip some output parts
for a zfcp_port which does not exist anymore due to port_remove,
there are other cases with port_state != Online for which we should
not skip an fc_rport.

Such as port_state "Blocked" after a cable pull beyond host-adjacent switch
or port_state "Not Present" after dev_loss_tmo ran out.
This way the user can see the previously discovered ports,
even if they might currently not be usable for traffic.
Non-good ports are marked in the short output with suffix "NotOnline".
In order not to break scripting or expectations around lszfcp, make the new
feature depend on the extended output command line option.

Sysfs path globbing does not work for a removed zfcp_port
to obtain the FCP device bus-ID. Instead, properly walk the sysfs.

Examples with a removed zfcp_port:
$ lszfcp -Pe
0.0.50c0/0x500507680b2481fa rport-6:0-2
$ lszfcp -PeV
- (NoMoreZfcpPort:0.0.50c0/0x500507680b2481fa)
/sys/class/fc_remote_ports/rport-6:0-2

Examples with an existing zfcp_port but pulled fibre:
$ lszfcp -Pe
0.0.3c40/0x500507680b2181fb rport-7:0-4
$ lszfcp -PeV
/sys/devices/css0/defunct/0.0.3c40/0x500507680b2181fb
/sys/class/fc_remote_ports/rport-7:0-4

Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Steffen Maier
2019-02-19 18:13:33 +01:00
committed by Jan Höppner
parent a3e37953fe
commit b0dcc61ed5
2 changed files with 32 additions and 7 deletions

View File

@@ -198,8 +198,7 @@ show_ports()
for FC_PORT_PATH in $PORT_LIST; do
PORT=`basename $FC_PORT_PATH`
read PORT_STATE < $FC_PORT_PATH/port_state
if [ "$PORT_STATE" == "Online" ];
then
if [ "$PORT_STATE" == "Online" ] || $SHOW_EXTENDED; then
read WWPN < $FC_PORT_PATH/port_name
else
continue
@@ -207,17 +206,36 @@ show_ports()
[ $WWPN != ${PAR_WWPN:-$WWPN} ] && continue
ADAPTER_PORT_PATH=`ls -d \
$SYSFS/devices/css0/*/*/$WWPN/../host[0-9]*/$PORT |\
awk -F "/../host" '{ print $1 }'`
ADAPTER=`basename \`dirname $ADAPTER_PORT_PATH\``
local sysreal=$(readlink -e "$FC_PORT_PATH")
local ADAPTER=""
while [ -n "$sysreal" ]; do
# ascend to parent: strip last path part
sysreal=${sysreal%/*}
[ -h $sysreal/subsystem ] || continue
local subsystem=$(readlink -e $sysreal/subsystem)
if [ "${subsystem##*/}" = "ccw" ]; then
ADAPTER=${sysreal##*/}
break
fi
done
[ -z "$ADAPTER" ] && continue # skip not zfcp-attached ones
if [ -d $SYSFS/devices/css[0-9]*/[0-9d]*/[0-9]*/$WWPN/../host[0-9]*/$PORT ];
then
ADAPTER_PORT_PATH=$SYSFS/devices/css[0-9]*/[0-9d]*/$ADAPTER/$WWPN
else
ADAPTER_PORT_PATH="-"
fi
[ $ADAPTER != ${PAR_BUSID:-$ADAPTER} ] && continue
if [ $VERBOSITY -eq 0 ]; then
echo "$ADAPTER/$WWPN $PORT"
else
echo $ADAPTER_PORT_PATH
if [ "$ADAPTER_PORT_PATH" != "-" ]; then
echo $ADAPTER_PORT_PATH
else
echo "- (NoMoreZfcpPort:$ADAPTER/$WWPN)"
fi
echo $FC_PORT_PATH
fi

View File

@@ -44,6 +44,13 @@ Option "-a" additionally shows all attributes of interest found in
sysfs for the listed object.
Option "-e" enables an extended output format.
It enumerates all hosts/ports/luns independent of their state.
The extended output format can help determining problems.
Since a long time, without option "-e", lszfcp has
.I
not
enumerated:
ports with fc_rport port_state unequal to "Online" (such as fibres pulled).
.SH OPTIONS
.TP