From: Arshad Hussain Date: Tue, 9 Jan 2024 06:12:57 +0000 (+0530) Subject: LU-16861 obdfilter: Exclude quotes when getting NIDs X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=4bb2b0bf34ed408f42dd6401d18c8d1255d6e91f;p=fs%2Flustre-release.git 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. Lustre-change: https://review.whamcloud.com/53620 Lustre-commit: c265e1c7b045bf1f9e5b2919c282b63086929ab6 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-by: James Simmons Reviewed-by: Andreas Dilger Reviewed-by: Alex Deiter Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/55090 Tested-by: jenkins Tested-by: Maloo --- 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 8e91f6f..bffd072 100644 --- a/lustre-iokit/obdfilter-survey/iokit-libecho +++ b/lustre-iokit/obdfilter-survey/iokit-libecho @@ -154,7 +154,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}}" } @@ -179,18 +179,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,11 +279,15 @@ get_ec_devno () { exit 1 fi client_name=${ost_name}_ecc - remote_shell $host \ - "$lctl <<-EOF - attach echo_client $client_name ${client_name}_UUID - setup $ost_name $stack_type - EOF" + # Only 'attach' if '{client_name}_uuid' not already present + if ! [[ $($LCTL dl) =~ $client_name ]]; then + remote_shell $host \ + "$LCTL <<-EOF + attach echo_client $client_name \ + ${client_name}_UUID + setup $ost_name $stack_type + EOF" + fi ec=$(get_devno $host echo_client $client_name) if [ -z "$ec" ]; then echo "Can't setup echo-client" @@ -299,12 +303,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 @@ -316,7 +320,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" @@ -327,7 +331,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" @@ -341,7 +345,7 @@ teardown_ec_devno () { local client_name=$2 remote_shell $host \ - "$lctl <<-EOF + "$LCTL <<-EOF --device $client_name cleanup --device $client_name detach EOF" @@ -366,7 +370,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 @@ -382,7 +386,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 @@ -399,7 +403,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 984b17d..41d98a8 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=$?