From c265e1c7b045bf1f9e5b2919c282b63086929ab6 Mon Sep 17 00:00:00 2001 From: Arshad Hussain Date: Tue, 9 Jan 2024 11:42:57 +0530 Subject: [PATCH] LU-16861 obdfilter: Exclude quotes when getting NIDs In get_targets(), when getting NIDs the quotes were also included. Exclude quotes when generating NIDs as they are not required. Use $LCTL instead of $lctl, and make it also work in Janitor testing. Test-Parameters: trivial testlist=obdfilter-survey Fixes: 9ef9906d7 ("LU-6863 tests: change obdfilter-survey.sh for CLIENTONLY mode") Signed-off-by: Arshad Hussain Change-Id: I8642539fc6b396f1339e20e4fef8bc78cda2d969 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53620 Tested-by: jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Andreas Dilger Reviewed-by: Alex Deiter Reviewed-by: Oleg Drokin --- lustre-iokit/lst-survey/lst.sh | 27 +++++++---- lustre-iokit/mds-survey/mds-survey | 24 ++++++---- lustre-iokit/obdfilter-survey/iokit-libecho | 30 ++++++------ lustre-iokit/obdfilter-survey/obdfilter-survey | 63 ++++++++++---------------- lustre/tests/obdfilter-survey.sh | 15 ++++-- 5 files changed, 84 insertions(+), 75 deletions(-) diff --git a/lustre-iokit/lst-survey/lst.sh b/lustre-iokit/lst-survey/lst.sh index 4e0a5cd..ef4ada8 100755 --- a/lustre-iokit/lst-survey/lst.sh +++ b/lustre-iokit/lst-survey/lst.sh @@ -88,21 +88,21 @@ stop_lst() { local rc=0 if ${LST_BATCH_STARTED}; then - lctl mark "lst stop ${BATCH_NAME}" + $LCTL mark "lst stop ${BATCH_NAME}" [[ -n ${ALL_HOSTS} ]] && - $PDSH "${ALL_HOSTS}" "lctl mark \"lst stop ${BATCH_NAME}\"" + $PDSH "${ALL_HOSTS}" "$LCTL mark 'lst stop ${BATCH_NAME}'" lst stop "${BATCH_NAME}" || rc=$? LST_BATCH_STARTED=false fi if ${LST_SESSION_CREATED}; then - lctl mark "Stop LST $MODE" + $LCTL mark "Stop LST $MODE" echo "Stop LST $MODE - $(date)" [[ -n ${ALL_HOSTS} ]] && - $PDSH "${ALL_HOSTS}" "lctl mark \"Stop LST $MODE\"" + $PDSH "${ALL_HOSTS}" "$LCTL mark 'Stop LST $MODE'" lst end_session || rc=$((rc + $?)) LST_SESSION_CREATED=false @@ -186,6 +186,17 @@ while getopts "b:C:c:d:D:ef:g:hHl:Lm:Mn:o:s:S:t:" flag ; do esac done +# find where 'lctl' binary is installed on this system +if [[ -x "$LCTL" ]]; then # full pathname specified + : # echo "LCTL=$LCTL" +elif [[ -n "$LUSTRE" && -x "$LUSTRE/utils/lctl" ]]; then + LCTL=$LUSTRE/utils/lctl +else # hope that it is in the PATH + LCTL=${LCTL:-lctl} +fi +#echo "using LCTL='$LCTL' lustre_root='$lustre_root' LUSTRE='$LUSTRE'" +[[ -n "$(which $LCTL)" ]] || { echo "error: lctl not found"; exit 99; } + if [[ -z $CLIENTS ]]; then echo "Must specify \"clients\" group (-f)" exit 1 @@ -272,7 +283,7 @@ if ${HOST_MODE}; then idx=0 opts=( -o NumberOfPasswordPrompts=0 -o ConnectTimeout=5 ) for host in ${SERVERS//,/ }; do - s_nids[idx]=$(ssh "${opts[@]}" "$host" 'lctl list_nids | head -n 1') + s_nids[idx]=$(ssh "${opts[@]}" "$host" '$LCTL list_nids | head -n 1') if [[ -z ${s_nids[idx]} ]]; then echo "Failed to determine primary NID of $host" exit @@ -282,7 +293,7 @@ if ${HOST_MODE}; then idx=0 for host in ${CLIENTS//,/ }; do - c_nids[idx]=$(ssh "${opts[@]}" "${host}" 'lctl list_nids | head -n 1') + c_nids[idx]=$(ssh "${opts[@]}" "${host}" '$LCTL list_nids | head -n 1') if [[ -z ${c_nids[idx]} ]]; then echo "Failed to determine primary NID of $host" exit @@ -318,9 +329,9 @@ if ! grep -q '\[' <<<"${CLIENT_NIDS[@]}" && which lnetctl &>/dev/null; then fi [[ -n $ALL_HOSTS ]] && - $PDSH "$ALL_HOSTS" "lctl mark \"Start LST $MODE\"" + $PDSH "$ALL_HOSTS" "$LCTL mark 'Start LST $MODE'" -lctl mark "Start LST $MODE" +$LCTL mark "Start LST $MODE" echo "Start LST $MODE - $(date)" trap 'exit_handler' EXIT diff --git a/lustre-iokit/mds-survey/mds-survey b/lustre-iokit/mds-survey/mds-survey index 0d6bc30..6111e1a9 100755 --- a/lustre-iokit/mds-survey/mds-survey +++ b/lustre-iokit/mds-survey/mds-survey @@ -70,7 +70,7 @@ create_directories () { else dirname="$(printf "${mdtbasedir}" $mdtidx)${basedir}${idx}" fi - remote_shell $host $lctl --device $devno test_mkdir /$dirname \ + remote_shell $host $LCTL --device $devno test_mkdir /$dirname \ -c $dir_stripes --stripe_index $mdtidx > $rfile 2>&1 while read line; do echo "$line" | grep -q 'error: test_mkdir' @@ -99,7 +99,7 @@ destroy_directories () { else dirname="$(printf "${mdtbasedir}" $mdtidx)${basedir}${idx}" fi - remote_shell $host $lctl --device $devno test_rmdir /$dirname > $rfile 2>&1 + remote_shell $host $LCTL --device $devno test_rmdir /$dirname > $rfile 2>&1 done } @@ -193,17 +193,23 @@ if [ "$lustre_root" == " " ]; then unset lustre_root fi -if [ -z "$lustre_root" ]; then - lctl=lctl -else - lctl=${lustre_root}/utils/lctl +# find where 'lctl' binary is installed on this system +if [[ -x "$LCTL" ]]; then # full pathname specified + : # echo "LCTL=$LCTL" +elif [[ -n "$lustre_root" && -x "$lustre_root/utils/lctl" ]]; then + LCTL=${lustre_root}/utils/lctl +elif [[ -n "$LUSTRE" && -x "$LUSTRE/utils/lctl" ]]; then + LCTL=$LUSTRE/utils/lctl +else # hope that it is in the PATH + LCTL=${LCTL:-lctl} fi +[[ -n "$(which $LCTL)" ]] || { echo "error: lctl not found"; exit 99; } declare -a client_names declare -a host_names declare -a client_indexes if [ -z "$targets" ]; then - targets=$($lctl device_list | awk "{if (\$2 == \"UP\" && \ + targets=$($LCTL device_list | awk "{if (\$2 == \"UP\" && \ \$3 == \"mdt\") {print \$4} }") if [ -z "$targets" ]; then echo "Can't find any MDT to test. Please set targets=..." @@ -226,7 +232,7 @@ done if (( $stripe_count > 0 )); then for ((i=0; i < $ndevs; i++)); do host=${host_names[$i]} - obd=$(remote_shell $host $lctl device_list | + obd=$(remote_shell $host $LCTL device_list | awk "{ if (\$2 == \"UP\" && (\$3 == \"osc\" || \$3 == \"osp\")) { print \$4 } }") @@ -335,7 +341,7 @@ for ((thr = $thrlo; thr <= $thrhi; thr*=2)); do tmpfi="${tmpf}_$idx" [ "$test" = "create" ] && test="create -c $stripe_count" echo >> ${cmdsf}_${host} \ - "$lctl > $tmpfi 2>&1 \ + "$LCTL > $tmpfi 2>&1 \ --threads $thr -$snap $devno test_$test \ -d /$dirname -D $dir_count \ -b $start_number -n $file_count_per_thread" diff --git a/lustre-iokit/obdfilter-survey/iokit-libecho b/lustre-iokit/obdfilter-survey/iokit-libecho index 8376388..62ec22a 100644 --- a/lustre-iokit/obdfilter-survey/iokit-libecho +++ b/lustre-iokit/obdfilter-survey/iokit-libecho @@ -153,7 +153,7 @@ get_devno () { local type=$2 local name=$3 - remote_shell $host $lctl device_list | + remote_shell $host $LCTL device_list | awk "{if (\$2 == \"UP\" && \$3 == \"$type\" && \$4 == \"$name\") {\ print \$1; exit}}" } @@ -178,18 +178,18 @@ get_devnos () { cleanup_network () { local clean_srv_OSS=$1 - $lctl <<-EOF + $LCTL <<-EOF --device echotmp cleanup --device echotmp detach EOF remote_shell "root@$server_nid" \ - "$lctl <<-EOF + "$LCTL <<-EOF --device echo_srv cleanup --device echo_srv detach EOF" if [ $clean_srv_OSS ]; then remote_shell "root@$server_nid" \ - "$lctl <<-EOF + "$LCTL <<-EOF --device OSS cleanup --device OSS detach EOF" @@ -279,9 +279,9 @@ get_ec_devno () { fi client_name=${ost_name}_ecc # Only 'attach' if '{client_name}_uuid' not already present - if ! [[ $(lctl dl) =~ $client_name ]]; then + if ! [[ $($LCTL dl) =~ $client_name ]]; then remote_shell $host \ - "$lctl <<-EOF + "$LCTL <<-EOF attach echo_client $client_name \ ${client_name}_UUID setup $ost_name $stack_type @@ -302,12 +302,12 @@ ec_using_srv_nid () { local oscname=$2 local oscuuid=$3 - $lctl add_uuid echo_UUID $server_nid@$NETTYPE >/dev/null 2>&1 - $lctl <<-EOF + $LCTL add_uuid echo_UUID $server_nid@$NETTYPE >/dev/null 2>&1 + $LCTL <<-EOF attach osc $oscname $oscuuid --device $oscname setup echo_srv_UUID echo_UUID EOF - $lctl <<-EOF + $LCTL <<-EOF attach echo_client ${oscname}_ecc $oscuuid --device ${oscname}_ecc setup $oscname EOF @@ -319,7 +319,7 @@ setup_srv_obd () { local test_ostfsnm=$2 remote_shell "root@$server_nid" \ - "$lctl <<-EOF + "$LCTL <<-EOF attach obdecho $test_ostfsnm ${test_ostfsnm}_UUID --device $test_ostfsnm setup EOF" @@ -330,7 +330,7 @@ setup_OSS () { local server_nid=$1 remote_shell "root@$server_nid" \ - "$lctl <<-EOF + "$LCTL <<-EOF attach ost OSS OSS_UUID --device OSS setup EOF" @@ -344,7 +344,7 @@ teardown_ec_devno () { local client_name=$2 remote_shell $host \ - "$lctl <<-EOF + "$LCTL <<-EOF --device $client_name cleanup --device $client_name detach EOF" @@ -369,7 +369,7 @@ split_hostname () { check_cleanup () { local type_obj="$1" - local osc_names_str=$($lctl dl | grep $type_obj) + local osc_names_str=$($LCTL dl | grep $type_obj) local count=0; for name in $osc_names_str; do @@ -385,7 +385,7 @@ check_cleanup () { check_setup () { local type_obj="$1" - local osc_names_str=$($lctl dl | grep $type_obj) + local osc_names_str=$($LCTL dl | grep $type_obj) local count=0; for name in $osc_names_str; do @@ -402,7 +402,7 @@ check_setup () { # added from bugzill req. get_targets () { if [ -z "$ost_names" ]; then - targets=$($lctl device_list | awk "{if (\$2 == \"UP\" && \ + targets=$($LCTL device_list | awk "{if (\$2 == \"UP\" && \ \$3 == \"obdfilter\") {print \$4} }") fi if [ -z "$targets" ]; then diff --git a/lustre-iokit/obdfilter-survey/obdfilter-survey b/lustre-iokit/obdfilter-survey/obdfilter-survey index 9170ef8..14ad4de 100755 --- a/lustre-iokit/obdfilter-survey/obdfilter-survey +++ b/lustre-iokit/obdfilter-survey/obdfilter-survey @@ -83,7 +83,7 @@ create_objects () { local nobj=$3 local rfile=$4 - remote_shell $host $lctl --device $devno create $nobj > $rfile 2>&1 + remote_shell $host $LCTL --device $devno create $nobj > $rfile 2>&1 first=0 prev=0 count=0 @@ -130,7 +130,7 @@ destroy_objects () { local nobj=$4 local rfile=$5 - remote_shell $host $lctl --device $devno destroy $obj0 $nobj > $rfile 2>&1 + remote_shell $host $LCTL --device $devno destroy $obj0 $nobj > $rfile 2>&1 } get_stats () { @@ -231,37 +231,11 @@ print_summary () { echo $minusn "$*" } -# Return a numeric version code based on a version string. The version -# code is useful for comparison two version strings to see which is newer. -version_code() { - # split arguments like "2.3.61" into "2", "3", "61" - eval set -- $(tr "[:punct:]" " " <<< $*) - echo -n "$((($1 << 16) | ($2 << 8) | $3))" -} - -# inspired from the lustre_build_version routine in test-framework.sh -get_lustre_version() { - local host=${1:-${unique_hosts[0]}} - local ver - - ver=$(remote_shell $host "$lctl get_param -n version 2>/dev/null || - $lctl lustre_build_version 2>/dev/null || - $lctl --version 2>/dev/null | cut -d' ' -f2") - local lver=$(egrep -i "lustre: |version: " <<<$ver | head -n 1) - [ -n "$lver" ] && ver="$lver" - - sed -e 's/.*: //' -e 's/^v//' -e 's/-.*//' -e 's/_/./g' <<<$ver | - cut -d. -f1-4 -} - # Check whether the record size (KBytes) exceeds the maximum bulk I/O RPC size # or not. check_record_size() { - [ $(version_code $(get_lustre_version)) -lt $(version_code 2.3.61) ] && - rszmax=1024 - if [ "$rszhi" -gt "$rszmax" ]; then - echo "Test disk case support maximum ${rszmax}KB IO data" \ + echo "Test disk case support maximum ${rszmax}KB IO data " \ "(rszhi=$rszhi is too big), please use a smaller value." return 1 fi @@ -337,11 +311,21 @@ if [ "$lustre_root" == " " ]; then unset lustre_root fi -if [ -z "$lustre_root" ]; then - lctl=${LCTL:-lctl} -else - lctl=${lustre_root}/utils/lctl +# find where 'lctl' binary is installed on this system +if [[ -x "$LCTL" ]]; then # full pathname specified + : # echo "LCTL=$LCTL" +elif [[ -n "$lustre_root" && -x "$lustre_root/utils/lctl" ]]; then + # echo "lustre_root=$lustre_root" + LCTL=${lustre_root}/utils/lctl +elif [[ -n "$LUSTRE" && -x "$LUSTRE/utils/lctl" ]]; then + # echo "LUSTRE=$LUSTRE" + LCTL=$LUSTRE/utils/lctl +else # hope that it is in the PATH + # echo "PATH=$PATH" + LCTL=${LCTL:-lctl} fi +echo "using LCTL='$LCTL' lustre_root='$lustre_root' LUSTRE='$LUSTRE'" +[[ -n "$(which $LCTL)" ]] || { echo "error: lctl not found"; exit 99; } # split out hostnames from client/ost names ndevs=0 @@ -368,22 +352,21 @@ if [ $case == "network" ]; then fi # Now do the server setup setup_srv_obd $server_nid "echo_srv" - oss_on_srv=$(dsh $server_nid root "$lctl dl | grep OSS" | - awk '{ print $4 }') + oss_on_srv=$(dsh $server_nid root "$LCTL dl" | awk '/OSS/ { print $4 }') if [ -z $oss_on_srv ]; then setup_OSS $server_nid clean_srv_OSS=1 fi - if ! dsh $server_nid root "$lctl dl | grep obdecho > /dev/null 2>&1"; then + if ! dsh $server_nid root "$LCTL dl | grep obdecho > /dev/null 2>&1"; then echo "obdecho not setup on server" exit 1 fi - if ! dsh $server_nid root "$lctl dl | grep ost > /dev/null 2>&1"; then + if ! dsh $server_nid root "$LCTL dl | grep ost > /dev/null 2>&1"; then echo "ost not setup on server" exit 1 fi # Now start client setup - osc_names_str=$($lctl dl| grep osc | grep -v mdt | grep UP || true) + osc_names_str=$($LCTL dl| grep osc | grep -v mdt | grep UP || true) if [ -n "$osc_names_str" ]; then echo "The existing setup must be cleaned"; exit 0; @@ -488,7 +471,7 @@ for ((rsz = $rszlo; rsz <= $rszhi; rsz*=2)); do declare -a pidarray for host in ${unique_hosts[@]}; do remote_shell $host \ - "lctl set_param -n osd*.*.force_sync 1 &>/dev/null || true" + "$LCTL set_param -n osd*.*.force_sync 1 &>/dev/null || true" echo "starting run for test: $test rsz: $rsz " \ "threads: $thr objects: $nobj" >> ${vmstatf}_${host} done @@ -505,7 +488,7 @@ for ((rsz = $rszlo; rsz <= $rszhi; rsz*=2)); do first_obj=${first_objs[$idx]} thr_per_obj=$((${thr}/${nobj})) echo >> ${cmdsf}_${host} \ - "$lctl > $tmpfi 2>&1 \\ + "$LCTL > $tmpfi 2>&1 \\ --threads $thr -$snap $devno \\ test_brw $count $(testname2type $test) q $pages \\ ${thr_per_obj}t${first_obj} $(testcase2mode)$pages &" diff --git a/lustre/tests/obdfilter-survey.sh b/lustre/tests/obdfilter-survey.sh index ad944a5..92e48a0 100644 --- a/lustre/tests/obdfilter-survey.sh +++ b/lustre/tests/obdfilter-survey.sh @@ -18,7 +18,15 @@ thrhi=${thrhi:-16} size=${size:-1024} thrlo=${thrlo:-$(( thrhi / 2))} -OBDSURVEY=${OBDSURVEY:-$(which obdfilter-survey)} +if [[ -x "$OBDSURVEY" ]]; then + echo "OBDSURVEY=$OBDSURVEY" +elif [[ -x $LUSTRE/../lustre-iokit/obdfilter-survey/obdfilter-survey ]]; then + echo "LUSTRE=$LUSTRE" + OBDSURVEY="$LUSTRE/../lustre-iokit/obdfilter-survey/obdfilter-survey" +else + OBDSURVEY=${OBDSURVEY:-$(which obdfilter-survey)} + echo "OBDSURVEY==$OBDSURVEY" +fi check_and_setup_lustre @@ -38,7 +46,8 @@ get_targets () { for osc in $($LCTL get_param -N osc.${FSNAME}-*osc-*); do nid=$($LCTL get_param $osc.import | - awk '/current_connection:/ {sub(/@.*/,""); print $2}') + awk '/current_connection:/ {sub(/@.*/,""); \ + sub(/"/,""); print $2}') dev=$(echo $osc | sed -e 's/^osc\.//' -e 's/-osc.*//') target=$dev @@ -72,7 +81,7 @@ obdflter_survey_run () { rm -f ${TMP}/obdfilter_survey* local targets=$(obdflter_survey_targets $case) - local cmd="NETTYPE=$NETTYPE thrlo=$thrlo nobjhi=$nobjhi thrhi=$thrhi size=$size case=$case rslt_loc=${TMP} targets=\"$targets\" $OBDSURVEY" + local cmd="NETTYPE=$NETTYPE LCTL=$LCTL thrlo=$thrlo nobjhi=$nobjhi thrhi=$thrhi size=$size case=$case rslt_loc=${TMP} targets=\"$targets\" $OBDSURVEY" echo + $cmd eval $cmd local rc=$? -- 1.8.3.1