From 32dbfc4712696ea76034cf886afdb736b943e00d Mon Sep 17 00:00:00 2001 From: Steffen Maier Date: Fri, 2 Dec 2022 23:58:02 +0100 Subject: [PATCH] lszfcp: eliminate costly child process for each SCSI device A simple built-in parameter expansion removing the matching prefix pattern (everything up to and including the last slash) is sufficient to strip the path from the basename. Speeds up "lszfcp -D" significantly. Before: $ time ~/git/s390-tools/zconf/lszfcp -D | wc -l 1028 real 0m5.322s user 0m0.300s sys 0m4.907s After: $ time ~/git/s390-tools/zconf/lszfcp -D | wc -l 1028 real 0m0.602s user 0m0.100s sys 0m0.492s Above measurements are from the fast in-memory sysfs. The improvements are likely amplified when running "lszfcp --sysfs ..." on collected debug data in a regular file system. Reviewed-by: Benjamin Block Signed-off-by: Steffen Maier Signed-off-by: Steffen Eiden --- zconf/lszfcp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zconf/lszfcp b/zconf/lszfcp index d0b54a9d..7789f135 100755 --- a/zconf/lszfcp +++ b/zconf/lszfcp @@ -422,7 +422,7 @@ show_devices() fi if [ $VERBOSITY -eq 0 ]; then - echo "$ADAPTER/$WWPN/$LUN `basename $SCSI_DEVICE_PATH`$SDEVMARKER" + echo "$ADAPTER/$WWPN/$LUN ${SCSI_DEVICE_PATH##*/}$SDEVMARKER" else echo "`ls -d $SYSFS/devices/css0/[0-9d]*/$ADAPTER`/$WWPN/$LUN" echo ${SCSI_DEVICE_PATH%*/}$SDEVMARKER # without trailing slash