Whamcloud - gitweb
LU-15474 test: facet_failover() should mount all facets concurrently
[fs/lustre-release.git] / lustre / tests / test-framework.sh
index fdd7b75..04f9599 100755 (executable)
@@ -433,6 +433,7 @@ init_test_env() {
        export LOV_MAX_STRIPE_COUNT=2000
        export DELETE_OLD_POOLS=${DELETE_OLD_POOLS:-false}
        export KEEP_POOLS=${KEEP_POOLS:-false}
+       export PARALLEL=${PARALLEL:-"no"}
 
        export MACHINEFILE=${MACHINEFILE:-$TMP/$(basename $0 .sh).machines}
        . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
@@ -1701,9 +1702,17 @@ set_hostid () {
 mount_facets () {
        local facets=${1:-$(get_facets)}
        local facet
+       local -a mountpids
+       local total=0
+       local ret=0
 
        for facet in ${facets//,/ }; do
-               mount_facet $facet
+               mount_facet $facet &
+               mountpids[total]=$!
+               total=$((total+1))
+       done
+       for ((index=0; index<$total; index++)); do
+               wait ${mountpids[index]}
                local RC=$?
                [ $RC -eq 0 ] && continue
 
@@ -1713,8 +1722,9 @@ mount_facets () {
                else
                        error "Restart of $facet failed!"
                fi
-               return $RC
+               ret=$RC
        done
+       return $ret
 }
 
 #
@@ -3604,8 +3614,10 @@ all_mds_up() {
        (( MDSCOUNT == 1 )) && return
 
        # wait so that statfs data on MDT expire
-       local delay=$(do_facet $SINGLEMDS lctl \
-               get_param -n osp.*MDT0000*MDT0001.maxage)
+       local delay=$(do_facet mds1 $LCTL \
+               get_param -n osp.*MDT*MDT0000.maxage | sort -n | tail -1)
+
+       [ -n "$delay" ] || error "fail to get maxage"
        sleep $delay
        local nodes=$(comma_list $(mdts_nodes))
        # initiate statfs RPC, all to all MDTs
@@ -3701,6 +3713,8 @@ facet_failover() {
        $E2FSCK_ON_MDT0 && (run_e2fsck $(facet_active_host $SINGLEMDS) \
                $(mdsdevname 1) "-n" || error "Running e2fsck")
 
+       local -a mountpids
+
        for ((index=0; index<$total; index++)); do
                facet=$(echo ${affecteds[index]} | tr -s " " | cut -d"," -f 1)
                echo reboot facets: ${affecteds[index]}
@@ -3721,11 +3735,17 @@ facet_failover() {
                        affecteds[index]=$(exclude_items_from_list \
                                ${affecteds[index]} mgs)
                fi
-               # FIXME; has to be changed to mount all facets concurrently
                if [ -n "${affecteds[index]}" ]; then
                        echo mount facets: ${affecteds[index]}
-                       mount_facets ${affecteds[index]}
+                       mount_facets ${affecteds[index]} &
+                       mountpids[index]=$!
                fi
+       done
+       for ((index=0; index<$total; index++)); do
+               if [ -n "${affecteds[index]}" ]; then
+                       wait ${mountpids[index]}
+               fi
+
                if $GSS_SK; then
                        do_nodes $(comma_list $(all_nodes)) \
                                "keyctl show | grep lustre | cut -c1-11 |
@@ -4732,14 +4752,11 @@ mkfs_opts() {
        opts+=${LDLM_TIMEOUT:+" --param=sys.ldlm_timeout=$LDLM_TIMEOUT"}
 
        if [ $type == MDS ]; then
-               opts+=${MDSCAPA:+" --param-mdt.capa=$MDSCAPA"}
                opts+=${DEF_STRIPE_SIZE:+" --param=lov.stripesize=$DEF_STRIPE_SIZE"}
                opts+=${DEF_STRIPE_COUNT:+" --param=lov.stripecount=$DEF_STRIPE_COUNT"}
                opts+=${L_GETIDENTITY:+" --param=mdt.identity_upcall=$L_GETIDENTITY"}
 
                if [ $fstype == ldiskfs ]; then
-                       fs_mkfs_opts+="-O ea_inode,large_dir"
-
                        var=${facet}_JRN
                        if [ -n "${!var}" ]; then
                                fs_mkfs_opts+=" -J device=${!var}"
@@ -4751,8 +4768,6 @@ mkfs_opts() {
        fi
 
        if [ $type == OST ]; then
-               opts+=${OSSCAPA:+" --param=ost.capa=$OSSCAPA"}
-
                if [ $fstype == ldiskfs ]; then
                        var=${facet}_JRN
                        if [ -n "${!var}" ]; then
@@ -7205,20 +7220,23 @@ init_clients_lists () {
     # Sanity check: exclude the dup entries
     RCLIENTS=$(for i in ${rclients//,/ }; do echo $i; done | sort -u)
 
-    clients="$SINGLECLIENT $HOSTNAME $RCLIENTS"
+       export CLIENT1=${CLIENT1:-$HOSTNAME}
+       export SINGLECLIENT=$CLIENT1
+
+       clients="$SINGLECLIENT $HOSTNAME $RCLIENTS"
 
     # Sanity check: exclude the dup entries from CLIENTS
     # for those configs which has SINGLCLIENT set to local client
     clients=$(for i in $clients; do echo $i; done | sort -u)
 
-    CLIENTS=$(comma_list $clients)
+       export CLIENTS=$(comma_list $clients)
     local -a remoteclients=($RCLIENTS)
     for ((i=0; $i<${#remoteclients[@]}; i++)); do
             varname=CLIENT$((i + 2))
-            eval $varname=${remoteclients[i]}
+                       eval export $varname=${remoteclients[i]}
     done
 
-    CLIENTCOUNT=$((${#remoteclients[@]} + 1))
+       export CLIENTCOUNT=$((${#remoteclients[@]} + 1))
 }
 
 get_random_entry () {
@@ -8681,36 +8699,34 @@ log_sub_test_end() {
 
 run_llverdev()
 {
-        local dev=$1
-        local llverdev_opts=$2
-        local devname=$(basename $1)
-        local size=$(grep "$devname"$ /proc/partitions | awk '{print $3}')
-        # loop devices aren't in /proc/partitions
-        [ "x$size" == "x" ] && local size=$(ls -l $dev | awk '{print $5}')
+       local dev=$1; shift
+       local llverdev_opts="$*"
+       local devname=$(basename $dev)
+       local size=$(awk "/$devname$/ {print \$3}" /proc/partitions)
+       # loop devices aren't in /proc/partitions
+       [[ -z "$size" ]] && size=$(stat -c %s $dev)
 
-        size=$(($size / 1024 / 1024)) # Gb
+       local size_gb=$((size / 1024 / 1024)) # Gb
 
-        local partial_arg=""
-        # Run in partial (fast) mode if the size
-        # of a partition > 1 GB
-        [ $size -gt 1 ] && partial_arg="-p"
+       local partial_arg=""
+       # Run in partial (fast) mode if the size of a partition > 1 GB
+       (( $size == 0 || $size_gb > 1 )) && partial_arg="-p"
 
-        llverdev --force $partial_arg $llverdev_opts $dev
+       llverdev --force $partial_arg $llverdev_opts $dev
 }
 
 run_llverfs()
 {
-        local dir=$1
-        local llverfs_opts=$2
-        local use_partial_arg=$3
-        local partial_arg=""
-        local size=$(df -B G $dir |tail -n 1 |awk '{print $2}' |sed 's/G//') #GB
+       local dir=$1
+       local llverfs_opts=$2
+       local use_partial_arg=$3
+       local partial_arg=""
+       local size=$(df -B G $dir |tail -n 1 |awk '{print $2}' |sed 's/G//') #GB
 
-        # Run in partial (fast) mode if the size
-        # of a partition > 1 GB
-        [ "x$use_partial_arg" != "xno" ] && [ $size -gt 1 ] && partial_arg="-p"
+       # Run in partial (fast) mode if the size of a partition > 1 GB
+       [ "x$use_partial_arg" != "xno" ] && [ $size -gt 1 ] && partial_arg="-p"
 
-        llverfs $partial_arg $llverfs_opts $dir
+       llverfs $partial_arg $llverfs_opts $dir
 }
 
 run_sgpdd () {