Whamcloud - gitweb
LU-196 set debug_mb size for every node
[fs/lustre-release.git] / lustre / tests / test-framework.sh
index d917813..40912c3 100644 (file)
@@ -16,6 +16,10 @@ export GSS_PIPEFS=false
 export IDENTITY_UPCALL=default
 export QUOTA_AUTO=1
 
+# LOAD_LLOOP: LU-409: only load llite_lloop module if kernel < 2.6.32 or
+#             LOAD_LLOOP is true. LOAD_LLOOP is false by default.
+export LOAD_LLOOP=${LOAD_LLOOP:-false}
+
 #export PDSH="pdsh -S -Rssh -w"
 
 # function used by scripts run on remote nodes
@@ -117,21 +121,17 @@ init_test_env() {
     export DUMPE2FS=${DUMPE2FS:-dumpe2fs}
     export E2FSCK=${E2FSCK:-e2fsck}
     export LFSCK_BIN=${LFSCK_BIN:-lfsck}
-    export LFSCK_ALWAYS=${LFSCK_ALWAYS:-"no"} # check filesystem after each test suit
-    export SKIP_LFSCK=${SKIP_LFSCK:-"yes"} # bug 13698, change to "no" when fixed
-    export SHARED_DIRECTORY=${SHARED_DIRECTORY:-"/tmp"}
+
+    export LFSCK_ALWAYS=${LFSCK_ALWAYS:-"no"} # check fs after each test suite
     export FSCK_MAX_ERR=4   # File system errors left uncorrected
-    if [ "$SKIP_LFSCK" == "no" ]; then
-        if [ ! -x `which $LFSCK_BIN` ]; then
-            log "$($E2FSCK -V)"
-            error_exit "$E2FSCK does not support lfsck"
-        fi
 
-        export MDSDB=${MDSDB:-$SHARED_DIRECTORY/mdsdb}
-        export OSTDB=${OSTDB:-$SHARED_DIRECTORY/ostdb}
-        export MDSDB_OPT="--mdsdb $MDSDB"
-        export OSTDB_OPT="--ostdb $OSTDB-\$ostidx"
-    fi
+    # This is used by a small number of tests to share state between the client
+    # running the tests, or in some cases between the servers (e.g. lfsck.sh).
+    # It needs to be a non-lustre filesystem that is available on all the nodes.
+    export SHARED_DIRECTORY=${SHARED_DIRECTORY:-"/tmp"}
+    export MDSDB=${MDSDB:-$SHARED_DIRECTORY/mdsdb}
+    export OSTDB=${OSTDB:-$SHARED_DIRECTORY/ostdb}
+
     #[ -d /r ] && export ROOT=${ROOT:-/r}
     export TMP=${TMP:-$ROOT/tmp}
     export TESTSUITELOG=${TMP}/${TESTSUITE}.log
@@ -372,17 +372,31 @@ load_modules_local() {
         load_module obdfilter/obdfilter
     fi
 
+    load_module_llite_lloop() {
+        local n1=$(uname -r | cut -d. -f1)
+        local n2=$(uname -r | cut -d. -f2)
+        local n3=$(uname -r | cut -d- -f1 | cut -d. -f3)
+
+    # load the llite_lloop module for < 2.6.32 kernels
+        if [[ $n1 -lt 2 ]] || [[ $n1 -eq 2 && $n2 -lt 6 ]] || \
+            [[ $n1 -eq 2 && $n2 -eq 6 && $n3 -lt 32 ]] || \
+            $LOAD_LLOOP; then
+                load_module llite/llite_lloop
+        fi
+    }
+
     load_module llite/lustre
-    load_module llite/llite_lloop
+    load_module_llite_lloop
     [ -d /r ] && OGDB=${OGDB:-"/r/tmp"}
     OGDB=${OGDB:-$TMP}
     rm -f $OGDB/ogdb-$HOSTNAME
     $LCTL modules > $OGDB/ogdb-$HOSTNAME
 
     # 'mount' doesn't look in $PATH, just sbin
-    local bindmount=$(mount | grep "/sbin/mount.lustre")
-    if [ -f $LUSTRE/utils/mount.lustre ] && [ "x$bindmount" == "x" ]; then
-           mount --bind $LUSTRE/utils/mount.lustre /sbin/mount.lustre || true
+    if [ -f $LUSTRE/utils/mount.lustre ] && \
+       ! grep -qe "/sbin/mount\.lustre " /proc/mounts; then
+        [ ! -f /sbin/mount.lustre ] && touch /sbin/mount.lustre
+        mount --bind $LUSTRE/utils/mount.lustre /sbin/mount.lustre || true
     fi
 }
 
@@ -425,7 +439,11 @@ unload_modules() {
         fi
     fi
 
-    umount /sbin/mount.lustre
+    if grep -qe "/sbin/mount\.lustre" /proc/mounts; then
+        umount /sbin/mount.lustre || true
+        [ -w /sbin/mount.lustre -a ! -s /sbin/mount.lustre ] && \
+            rm -f /sbin/mount.lustre || true
+    fi
 
     check_mem_leak || return 254
 
@@ -559,6 +577,50 @@ ostdevlabel() {
     echo -n $label
 }
 
+set_debug_size () {
+    local dz=${1:-$DEBUG_SIZE}
+    local cpus=$(getconf _NPROCESSORS_CONF)
+
+    # bug 19944, adjust size to be -gt num_possible_cpus()
+    # promise 2MB for every cpu at least
+    if [ -n "$cpus" ] && [ $((cpus * 2)) -gt $dz ]; then
+        dz=$((cpus * 2))
+    fi
+    lctl set_param debug_mb=$dz
+}
+
+set_default_debug () {
+    local debug=${1:-"$PTLDEBUG"}
+    local subsystem_debug=${2:-"$SUBSYSTEM"}
+    local debug_size=${3:-$DEBUG_SIZE}
+
+    lctl set_param debug="$debug"
+    lctl set_param subsystem_debug="${subsystem_debug# }"
+
+    set_debug_size $debug_size
+    sync
+}
+
+set_default_debug_nodes () {
+    local nodes=$1
+
+    if [[ ,$nodes, = *,$HOSTNAME,* ]]; then
+       nodes=$(exclude_items_from_list "$nodes" "$HOSTNAME")
+       set_default_debug
+    fi
+
+    [[ -n $nodes ]] && do_rpc_nodes $nodes set_default_debug \
+       \\\"$PTLDEBUG\\\" \\\"$SUBSYSTEM\\\" $DEBUG_SIZE || true
+}
+
+set_default_debug_facet () {
+    local facet=$1
+    local node=$(facet_active_host $facet)
+    [ -z "$node" ] && echo "No host defined for facet $facet" && exit 1
+
+    set_default_debug_nodes $node
+}
+
 # Facet functions
 mount_facets () {
     local facets=${1:-$(get_facets)}
@@ -583,10 +645,7 @@ mount_facet() {
         echo "mount -t lustre $@ ${!dev} $mntpt"
         echo "Start of ${!dev} on ${facet} failed ${RC}"
     else
-        do_facet ${facet} "lctl set_param debug=\\\"$PTLDEBUG\\\"; \
-            lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\"; \
-            lctl set_param debug_mb=${DEBUG_SIZE}; \
-            sync"
+        set_default_debug_facet $facet
 
         label=$(do_facet ${facet} "$E2LABEL ${!dev}")
         [ -z "$label" ] && echo no label for ${!dev} && exit 1
@@ -739,9 +798,7 @@ zconf_mount() {
     do_node $client mkdir -p $mnt
     do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
 
-    do_node $client "lctl set_param debug=\\\"$PTLDEBUG\\\";
-        lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
-        lctl set_param debug_mb=${DEBUG_SIZE}"
+    set_default_debug_nodes $client
 
     return 0
 }
@@ -858,9 +915,7 @@ exit \\\$rc" || return ${PIPESTATUS[0]}
     echo "Started clients $clients: "
     do_nodes $clients "mount | grep -w $mnt"
 
-    do_nodes $clients "lctl set_param debug=\\\"$PTLDEBUG\\\";
-        lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
-        lctl set_param debug_mb=${DEBUG_SIZE};"
+    set_default_debug_nodes $clients
 
     return 0
 }
@@ -2369,10 +2424,7 @@ check_and_setup_lustre() {
         init_facets_vars
         init_param_vars
 
-        do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=\\\"$PTLDEBUG\\\";
-            lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
-            lctl set_param debug_mb=${DEBUG_SIZE};
-            sync"
+        set_default_debug_nodes $(comma_list $(nodes_list))
     fi
 
     init_gss
@@ -2451,11 +2503,10 @@ get_svr_devs() {
 run_e2fsck() {
     local node=$1
     local target_dev=$2
-    local ostidx=$3
-    local ostdb_opt=$4
+    local extra_opts=$3
 
     df > /dev/null      # update statfs data on disk
-    local cmd="$E2FSCK -d -v -f -n $MDSDB_OPT $ostdb_opt $target_dev"
+    local cmd="$E2FSCK -d -v -t -t -f -n $extra_opts $target_dev"
     echo $cmd
     local rc=0
     do_node $node $cmd || rc=$?
@@ -2483,15 +2534,14 @@ generate_db() {
         error "$SHARED_DIRECTORY is not a shared directory"
     rm $tmp_file
 
-    run_e2fsck $(mdts_nodes) $MDTDEV
+    run_e2fsck $(mdts_nodes) $MDTDEV "--mdsdb $MDSDB"
 
     i=0
     ostidx=0
     OSTDB_LIST=""
     for node in $(osts_nodes); do
         for dev in ${OSTDEVS[i]}; do
-            local ostdb_opt=`eval echo $OSTDB_OPT`
-            run_e2fsck $node $dev $ostidx "$ostdb_opt"
+            run_e2fsck $node $dev "--mdsdb $MDSDB --ostdb $OSTDB-$ostidx"
             OSTDB_LIST="$OSTDB_LIST $OSTDB-$ostidx"
             ostidx=$((ostidx + 1))
         done
@@ -2513,14 +2563,10 @@ run_lfsck() {
 }
 
 check_and_cleanup_lustre() {
-    if [ "$LFSCK_ALWAYS" = "yes" ]; then
+    if [ "$LFSCK_ALWAYS" = "yes" -a "$TESTSUITE" != "lfsck" ]; then
         get_svr_devs
         generate_db
-        if [ "$SKIP_LFSCK" == "no" ]; then
-            run_lfsck
-        else
-            echo "skip lfsck"
-        fi
+        run_lfsck
     fi
 
     if is_mounted $MOUNT; then
@@ -3578,7 +3624,8 @@ inodes_available () {
 }
 
 mdsrate_inodes_available () {
-    echo $(($(inodes_available) - 1))
+    local min_inodes=$(inodes_available)
+    echo $((min_inodes * 99 / 100))
 }
 
 # reset llite stat counters
@@ -3722,7 +3769,8 @@ convert_facet2label() {
 get_clientosc_proc_path() {
     local ost=$1
 
-    echo "${1}-osc-*"
+    # exclude -osc-M*
+    echo "${1}-osc-[!M]*"
 }
 
 get_lustre_version () {