From b0dcc61ed58198de1eac41318fce9e8d13904076 Mon Sep 17 00:00:00 2001 From: Steffen Maier Date: Tue, 19 Feb 2019 18:13:33 +0100 Subject: [PATCH] lszfcp: fix to show non-good target ports again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Jens Remus Signed-off-by: Jan Höppner --- zconf/lszfcp | 32 +++++++++++++++++++++++++------- zconf/lszfcp.8 | 7 +++++++ 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/zconf/lszfcp b/zconf/lszfcp index 3fca53a6..ac3bdc94 100755 --- a/zconf/lszfcp +++ b/zconf/lszfcp @@ -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 diff --git a/zconf/lszfcp.8 b/zconf/lszfcp.8 index 0e8fed1a..ad11c8b2 100644 --- a/zconf/lszfcp.8 +++ b/zconf/lszfcp.8 @@ -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