Whamcloud - gitweb
LU-5710 all: second batch of corrected typos and grammar errors
[fs/lustre-release.git] / lustre / tests / test-framework.sh
index bfdc9c2..381bacf 100755 (executable)
@@ -370,7 +370,7 @@ module_loaded () {
 
 # Load a module on the system where this is running.
 #
-# Synopsis: load_module module_name [module arguments for insmod/modprobe]
+# usage: load_module module_name [module arguments for insmod/modprobe]
 #
 # If module arguments are not given but MODOPTS_<MODULE> is set, then its value
 # will be used as the arguments.  Otherwise arguments will be obtained from
@@ -543,10 +543,10 @@ load_modules_local() {
        local mount_lustre=$LUSTRE/utils/mount.lustre
        if [ -f $mount_lustre ]; then
                local sbin_mount=/sbin/mount.lustre
-               if grep -qe "$sbin_mount " /proc/mounts; then
-                       cmp $mount_lustre $sbin_mount || umount $sbin_mount
+               if grep -qw "$sbin_mount" /proc/mounts; then
+                       cmp -s $mount_lustre $sbin_mount || umount $sbin_mount
                fi
-               if ! grep -qe "$sbin_mount " /proc/mounts; then
+               if ! grep -qw "$sbin_mount" /proc/mounts; then
                        [ ! -f "$sbin_mount" ] && touch "$sbin_mount"
                        if [ ! -s "$sbin_mount" -a -w "$sbin_mount" ]; then
                                cat <<- EOF > "$sbin_mount"
@@ -1193,6 +1193,12 @@ mount_facet() {
     else
         set_default_debug_facet $facet
 
+       if [[ $facet == mds* ]]; then
+               do_facet $facet \
+                       lctl set_param -n mdt.${FSNAME}*.enable_remote_dir=1 \
+                               2>/dev/null
+       fi
+
                label=$(devicelabel ${facet} ${!dev})
         [ -z "$label" ] && echo no label for ${!dev} && exit 1
         eval export ${facet}_svc=${label}
@@ -2064,6 +2070,8 @@ sync_all_data() {
 
 wait_delete_completed_mds() {
        local MAX_WAIT=${1:-20}
+       # for ZFS, waiting more time for DMUs to be committed
+       local ZFS_WAIT=${2:-5}
        local mds2sync=""
        local stime=$(date +%s)
        local etime
@@ -2099,6 +2107,14 @@ wait_delete_completed_mds() {
                if [[ $changes -eq 0 ]]; then
                        etime=$(date +%s)
                        #echo "delete took $((etime - stime)) seconds"
+
+                       # the occupied disk space will be released
+                       # only after DMUs are committed
+                       if [[ $(facet_fstype $SINGLEMDS) == zfs ]]; then
+                               echo "sleep $ZFS_WAIT for ZFS OSD"
+                               sleep $ZFS_WAIT
+                       fi
+
                        return
                fi
                sleep 1
@@ -2661,7 +2677,7 @@ hostlist_expand() {
     done
     myList="${myList%* }";
 
-    # We can select an object at a offset in the list
+    # We can select an object at an offset in the list
     [ $# -eq 2 ] && {
         cnt=0
         for item in $myList; do
@@ -3009,7 +3025,7 @@ ostvdevname() {
                        eval VDEVPTR="";;
                zfs )
                        #if $OSTDEVn isn't defined, default is $OSTDEVBASE{n}
-                       # Device formated by zfs
+                       # Device formatted by zfs
                        DEVNAME=OSTDEV$num
                        eval VDEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}};;
                * )
@@ -3019,7 +3035,7 @@ ostvdevname() {
        echo -n $VDEVPTR
 }
 
-# Logical device formated for lustre
+# Logical device formatted for lustre
 mdsdevname() {
        local num=$1
        local DEVNAME=MDSDEV$num
@@ -3053,7 +3069,7 @@ mdsvdevname() {
                        eval VDEVPTR="";;
                zfs )
                        # if $MDSDEVn isn't defined, default is $MDSDEVBASE{n}
-                       # Device formated by ZFS
+                       # Device formatted by ZFS
                        local DEVNAME=MDSDEV$num
                        eval VDEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}};;
                * )
@@ -3285,10 +3301,6 @@ mkfs_opts() {
        local fs_mkfs_opts
        local var
 
-       if [ $type == MGS ] && combined_mgs_mds; then
-               return 1
-       fi
-
        if [ $type == MGS ] || ( [ $type == MDS ] &&
                                  [ "$dev" == $(mgsdevname) ] &&
                                 [ "$host" == "$(facet_host mgs)" ] ); then
@@ -4638,7 +4650,7 @@ stop_full_debug_logging() {
 }
 
 # prints bash call stack
-log_trace_dump() {
+print_stack_trace() {
        echo "  Trace dump:"
        for (( i=1; i < ${#BASH_LINENO[*]} ; i++ )) ; do
                local s=${BASH_SOURCE[$i]}
@@ -4664,7 +4676,7 @@ error_noexit() {
 
 
        log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
-       log_trace_dump
+       print_stack_trace >&2
 
        mkdir -p $LOGDIR
        # We need to dump the logs on all nodes
@@ -4850,7 +4862,7 @@ run_test() {
 }
 
 log() {
-    echo "$*"
+       echo "$*" >&2
     module_loaded lnet || load_modules
 
     local MSG="$*"
@@ -5656,27 +5668,6 @@ fi;
 exit \\\$rc"
 }
 
-# CMD: determine mds index where directory inode presents
-get_mds_dir() {
-    local dir=$1
-    local SEQ
-
-    SEQ=$(lfs path2fid $dir | tr '[:]' ' '|cut -f2 -d ' ')
-    if [ "$SEQ" == "" ]; then
-       error "can't get sequence for $dir"
-       return 1
-    fi
-    export SEQ
-
-    do_facet mds1 "cat /proc/fs/lustre/fld/srv-*-MDT0000/fldb" | \
-       tr '[)]:-' ' ' |                                \
-       while read SS EE IDX TYP; do                    \
-               if let "SEQ >= SS && SEQ < EE"; then    \
-                       echo $IDX;                      \
-               fi;                                     \
-       done
-}
-
 mdsrate_cleanup () {
        if [ -d $4 ]; then
                mpi_run ${MACHINEFILE_OPTION} $2 -np $1 ${MDSRATE} --unlink \
@@ -6897,62 +6888,46 @@ generate_logname() {
 
 # make directory on different MDTs
 test_mkdir() {
-       local option
-       local parent
-       local child
        local path
        local p_option
-       local option2
        local stripe_count=2
-       local rc=0
-
-       case $# in
-               1) path=$1;;
-               2) option=$1
-                  path=$2;;
-               3) option=$1
-                  option2=$2
-                  path=$3;;
-               *) error "Only creating single directory is supported";;
-       esac
-
-       child=$(basename $path)
-       parent=$(dirname $path)
-
-       if [ "$option" == "-p" -o "$option2" == "-p" ]; then
-               if [ -d $parent/$child ]; then
-                       return $rc
-               fi
-               p_option="-p"
-       fi
+       local stripe_index=-1
+       local OPTIND=1
+
+       while getopts "c:i:p" opt; do
+               case $opt in
+                       c) stripe_count=$OPTARG;;
+                       i) stripe_index=$OPTARG;;
+                       p) p_option="-p";;
+                       \?) error "only support -i -c -p";;
+               esac
+       done
 
-       if [ "${option:0:2}" == "-c" ]; then
-               stripe_count=$(echo $option | sed 's/^-c//')
-       fi
+       shift $((OPTIND - 1))
+       [ $# -eq 1 ] || error "Only creating single directory is supported"
+       path="$*"
 
-       if [ "${option2:0:2}" == "-c" ]; then
-               stripe_count=$(echo $option2 | sed 's/^-c//')
-       fi
+       if [ "$p_option" == "-p" ]; then
+               local parent=$(dirname $path)
 
-       if [ ! -d ${parent} ]; then
-               if [ "$p_option" == "-p" ]; then
-                       mkdir -p ${parent}
-               else
-                       return 1
-               fi
+               [ -d $path ] && return 0
+               [ ! -d ${parent} ] && mkdir -p ${parent}
        fi
 
        if [ $MDSCOUNT -le 1 ]; then
-               mkdir $p_option $parent/$child || rc=$?
+               mkdir $path
        else
-               local mdt_idx=$($LFS getstripe -M $parent)
                local test_num=$(echo $testnum | sed -e 's/[^0-9]*//g')
+               local mdt_index
 
-               mdt_idx=$((test_num % MDSCOUNT))
-               echo "striped dir -i$mdt_idx -c$stripe_count $path"
-               $LFS setdirstripe -i$mdt_idx -c$stripe_count $path || rc=$?
+               if [ $stripe_index -eq -1 ]; then
+                       mdt_index=$((test_num % MDSCOUNT))
+               else
+                       mdt_index=$stripe_index
+               fi
+               echo "striped dir -i$mdt_index -c$stripe_count $path"
+               $LFS setdirstripe -i$mdt_index -c$stripe_count $path
        fi
-       return $rc
 }
 
 # find the smallest and not in use file descriptor
@@ -6987,11 +6962,10 @@ precreated_ost_obj_count()
        local mdt_name="MDT$(printf '%04x' $mdt_idx)"
        local ost_name="OST$(printf '%04x' $ost_idx)"
        local proc_path="${FSNAME}-${ost_name}-osc-${mdt_name}"
-       local last_id=$(do_facet mds${mdt_idx} lctl get_param -n \
+       local last_id=$(do_facet mds$((mdt_idx + 1)) lctl get_param -n \
                        osp.$proc_path.prealloc_last_id)
-       local next_id=$(do_facet mds${mdt_idx} lctl get_param -n \
+       local next_id=$(do_facet mds$((mdt_idx + 1)) lctl get_param -n \
                        osp.$proc_path.prealloc_next_id)
-
        echo $((last_id - next_id + 1))
 }