# 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
[ $# -gt 0 ] && echo "${module} options: '$*'"
- # Note that insmod will ignore anything in modprobe.conf, which is why we're
- # passing options on the command-line.
- if [ "$BASE" == "lnet_selftest" ] && \
- [ -f ${LUSTRE}/../lnet/selftest/${module}${EXT} ]; then
- insmod ${LUSTRE}/../lnet/selftest/${module}${EXT}
- elif [ -f ${LUSTRE}/${module}${EXT} ]; then
- insmod ${LUSTRE}/${module}${EXT} "$@"
- else
- # must be testing a "make install" or "rpm" installation
- # note failed to load ptlrpc_gss is considered not fatal
- if [ "$BASE" == "ptlrpc_gss" ]; then
- modprobe $BASE "$@" 2>/dev/null || echo "gss/krb5 is not supported"
- else
- modprobe $BASE "$@"
- fi
- fi
+ # Note that insmod will ignore anything in modprobe.conf, which is why
+ # we're passing options on the command-line.
+ if [[ "$BASE" == "lnet_selftest" ]] &&
+ [[ -f ${LUSTRE}/../lnet/selftest/${module}${EXT} ]]; then
+ insmod ${LUSTRE}/../lnet/selftest/${module}${EXT}
+ elif [[ -f ${LUSTRE}/${module}${EXT} ]]; then
+ [[ "$BASE" != "ptlrpc_gss" ]] || modprobe sunrpc
+ insmod ${LUSTRE}/${module}${EXT} "$@"
+ else
+ # must be testing a "make install" or "rpm" installation
+ # note failed to load ptlrpc_gss is considered not fatal
+ if [[ "$BASE" == "ptlrpc_gss" ]]; then
+ modprobe $BASE "$@" 2>/dev/null ||
+ echo "gss/krb5 is not supported"
+ else
+ modprobe $BASE "$@"
+ fi
+ fi
}
llite_lloop_enabled() {
load_module ../ldiskfs/ldiskfs
load_module osd-ldiskfs/osd_ldiskfs
fi
- load_module nodemap/nodemap
load_module mgs/mgs
load_module mdd/mdd
load_module mdt/mdt
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
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
return $rc
}
+dump_file_contents() {
+ local nodes=$1
+ local dir=$2
+ local logname=$3
+ local node
+
+ if [ -z "$nodes" -o -z "$dir" -o -z "$logname" ]; then
+ error_noexit false \
+ "Invalid parameters for dump_file_contents()"
+ return 1
+ fi
+ for node in ${nodes}; do
+ do_node $node "for i in \\\$(find $dir -type f); do
+ echo ====\\\${i}=======================;
+ cat \\\${i};
+ done" >> ${logname}.${node}.log
+ done
+}
+
+dump_command_output() {
+ local nodes=$1
+ local cmd=$2
+ local logname=$3
+ local node
+
+ if [ -z "$nodes" -o -z "$cmd" -o -z "$logname" ]; then
+ error_noexit false \
+ "Invalid parameters for dump_command_output()"
+ return 1
+ fi
+
+ for node in ${nodes}; do
+ do_node $node "echo ====${cmd}=======================;
+ $cmd" >> ${logname}.${node}.log
+ done
+}
+
+log_zfs_info() {
+ local logname=$1
+
+ # dump file contents from /proc/spl in case of zfs test
+ if [ "$(facet_fstype ost1)" = "zfs" ]; then
+ dump_file_contents "$(osts_nodes)" "/proc/spl" "${logname}"
+ dump_command_output \
+ "$(osts_nodes)" "zpool events -v" "${logname}"
+ fi
+
+ if [ "$(facet_fstype $SINGLEMDS)" = "zfs" ]; then
+ dump_file_contents "$(mdts_nodes)" "/proc/spl" "${logname}"
+ dump_command_output \
+ "$(mdts_nodes)" "zpool events -v" "${logname}"
+ fi
+}
+
check_and_cleanup_lustre() {
if [ "$LFSCK_ALWAYS" = "yes" -a "$TESTSUITE" != "lfsck" ]; then
get_svr_devs
}
drop_bl_callback_once() {
- rc=0
+ local rc=0
do_facet client lctl set_param ldlm.namespaces.*.early_lock_cancel=0
#define OBD_FAIL_LDLM_BL_CALLBACK_NET 0x305
do_facet client lctl set_param fail_loc=0x80000305
do_facet client "$@" || rc=$?
do_facet client lctl set_param fail_loc=0
+ do_facet client lctl set_param fail_val=0
do_facet client lctl set_param ldlm.namespaces.*.early_lock_cancel=1
return $rc
}
do_facet client lctl set_param fail_loc=0x305
do_facet client "$@" || rc=$?
do_facet client lctl set_param fail_loc=0
+ do_facet client lctl set_param fail_val=0
do_facet client lctl set_param ldlm.namespaces.*.early_lock_cancel=1
return $rc
}
}
# 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]}
log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
- log_trace_dump
+ print_stack_trace >&2
mkdir -p $LOGDIR
# We need to dump the logs on all nodes
}
log() {
- echo "$*"
+ echo "$*" >&2
module_loaded lnet || load_modules
local MSG="$*"
local TEST_ERROR
local name=${TESTSUITE}.test_${1}.test_log.$(hostname -s).log
local test_log=$LOGDIR/$name
+ local zfs_log_name=${TESTSUITE}.test_${1}.zfs_log
+ local zfs_debug_log=$LOGDIR/$zfs_log_name
rm -rf $LOGDIR/err
rm -rf $LOGDIR/ignore
rm -rf $LOGDIR/skip
fi
if [ -f $LOGDIR/err ]; then
+ log_zfs_info "$zfs_debug_log"
$FAIL_ON_ERROR && exit $RC
fi
}
check_catastrophe() {
- local rnodes=${1:-$(comma_list $(remote_nodes_list))}
- VAR=$(lctl get_param -n catastrophe 2>&1)
- if [ $? = 0 ] ; then
- if [ $VAR != 0 ]; then
- return 1
- fi
- fi
-
- [ -z "$rnodes" ] && return 0
+ local nodes=${1:-$(comma_list $(nodes_list))}
- local data
- data=$(do_nodes "$rnodes" "rc=\\\$(lctl get_param -n catastrophe);
- if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
- exit \\\$rc")
- local rc=$?
- if [ -n "$data" ]; then
- echo $data
- return $rc
- fi
- return 0
-}
-
-# CMD: determine mds index where directory inode presents
-get_mds_dir () {
- local dir=$1
- local file=$dir/f0.get_mds_dir_tmpfile
-
- mkdir -p $dir
- rm -f $file
- sleep 1
- local iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
- local -a oldused=($iused)
-
- openfile -f O_CREAT:O_LOV_DELAY_CREATE -m 0644 $file > /dev/null
- sleep 1
- iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
- local -a newused=($iused)
-
- local num=0
- for ((i=0; i<${#newused[@]}; i++)); do
- if [ ${oldused[$i]} -lt ${newused[$i]} ]; then
- echo $(( i + 1 ))
- rm -f $file
- return 0
- fi
- done
- error "mdt-s : inodes count OLD ${oldused[@]} NEW ${newused[@]}"
+ do_nodes $nodes "rc=0;
+val=\\\$($LCTL get_param -n catastrophe 2>&1);
+if [[ \\\$? -eq 0 && \\\$val -ne 0 ]]; then
+ echo \\\$(hostname -s): \\\$val;
+ rc=\\\$val;
+fi;
+exit \\\$rc"
}
mdsrate_cleanup () {
return $rc
}
-# target_start_and_reset_recovery_timer()
-# service_time = at_est2timeout(service_time);
-# service_time += 2 * (CONNECTION_SWITCH_MAX + CONNECTION_SWITCH_INC +
-# INITIAL_CONNECT_TIMEOUT);
-# CONNECTION_SWITCH_MAX : min(25U, max(CONNECTION_SWITCH_MIN,obd_timeout))
-#define CONNECTION_SWITCH_INC 1
-#define INITIAL_CONNECT_TIMEOUT max(CONNECTION_SWITCH_MIN,obd_timeout/20)
-#define CONNECTION_SWITCH_MIN 5U
+# check_and_start_recovery_timer()
+# service_time = at_est2timeout(service_time);
+# service_time += 2 * INITIAL_CONNECT_TIMEOUT;
+# service_time += 2 * (CONNECTION_SWITCH_MAX + CONNECTION_SWITCH_INC);
-max_recovery_time () {
- local init_connect_timeout=$(( TIMEOUT / 20 ))
- [[ $init_connect_timeout -ge 5 ]] || init_connect_timeout=5
+#define INITIAL_CONNECT_TIMEOUT max(CONNECTION_SWITCH_MIN, obd_timeout/20)
+#define CONNECTION_SWITCH_MAX min(50, max(CONNECTION_SWITCH_MIN, obd_timeout))
+#define CONNECTION_SWITCH_MIN 5
+#define CONNECTION_SWITCH_INC 5
+max_recovery_time() {
+ local init_connect_timeout=$((TIMEOUT / 20))
+ ((init_connect_timeout >= 5)) || init_connect_timeout=5
- local service_time=$(( $(at_max_get client) + $(( 2 * $(( 25 + 1 + init_connect_timeout)) )) ))
+ local service_time=$(($(at_max_get client) * 9 / 4 + 5))
+ service_time=$((service_time + 2 * (init_connect_timeout + 50 + 5)))
- echo $service_time
+ echo -n $service_time
}
get_clients_mount_count () {
rm -rf $DIR/[df][0-9]* || error "Fail to cleanup the env!"
mkdir $DIR/$tdir || error "Fail to mkdir $DIR/$tdir."
+ for idx in $(seq $MDSCOUNT); do
+ local name="MDT$(printf '%04x' $((idx - 1)))"
+ rm -rf $MOUNT/.lustre/lost+found/$name/*
+ done
}
# calcule how many ost-objects to be created.
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))
}
error_noexit "Pool $FSNAME.$pool is not destroyed"
return 3
}
+
+# Get and check the actual stripe count of one file.
+# Usage: check_stripe_count <file> <expected_stripe_count>
+check_stripe_count() {
+ local file=$1
+ local expected=$2
+ local actual
+
+ [[ -z "$file" || -z "$expected" ]] &&
+ error "check_stripe_count: invalid argument"
+
+ local cmd="$GETSTRIPE -c $file"
+ actual=$($cmd) || error "$cmd failed"
+ actual=${actual%% *}
+
+ if [[ $actual -ne $expected ]]; then
+ [[ $expected -eq -1 ]] ||
+ error "$cmd wrong: found $actual, expected $expected"
+ [[ $actual -eq $OSTCOUNT ]] ||
+ error "$cmd wrong: found $actual, expected $OSTCOUNT"
+ fi
+}
+
+# Get and check the actual list of OST indices on one file.
+# Usage: check_obdidx <file> <expected_comma_separated_list_of_ost_indices>
+check_obdidx() {
+ local file=$1
+ local expected=$2
+ local obdidx
+
+ [[ -z "$file" || -z "$expected" ]] &&
+ error "check_obdidx: invalid argument!"
+
+ obdidx=$(comma_list $($GETSTRIPE $file | grep -A $OSTCOUNT obdidx |
+ grep -v obdidx | awk '{print $1}' | xargs))
+
+ [[ $obdidx = $expected ]] ||
+ error "list of OST indices on $file is $obdidx," \
+ "should be $expected"
+}
+
+# Get and check the actual OST index of the first stripe on one file.
+# Usage: check_start_ost_idx <file> <expected_start_ost_idx>
+check_start_ost_idx() {
+ local file=$1
+ local expected=$2
+ local start_ost_idx
+
+ [[ -z "$file" || -z "$expected" ]] &&
+ error "check_start_ost_idx: invalid argument!"
+
+ start_ost_idx=$($GETSTRIPE $file | grep -A 1 obdidx | grep -v obdidx |
+ awk '{print $1}')
+
+ [[ $start_ost_idx = $expected ]] ||
+ error "OST index of the first stripe on $file is" \
+ "$start_ost_idx, should be $expected"
+}