From 5107a7be16e4849fbda7beae0504fdbc0f2cb4b5 Mon Sep 17 00:00:00 2001 From: Stefan Haberland Date: Tue, 9 Aug 2022 13:12:26 +0200 Subject: [PATCH] zconf/lsdasd: fix Copy Pair related output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix the default output for copy pair secondary devices to not show a faulty blockdevice entry and major:minor combination. The new output looks like: # lsdasd Bus-ID Status Name Device Type BlkSz Size Blocks ================================================================================ 0.0.9740 secondary ECKD 0.0.9741 secondary ECKD 0.0.9742 secondary ECKD 0.0.e964 active dasda 94:0 ECKD 4096 21129MB 5409180 0.0.e967 active dasdb 94:4 ECKD 4096 21129MB 5409180 0.0.9330 active dasdc 94:8 ECKD 4096 782MB 200340 0.0.9700 active dasdd 94:12 ECKD 4096 782MB 200340 0.0.9701 active dasdf 94:20 ECKD 4096 782MB 200340 0.0.9702 active dasdh 94:28 ECKD 4096 782MB 200340 Also add copy_pairs to extended output: # lsdasd -l 9700 0.0.9700/dasdd/94:12 status: active type: ECKD blksz: 4096 size: 782MB blocks: 200340 extent_size: 1113 logical_capacity: 1113 space_allocated: 1113 use_diag: 0 readonly: 0 eer_enabled: 0 erplog: 0 hpf: 1 uid: IBM.750000000ABT31.9700.00 fc_security: Unsupported paths_installed: 38 39 3a 3b paths_in_use: 38 39 3a 3b paths_non_preferred: paths_invalid_cabling: paths_cuir_quiesced: paths_invalid_hpf_characteristics: paths_error_threshold_exceeded: copy_pairs: 0.0.9700,0.0.9740 0.0.9700,0.0.9743 0.0.9700,0.0.9744 0.0.9700,0.0.9745 Signed-off-by: Stefan Haberland Reviewed-by: Jan Hoeppner Signed-off-by: Jan Höppner --- zconf/lsdasd | 113 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 96 insertions(+), 17 deletions(-) diff --git a/zconf/lsdasd b/zconf/lsdasd index 795b33bd..8b2cc0ff 100755 --- a/zconf/lsdasd +++ b/zconf/lsdasd @@ -146,6 +146,62 @@ function findDASDDebugfsDirectorie() { fi } +#------------------------------------------------------------------------------ +# The blockpath can usually be found over the DEVPATH +# In case of a swapped Copy Pair device the blockdev is likely associated +# with one of the secondary devices +# this function checks if the blockdev is associated with the primary device +# and if not search for it in the secondary device list +#------------------------------------------------------------------------------ +function setCorrectBlockPath() { + local DRIVERECKD="$SYSFSDIR/bus/ccw/drivers/dasd-eckd/" + local DRIVERFBA="$SYSFSDIR/bus/ccw/drivers/dasd-fba/" + local SEARCHDIRS= + local SEARCHLIST= + + if [[ "$COPYROLE" == "none" ]] || [[ -d "$DEVPATH/block" ]]; then + BLOCKPATH="$DEVPATH"/block/dasd* + return + fi + + if [[ -d "$DRIVERECKD" ]]; then + SEARCHDIRS="$DRIVERECKD" + fi + if [[ -d "$DRIVERFBA" ]]; then + SEARCHDIRS="$SEARCHDIRS $DRIVERFBA" + fi + + SEARCHLIST=$(echo $SECONDARY_LIST | sed 's/,/ /g') + for SEARCHDEV in $SEARCHLIST + do + if [[ -n "$SEARCHDIRS" ]]; then + PRIM_DEVPATH=$(find $SEARCHDIRS -type l -name $SEARCHDEV \ + -printf "%h/%l\n" 2> /dev/null) + if [[ -d "$PRIM_DEVPATH/block" ]]; then + break + fi + else + # The above paths may become invalid in the future, so we keep the + # following query as backup: + PRIM_DEVPATH=$(find "$SYSFSDIR/devices" -type l -name $SEARCHDEV \ + "driver" -lname "*/dasd*" -printf "%h\n" \ + 2> /dev/null) + fi + done + + BLOCKPATH="$PRIM_DEVPATH"/block/dasd* +} + +#------------------------------------------------------------------------------ +# gather Copy Pair related data +#------------------------------------------------------------------------------ +function gatherCopyPairData() { + read COPYPAIR 2> /dev/null < $DEVPATH/copy_pair + PRIMARY_UID=`echo $COPYPAIR | cut -d " " -f1 | cut -d "," -f1` + COPYPAIR=`echo "$COPYPAIR" | sed 's/ /,/g' | sed 's/^,//' ` + SECONDARY_LIST=`echo ${COPYPAIR//$PRIMARY_UID","/} ` +} + #------------------------------------------------------------------------------ # gather device data and call appropriate output function #------------------------------------------------------------------------------ @@ -165,16 +221,18 @@ function gatherDeviceData() { read READONLY 2> /dev/null < $DEVPATH/readonly || continue read DISCIPLINE 2> /dev/null < $DEVPATH/discipline || continue read ESE 2> /dev/null < $DEVPATH/ese + read COPYROLE 2> /dev/null < $DEVPATH/copy_role + if [[ "$COPYROLE" != "none" ]]; then + gatherCopyPairData + fi # Block device specific information is only available for # devices that are online and not a PAV alias - if [[ ! "$ONLINE" == 0 ]] && [[ ! "$ALIAS" == 1 ]]; then - #find device Path to the block device - if [[ -d "$DEVPATH/block" ]]; then - set - "$DEVPATH"/block/dasd* - else - set - "$DEVPATH"/block:dasd* - fi + if [[ ! "$ONLINE" == 0 ]] && [[ ! "$ALIAS" == 1 ]] && + [[ ! "$COPYROLE" == "secondary" ]]; then + #find device Path to the block device + setCorrectBlockPath + set - $BLOCKPATH MAJMIN= MAJOR= MINOR= @@ -194,10 +252,12 @@ function gatherDeviceData() { fi fi else - # BLOCKNAME for offline and alias devices will not be - # printed, it's just a key for sorting + # BLOCKNAME for offline, alias and secondary devices + # will not be printed, it's just a key for sorting if [[ "$ONLINE" == 0 ]]; then BLOCKNAME="" + elif [[ "$COPYROLE" == "secondary" ]]; then + BLOCKNAME="b" else BLOCKNAME="a" fi @@ -261,6 +321,15 @@ function newoutput() return fi + if [[ "$COPYROLE" == "secondary" ]]; then + printf "%s:%s:%-8s secondary %-8s %13s\n" \ + "$SORTKEYLEN" "$SORTKEY" \ + "$BUSID" \ + "$PRIMARY_BLOCKNAME" \ + "$DISCIPLINE" + return + fi + if [[ "$READONLY" == 0 ]]; then ROSTRING="" else @@ -519,10 +588,14 @@ function extended() "${HPF_PATHS[@]}" \ "${IFCC_PATHS[@]}" ; return - elif [[ "$ALIAS" == 1 ]]; then - if [[ "$BASEONLY" == "false" ]]; then - ACTIVE="alias" - printf "%s:%s:%s# status:\t\t\t\t%s# type: \t\t\t\t%s# use_diag:\t\t\t\t%s# readonly:\t\t\t\t%s# eer_enabled:\t\t\t\t%s# erplog:\t\t\t\t%s# hpf:\t\t\t\t\t%s # uid: \t\t\t\t%s# fc_security: \t\t\t\t%s# paths_installed: \t\t\t%s %s %s %s %s %s %s %s# paths_in_use: \t\t\t%s %s %s %s %s %s %s %s# paths_non_preferred: \t\t\t%s %s %s %s %s %s %s %s# paths_invalid_cabling: \t\t%s %s %s %s %s %s %s %s# paths_cuir_quiesced: \t\t\t%s %s %s %s %s %s %s %s# paths_invalid_hpf_characteristics: \t%s %s %s %s %s %s %s %s# paths_error_threshold_exceeded: \t%s %s %s %s %s %s %s %s#\n" \ + elif [[ "$ALIAS" == 1 ]] || [[ "$COPYROLE" == "secondary" ]]; then + if [[ "$BASEONLY" == "false" ]] || [[ "$COPYROLE" == "secondary" ]]; then + if [[ "$COPYROLE" == "secondary" ]]; then + ACTIVE="secondary" + else + ACTIVE="alias" + fi + printf "%s:%s:%s# status:\t\t\t\t%s# type: \t\t\t\t%s# use_diag:\t\t\t\t%s# readonly:\t\t\t\t%s# eer_enabled:\t\t\t\t%s# erplog:\t\t\t\t%s# hpf:\t\t\t\t\t%s # uid: \t\t\t\t%s# fc_security: \t\t\t\t%s# paths_installed: \t\t\t%s %s %s %s %s %s %s %s# paths_in_use: \t\t\t%s %s %s %s %s %s %s %s# paths_non_preferred: \t\t\t%s %s %s %s %s %s %s %s# paths_invalid_cabling: \t\t%s %s %s %s %s %s %s %s# paths_cuir_quiesced: \t\t\t%s %s %s %s %s %s %s %s# paths_invalid_hpf_characteristics: \t%s %s %s %s %s %s %s %s# paths_error_threshold_exceeded: \t%s %s %s %s %s %s %s %s# copy_pairs:\t\t\t\t%s#\n" \ "$SORTKEYLEN" "$SORTKEY" \ "$BUSID" \ "$ACTIVE" \ @@ -540,7 +613,8 @@ function extended() "${CABLE_PATHS[@]}" \ "${CUIR_PATHS[@]}" \ "${HPF_PATHS[@]}" \ - "${IFCC_PATHS[@]}" ; + "${IFCC_PATHS[@]}" \ + "${COPYPAIR}" ; fi return elif [[ -z "$BLOCKNAME" ]] || [[ -z "$SIZE" ]]; then @@ -565,7 +639,7 @@ function extended() DISCIPLINE="${DISCIPLINE} (ESE)" fi - printf "%s:%s:%s/%s/%s%s%s# status:\t\t\t\t%s# type: \t\t\t\t%s# blksz:\t\t\t\t%s# size: \t\t\t\t%s# blocks:\t\t\t\t%s# extent_size:\t\t\t\t%s# logical_capacity:\t\t\t%s# space_allocated:\t\t\t%s# use_diag:\t\t\t\t%s# readonly:\t\t\t\t%s# eer_enabled:\t\t\t\t%s# erplog:\t\t\t\t%s# hpf:\t\t\t\t\t%s# uid: \t\t\t\t%s# fc_security: \t\t\t\t%s# paths_installed: \t\t\t%s %s %s %s %s %s %s %s# paths_in_use: \t\t\t%s %s %s %s %s %s %s %s# paths_non_preferred: \t\t\t%s %s %s %s %s %s %s %s# paths_invalid_cabling: \t\t%s %s %s %s %s %s %s %s# paths_cuir_quiesced: \t\t\t%s %s %s %s %s %s %s %s# paths_invalid_hpf_characteristics: \t%s %s %s %s %s %s %s %s# paths_error_threshold_exceeded: \t%s %s %s %s %s %s %s %s#\n" \ + printf "%s:%s:%s/%s/%s%s%s# status:\t\t\t\t%s# type: \t\t\t\t%s# blksz:\t\t\t\t%s# size: \t\t\t\t%s# blocks:\t\t\t\t%s# extent_size:\t\t\t\t%s# logical_capacity:\t\t\t%s# space_allocated:\t\t\t%s# use_diag:\t\t\t\t%s# readonly:\t\t\t\t%s# eer_enabled:\t\t\t\t%s# erplog:\t\t\t\t%s# hpf:\t\t\t\t\t%s# uid: \t\t\t\t%s# fc_security: \t\t\t\t%s# paths_installed: \t\t\t%s %s %s %s %s %s %s %s# paths_in_use: \t\t\t%s %s %s %s %s %s %s %s# paths_non_preferred: \t\t\t%s %s %s %s %s %s %s %s# paths_invalid_cabling: \t\t%s %s %s %s %s %s %s %s# paths_cuir_quiesced: \t\t\t%s %s %s %s %s %s %s %s# paths_invalid_hpf_characteristics: \t%s %s %s %s %s %s %s %s# paths_error_threshold_exceeded: \t%s %s %s %s %s %s %s %s# copy_pairs:\t\t\t\t%s#\n" \ "$SORTKEYLEN" "$SORTKEY" \ "$BUSID" \ "$BLOCKNAME" \ @@ -593,7 +667,8 @@ function extended() "${CABLE_PATHS[@]}" \ "${CUIR_PATHS[@]}" \ "${HPF_PATHS[@]}" \ - "${IFCC_PATHS[@]}" ; + "${IFCC_PATHS[@]}" \ + "${COPYPAIR}" ; } function host() @@ -710,7 +785,11 @@ function uid() fi fi - printf "%s:%s:%-8s %-8s %s\n" \ + if [[ "$COPYROLE" == "secondary" ]]; then + BLOCKNAME="secondary" + fi + + printf "%s:%s:%-8s %-10s %s\n" \ "$SORTKEYLEN" "$SORTKEY" \ "$BUSID" \ "$BLOCKNAME" \