Whamcloud - gitweb
LU-2213 scrub: stop LFSCK before osd_shutdown
[fs/lustre-release.git] / lustre / tests / test-framework.sh
index 02890af..3e714e3 100644 (file)
@@ -1155,10 +1155,6 @@ setup_quota(){
                return
        fi
 
-       # XXX remove it once all quota code landed
-       echo "skip quota setup"
-       return
-
        local mntpt=$1
 
        # save old quota type & set new quota type
@@ -1725,15 +1721,16 @@ cleanup_check() {
 
     check_mem_leak || exit 204
 
-    [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
-        echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
+       [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl &&
+               echo "$TESTSUITE: lustre didn't clean up..." 1>&2 &&
+               return 202 || true
 
-    if module_loaded lnet || module_loaded libcfs; then
-        echo "$0: modules still loaded..." 1>&2
-        /sbin/lsmod 1>&2
-        return 203
-    fi
-    return 0
+       if module_loaded lnet || module_loaded libcfs; then
+               echo "$TESTSUITE: modules still loaded..." 1>&2
+               /sbin/lsmod 1>&2
+               return 203
+       fi
+       return 0
 }
 
 wait_update () {
@@ -2787,8 +2784,6 @@ mkfs_opts() {
                opts+=${L_GETIDENTITY:+" --param=mdt.identity_upcall=$L_GETIDENTITY"}
 
                if [ $fstype == ldiskfs ]; then
-                       opts+=${IAMDIR:+" --iam-dir"}
-
                        fs_mkfs_opts+=${MDSJOURNALSIZE:+" -J size=$MDSJOURNALSIZE"}
                        fs_mkfs_opts+=${MDSISIZE:+" -i $MDSISIZE"}
                fi
@@ -3006,45 +3001,70 @@ mounted_lustre_filesystems() {
 }
 
 init_facet_vars () {
-    [ "$CLIENTONLY" ] && return 0
-    local facet=$1
-    shift
-    local device=$1
+       [ "$CLIENTONLY" ] && return 0
+       local facet=$1
+       shift
+       local device=$1
 
-    shift
+       shift
 
-    eval export ${facet}_dev=${device}
-    eval export ${facet}_opt=\"$@\"
+       eval export ${facet}_dev=${device}
+       eval export ${facet}_opt=\"$@\"
 
-    local dev=${facet}_dev
-       local label=$(devicelabel ${facet} ${!dev})
-    [ -z "$label" ] && echo no label for ${!dev} && exit 1
+       local dev=${facet}_dev
 
-    eval export ${facet}_svc=${label}
+       # We need to loop for the label
+       # in case its not initialized yet.
+       for wait_time in {0,1,3,5,10}; do
 
-    local varname=${facet}failover_HOST
-    if [ -z "${!varname}" ]; then
-       eval $varname=$(facet_host $facet) 
-    fi
+               if [ $wait_time -gt 0 ]; then
+                       echo "${!dev} not yet initialized,"\
+                               "waiting ${wait_time} seconds."
+                       sleep $wait_time
+               fi
 
-    # ${facet}failover_dev is set in cfg file
-    varname=${facet}failover_dev
-    if [ -n "${!varname}" ] ; then
-        eval export ${facet}failover_dev=${!varname}
-    else
-        eval export ${facet}failover_dev=$device
-    fi
+               local label=$(devicelabel ${facet} ${!dev})
 
-    # get mount point of already mounted device
-    # is facet_dev is already mounted then use the real
-    #  mount point of this facet; otherwise use $(facet_mntpt $facet)
-    # i.e. ${facet}_MOUNT if specified by user or default
-    local mntpt=$(do_facet ${facet} cat /proc/mounts | \
-            awk '"'${!dev}'" == $1 && $3 == "lustre" { print $2 }')
-    if [ -z $mntpt ]; then
-        mntpt=$(facet_mntpt $facet)
-    fi
-    eval export ${facet}_MOUNT=$mntpt
+               # Check to make sure the label does
+               # not include ffff at the end of the label.
+               # This indicates it has not been initialized yet.
+
+               if [[ $label =~ [f|F]{4}$ ]]; then
+                       # label is not initialized, unset the result
+                       # and either try again or fail
+                       unset label
+               else
+                       break
+               fi
+       done
+
+       [ -z "$label" ] && echo no label for ${!dev} && exit 1
+
+       eval export ${facet}_svc=${label}
+
+       local varname=${facet}failover_HOST
+       if [ -z "${!varname}" ]; then
+               eval $varname=$(facet_host $facet)
+       fi
+
+       # ${facet}failover_dev is set in cfg file
+       varname=${facet}failover_dev
+       if [ -n "${!varname}" ] ; then
+               eval export ${facet}failover_dev=${!varname}
+       else
+               eval export ${facet}failover_dev=$device
+       fi
+
+       # get mount point of already mounted device
+       # is facet_dev is already mounted then use the real
+       #  mount point of this facet; otherwise use $(facet_mntpt $facet)
+       # i.e. ${facet}_MOUNT if specified by user or default
+       local mntpt=$(do_facet ${facet} cat /proc/mounts | \
+                       awk '"'${!dev}'" == $1 && $3 == "lustre" { print $2 }')
+       if [ -z $mntpt ]; then
+               mntpt=$(facet_mntpt $facet)
+       fi
+       eval export ${facet}_MOUNT=$mntpt
 }
 
 init_facets_vars () {
@@ -3700,7 +3720,7 @@ pause_bulk() {
 }
 
 drop_ldlm_cancel() {
-#define OBD_FAIL_LDLM_CANCEL             0x304
+#define OBD_FAIL_LDLM_CANCEL_NET                       0x304
        local RC=0
        local list=$(comma_list $(mdts_nodes) $(osts_nodes))
        do_nodes $list lctl set_param fail_loc=0x304
@@ -3712,7 +3732,7 @@ drop_ldlm_cancel() {
 }
 
 drop_bl_callback() {
-#define OBD_FAIL_LDLM_BL_CALLBACK        0x305
+#define OBD_FAIL_LDLM_BL_CALLBACK_NET                  0x305
     RC=0
     do_facet client lctl set_param fail_loc=0x305
     do_facet client "$@" || RC=$?
@@ -3849,9 +3869,10 @@ error_noexit() {
         gather_logs $(comma_list $(nodes_list))
     fi
 
-    debugrestore
-    [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
-    echo "$@" > $LOGDIR/err
+       debugrestore
+       [ "$TESTSUITELOG" ] &&
+               echo "$TESTSUITE: $TYPE: $TESTNAME $@" >> $TESTSUITELOG
+       echo "$@" > $LOGDIR/err
 }
 
 exit_status () {
@@ -4011,10 +4032,6 @@ run_test() {
     return $?
 }
 
-equals_msg() {
-    banner "$*"
-}
-
 log() {
     echo "$*"
     module_loaded lnet || load_modules
@@ -4041,9 +4058,11 @@ trace() {
 }
 
 complete () {
-    equals_msg $1 test complete, duration $2 sec
+    local duration=$1
+
+    banner test complete, duration $duration sec
     [ -f "$TESTSUITELOG" ] && egrep .FAIL $TESTSUITELOG || true
-    echo duration $2 >>$TESTSUITELOG
+    echo duration $duration >>$TESTSUITELOG
 }
 
 pass() {
@@ -5721,6 +5740,7 @@ mds_backup_restore() {
        local metaea=${TMP}/backup_restore.ea
        local metadata=${TMP}/backup_restore.tgz
        local opts=${MDS_MOUNT_OPTS}
+       local svc=${SINGLEMDS}_svc
 
        if ! ${rcmd} test -b ${devname}; then
                opts=$(csa_add "$opts" -o loop)
@@ -5764,6 +5784,8 @@ mds_backup_restore() {
        ${rcmd} umount -d $mntpt || return 10
        # step 14: cleanup tmp backup
        ${rcmd} rm -f $metaea $metadata
+       # step 15: reset device label - it's not virgin on
+       ${rcmd} e2label $devname ${!svc}
 }
 
 # remove OI files