Whamcloud - gitweb
LU-196 set debug_mb size for every node
[fs/lustre-release.git] / lustre / tests / test-framework.sh
index ecf4ef8..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
@@ -120,6 +124,10 @@ init_test_env() {
 
     export LFSCK_ALWAYS=${LFSCK_ALWAYS:-"no"} # check fs after each test suite
     export FSCK_MAX_ERR=4   # File system errors left uncorrected
+
+    # 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}
@@ -364,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
 }
 
@@ -417,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
 
@@ -551,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)}
@@ -575,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
@@ -731,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
 }
@@ -850,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
 }
@@ -2361,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
@@ -3564,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
@@ -3708,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 () {