From 94b7a8f68d8e2c0f9345cfb2557a885d6e1ebe95 Mon Sep 17 00:00:00 2001 From: Steffen Maier Date: Tue, 19 Feb 2019 18:37:14 +0100 Subject: [PATCH] lszfcp: allow to also enumerate FCP device that have never been online MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since zfcp lazily allocates Scsi_Host et al. on setting an FCP device online for the first time since the last driver core bind to zfcp (such as zfcp kernel module load), lszfcp has only been showing FCP devices (vHBAs) that have been online at least once including those that have been set offline again. This is somewhat confusing. Also it would be nice if lszfcp could be an easier to type replacement for "lscss -t 17032/03" to simply show all devices bound to the zfcp device driver. Of course those FCP devices that have never been online, won't have any zfcp-specific attribute details, only CIO attributes from the CCW bus. They also do not have a Scsi_Host nor fc_host. In order not to break any scripting or expectations around lszfcp, make the new feature depend on the extended output command line option. Example: $ lszfcp -He 0.0.1880 - offline $ lszfcp -HeV /sys/devices/css0/0.0.010b/0.0.1880 offline - - $ lszfcp -Hea 0.0.1880 - offline Bus = "ccw" availability = "good" cmb_enable = "0" cutype = "1731/03" devtype = "1732/03" modalias = "ccw:t1731m03dt1732dm03" online = "0" uevent = "DRIVER=zfcp" Signed-off-by: Steffen Maier Reviewed-by: Fedor Loshakov Reviewed-by: Jens Remus Signed-off-by: Jan Höppner --- zconf/lszfcp | 34 ++++++++++++++++++++++++++++++++-- zconf/lszfcp.8 | 4 +++- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/zconf/lszfcp b/zconf/lszfcp index f8dacca8..0322db89 100755 --- a/zconf/lszfcp +++ b/zconf/lszfcp @@ -59,6 +59,19 @@ check_fcp_devs() ignore=$(ls -dX $SYSFS/devices/css[0-9]*/defunct/[0-9]*/host[0-9]* 2>&1) [ $? -eq 0 ] && found=1 fi + if [ $found -eq 0 ] && $SHOW_EXTENDED; then + local mypath mylist="" + # nothing found yet so search for FCP devices never been online + for mypath in $SYSFS/bus/ccw/drivers/zfcp/*.*.*; do + if [ "$mypath" = "$SYSFS/bus/ccw/drivers/zfcp/*.*.*" ]; + then + break # glob did not match anything + fi + [ -d $mypath/host[0-9]* ] && continue # is/was online + mylist="$mylist $(readlink -e $mypath)/-" + done + [ -n "$mylist" ] && found=1 + fi if [ $found -eq 0 ]; then echo "Error: No fcp devices found." @@ -150,6 +163,12 @@ show_hosts() # add all "defunct" FCP devices HOST_LIST="$HOST_LIST $(ls -dX $SYSFS/devices/css[0-9]*/defunct/[0-9]*/host[0-9]* 2>/dev/null)" + # add all FCP devices that have never been online + for HOST_PATH in $SYSFS/bus/ccw/drivers/zfcp/*.*.*; do + [ -d $HOST_PATH/host[0-9]* ] && continue # is/was online + HOST_LIST="$HOST_LIST +$(readlink -e $HOST_PATH)/-" + done fi for HOST_PATH in $HOST_LIST; do @@ -177,14 +196,25 @@ $(ls -dX $SYSFS/devices/css[0-9]*/defunct/[0-9]*/host[0-9]* 2>/dev/null)" echo $ADAPTER $SCSI_HOST$HOSTMARKER else echo $ADAPTER_PATH$HOSTMARKER - $FC_CLASS && echo "$SYSFS/class/fc_host/$SCSI_HOST" - echo "$SYSFS/class/scsi_host/$SCSI_HOST" + if [ "$SCSI_HOST" != "-" ]; then + $FC_CLASS && echo "$SYSFS/class/fc_host/$SCSI_HOST" + echo "$SYSFS/class/scsi_host/$SCSI_HOST" + else + echo "-" + echo "-" + fi fi if $SHOW_ATTRIBUTES; then echo 'Bus = "ccw"' show_attributes $ADAPTER_PATH + if [ "$SCSI_HOST" = "-" ]; then + # skip output of non-existent fc_host & scsi_host + echo + continue + fi + if $FC_CLASS; then echo 'Class = "fc_host"' show_attributes \ diff --git a/zconf/lszfcp.8 b/zconf/lszfcp.8 index a5653187..28aea1f5 100644 --- a/zconf/lszfcp.8 +++ b/zconf/lszfcp.8 @@ -51,6 +51,7 @@ Since a long time, without option "-e", lszfcp has .I not enumerated: +hosts that have never been online (since last bind to zfcp device driver), hosts that are defunct (CHPID configured off, or z/VM detach), ports with fc_rport port_state unequal to "Online" (such as fibres pulled). @@ -63,7 +64,8 @@ Show all attributes of the specified objects. List zfcp units and SCSI devices. .TP .B -H, --hosts -List zfcp adapters and fc-hosts (default). Information is given only +List zfcp adapters, fc-hosts, and scsi-hosts (default). +Without option "-e", information is given only for adapters that are online (registered at the SCSI stack). .TP .B -P, --ports