2 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
4 trap 'print_summary && echo "test-framework exiting on error"' ERR
9 export REFORMAT=${REFORMAT:-""}
10 export WRITECONF=${WRITECONF:-""}
12 export GMNALNID=${GMNALNID:-/usr/sbin/gmlndnid}
13 export CATASTROPHE=${CATASTROPHE:-/proc/sys/lnet/catastrophe}
16 export GSS_PIPEFS=false
17 export IDENTITY_UPCALL=default
19 #export PDSH="pdsh -S -Rssh -w"
21 # function used by scripts run on remote nodes
22 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
23 . $LUSTRE/tests/functions.sh
27 [[ $DIR/ = $MOUNT/* ]] || \
28 { failed=1 && echo "DIR=$DIR not in $MOUNT. Aborting."; }
29 [[ $DIR1/ = $MOUNT1/* ]] || \
30 { failed=1 && echo "DIR1=$DIR1 not in $MOUNT1. Aborting."; }
31 [[ $DIR2/ = $MOUNT2/* ]] || \
32 { failed=1 && echo "DIR2=$DIR2 not in $MOUNT2. Aborting"; }
34 [ -n "$failed" ] && exit 99 || true
38 echo "usage: $0 [-r] [-f cfgfile]"
45 [ "$TESTSUITE" == "lfscktest" ] && return 0
46 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to ${ONLY}."
47 local form="%-13s %-17s %s\n"
48 printf "$form" "status" "script" "skipped tests E(xcluded) S(low)"
49 echo "------------------------------------------------------------------------------------"
50 for O in $TESTSUITE_LIST; do
53 local o=$(echo $O | tr "[:upper:]" "[:lower:]")
56 local log=${TMP}/${o}.log
57 [ -f $log ] && skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
58 [ -f $log ] && slow=$(grep SLOW $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
59 [ "${!O}" = "done" ] && \
60 printf "$form" "Done" "$O" "E=$skipped" && \
61 [ -n "$slow" ] && printf "$form" "-" "-" "S=$slow"
65 for O in $TESTSUITE_LIST; do
66 [ "${!O}" = "no" ] && \
67 printf "$form" "Skipped" "$O" ""
70 for O in $TESTSUITE_LIST; do
71 [ "${!O}" = "done" -o "${!O}" = "no" ] || \
72 printf "$form" "UNFINISHED" "$O" ""
77 export LUSTRE=`absolute_path $LUSTRE`
78 export TESTSUITE=`basename $0 .sh`
79 export TEST_FAILED=false
81 export MKE2FS=${MKE2FS:-mke2fs}
82 export DEBUGFS=${DEBUGFS:-debugfs}
83 export TUNE2FS=${TUNE2FS:-tune2fs}
84 export E2LABEL=${E2LABEL:-e2label}
85 export DUMPE2FS=${DUMPE2FS:-dumpe2fs}
86 export E2FSCK=${E2FSCK:-e2fsck}
88 #[ -d /r ] && export ROOT=${ROOT:-/r}
89 export TMP=${TMP:-$ROOT/tmp}
90 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
91 export HOSTNAME=${HOSTNAME:-`hostname`}
92 if ! echo $PATH | grep -q $LUSTRE/utils; then
93 export PATH=$PATH:$LUSTRE/utils
95 if ! echo $PATH | grep -q $LUSTRE/utils/gss; then
96 export PATH=$PATH:$LUSTRE/utils/gss
98 if ! echo $PATH | grep -q $LUSTRE/tests; then
99 export PATH=$PATH:$LUSTRE/tests
101 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mpi/mdsrate"}
102 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
103 if ! echo $PATH | grep -q $LUSTRE/tests/racer; then
104 export PATH=$PATH:$LUSTRE/tests/racer
106 if ! echo $PATH | grep -q $LUSTRE/tests/mpi; then
107 export PATH=$PATH:$LUSTRE/tests/mpi
109 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
110 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
111 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
112 [ ! -f "$LFS" ] && export LFS=$(which lfs)
113 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
114 if [ ! -f "$L_GETIDENTITY" ]; then
115 if `which l_getidentity > /dev/null 2>&1`; then
116 export L_GETIDENTITY=$(which l_getidentity)
118 export L_GETIDENTITY=NONE
121 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
122 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
123 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
124 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
125 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
126 export FSTYPE=${FSTYPE:-"ldiskfs"}
127 export NAME=${NAME:-local}
128 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
129 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
130 export LGSSD=$(which lgssd)
131 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
132 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd 2> /dev/null)
133 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
135 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
138 if [ "$ACCEPTOR_PORT" ]; then
139 export PORT_OPT="--port $ACCEPTOR_PORT"
144 echo "Using GSS/krb5 ptlrpc security flavor"
145 which lgss_keyring > /dev/null 2>&1 || \
146 error "built with gss disabled! SEC=$SEC"
157 IDENTITY_UPCALL=false
161 # Paths on remote nodes, if different
162 export RLUSTRE=${RLUSTRE:-$LUSTRE}
163 export RPWD=${RPWD:-$PWD}
164 export I_MOUNTED=${I_MOUNTED:-"no"}
168 while getopts "rvwf:" opt $*; do
171 r) REFORMAT=--reformat;;
173 w) WRITECONF=writeconf;;
178 shift $((OPTIND - 1))
181 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
187 2.4.*) EXT=".o"; USE_QUOTA=no; [ ! "$CLIENTONLY" ] && FSTYPE=ext3;;
188 *) EXT=".ko"; USE_QUOTA=yes;;
195 BASE=`basename $module $EXT`
196 lsmod | grep -q ${BASE} || \
197 if [ -f ${LUSTRE}/${module}${EXT} ]; then
198 insmod ${LUSTRE}/${module}${EXT} $@
200 # must be testing a "make install" or "rpm" installation
201 # note failed to load ptlrpc_gss is considered not fatal
202 if [ "$BASE" == "ptlrpc_gss" ]; then
203 modprobe $BASE $@ 2>/dev/null || echo "gss/krb5 is not supported"
211 if [ -n "$MODPROBE" ]; then
215 if [ "$HAVE_MODULES" = true ]; then
221 echo Loading modules from $LUSTRE
222 load_module ../libcfs/libcfs/libcfs
223 [ "$PTLDEBUG" ] && lctl set_param debug="$PTLDEBUG"
224 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug="${SUBSYSTEM# }"
226 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
227 [ ! "$MODPROBECONF" -a -d /etc/modprobe.d ] && MODPROBECONF=/etc/modprobe.d/Lustre
228 [ -z "$LNETOPTS" -a "$MODPROBECONF" ] && \
229 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
230 echo $LNETOPTS | grep -q "accept=all" || LNETOPTS="$LNETOPTS accept=all";
231 echo "lnet options: '$LNETOPTS'"
232 # note that insmod will ignore anything in modprobe.conf
233 load_module ../lnet/lnet/lnet $LNETOPTS
234 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
235 load_module ../lnet/klnds/$LNETLND
236 load_module lvfs/lvfs
237 load_module obdclass/obdclass
238 load_module ptlrpc/ptlrpc
239 load_module ptlrpc/gss/ptlrpc_gss
240 [ "$USE_QUOTA" = "yes" -a "$LQUOTA" != "no" ] && load_module quota/lquota
248 if [ -z "$CLIENTONLY" ] && [ -z "$CLIENTMODSONLY" ]; then
249 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
250 grep -q jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
251 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
256 load_module lvfs/fsfilt_$FSTYPE
260 load_module obdfilter/obdfilter
263 load_module llite/lustre
264 load_module llite/llite_lloop
265 [ -d /r ] && OGDB=${OGDB:-"/r/tmp"}
267 rm -f $OGDB/ogdb-$HOSTNAME
268 $LCTL modules > $OGDB/ogdb-$HOSTNAME
270 # 'mount' doesn't look in $PATH, just sbin
271 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
275 if [ `uname -r | cut -c 3` -eq 4 ]; then
283 MODULES=$($LCTL modules | awk '{ print $2 }')
284 while [ -n "$MODULES" ]; do
286 $RMMOD $MODULES > /dev/null 2>&1 || true
287 MODULES=$($LCTL modules | awk '{ print $2 }')
288 if [ -z "$MODULES" ]; then
292 echo "waiting, $((MAX - WAIT)) secs left"
294 if [ $WAIT -eq $MAX ]; then
295 echo "LNET modules $MODULES will not unload"
302 unload_dep_module() {
304 #libcfs 107852 17 llite_lloop,lustre,obdfilter,ost,...
306 local DEPS=$(lsmod | awk '($1 == "'$MODULE'") { print $4 }' | tr ',' ' ')
307 for SUBMOD in $DEPS; do
308 unload_dep_module $SUBMOD
310 [ "$MODULE" = "libcfs" ] && $LCTL dk $TMP/debug || true
311 $RMMOD $MODULE || true
315 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
316 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
317 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
318 echo "$LEAK_LUSTRE" 1>&2
319 echo "$LEAK_PORTALS" 1>&2
320 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
321 echo "Memory leaks detected"
322 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
328 wait_exit_ST client # bug 12845
330 lsmod | grep libcfs > /dev/null && $LCTL dl
331 unload_dep_module $FSTYPE
332 unload_dep_module libcfs
334 local MODULES=$($LCTL modules | awk '{ print $2 }')
335 if [ -n "$MODULES" ]; then
336 echo "Modules still loaded: "
338 if [ "$(lctl dl)" ]; then
339 echo "Lustre still loaded"
344 echo "Lustre stopped but LNET is still loaded, waiting..."
345 wait_for_lnet || return 3
351 check_mem_leak || return 254
353 echo "modules unloaded."
357 check_gss_daemon_facet() {
361 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
362 if [ $num -ne 1 ]; then
363 echo "$num instance of $dname on $facet"
372 do_facet $facet "killall -2 $@ 2>/dev/null || true"
375 start_gss_daemons() {
377 for num in `seq $MDSCOUNT`; do
378 do_facet mds$num "$LSVCGSSD -v"
380 do_facet mds$num "$LGSSD -v"
384 for num in `seq $OSTCOUNT`; do
385 do_facet ost$num "$LSVCGSSD -v"
388 # FIXME: is "client" the right facet name?
390 do_facet client "$LGSSD -v"
393 # wait daemons entering "stable" status
397 # check daemons are running
399 for num in `seq $MDSCOUNT`; do
400 check_gss_daemon_facet mds$num lsvcgssd
402 check_gss_daemon_facet mds$num lgssd
405 for num in `seq $OSTCOUNT`; do
406 check_gss_daemon_facet ost$num lsvcgssd
409 check_gss_daemon_facet client lgssd
414 for num in `seq $MDSCOUNT`; do
415 send_sigint mds$num lsvcgssd lgssd
417 for num in `seq $OSTCOUNT`; do
418 send_sigint ost$num lsvcgssd
420 send_sigint client lgssd
427 if [ -n "$LGSS_KEYRING_DEBUG" ]; then
428 echo $LGSS_KEYRING_DEBUG > /proc/fs/lustre/sptlrpc/gss/lgss_keyring/debug_level
436 # maybe cleanup credential cache?
442 local device=`mdsdevname $num`
443 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
449 local device=`ostdevname $num`
450 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
458 local dev=$(facet_active $facet)_dev
459 local opt=${facet}_opt
460 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
461 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
463 if [ $RC -ne 0 ]; then
464 echo "mount -t lustre $@ ${!dev} ${MOUNT%/*}/${facet}"
465 echo "Start of ${!dev} on ${facet} failed ${RC}"
467 do_facet ${facet} "lctl set_param debug=\\\"$PTLDEBUG\\\"; \
468 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\"; \
469 lctl set_param debug_mb=${DEBUG_SIZE}; \
472 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
473 [ -z "$label" ] && echo no label for ${!dev} && exit 1
474 eval export ${facet}_svc=${label}
475 echo Started ${label}
480 # start facet device options
486 eval export ${facet}_dev=${device}
487 eval export ${facet}_opt=\"$@\"
489 local varname=${facet}failover_dev
490 if [ -n "${!varname}" ] ; then
491 eval export ${facet}failover_dev=${!varname}
493 eval export ${facet}failover_dev=$device
496 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
506 HOST=`facet_active_host $facet`
507 [ -z $HOST ] && echo stop: no host for $facet && return 0
509 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
510 if [ ${running} -ne 0 ]; then
511 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
512 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
515 # umount should block, but we should wait for unrelated obd's
516 # like the MGS or MGC to also stop.
517 wait_exit_ST ${facet}
520 # save quota version (both administrative and operational quotas)
521 # add an additional parameter if mountpoint is ever different from $MOUNT
522 quota_save_version() {
523 local fsname=${2:-$FSNAME}
525 $LFS quotaoff -ug $MOUNT # just in case
526 [ -n "$1" ] && { $LFS quotacheck -$1 $MOUNT || error "quotacheck has failed"; }
528 do_facet mgs "lctl conf_param ${fsname}-MDT*.mdd.quota_type=$1"
530 local osts=$(get_facets OST)
531 for ost in ${osts//,/ }; do
533 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$1"
537 # client could mount several lustre
539 local fsname=${1:-$FSNAME}
541 do_facet mgs lctl get_param mdd.${fsname}-MDT*.quota_type || rc=$?
542 do_nodes $(comma_list $(osts_nodes)) \
543 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
547 restore_quota_type () {
548 local mntpt=${1:-$MOUNT}
549 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
550 if [ ! "$old_QUOTA_TYPE" ] || [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
553 quota_save_version $old_QUOTA_TYPE
560 # 1. run quotacheck only if quota is off
561 # 2. save the original quota_type params, restore them after testing
563 # Suppose that quota type the same on mds and ost
564 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
565 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
566 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
567 export old_QUOTA_TYPE=$quota_type
568 quota_save_version $QUOTA_TYPE
571 local quota_usrs=$QUOTA_USERS
573 # get_filesystem_size
574 local disksz=$(lfs df $mntpt | grep "filesystem summary:" | awk '{print $3}')
575 local blk_soft=$((disksz + 1024))
576 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
578 local Inodes=$(lfs df -i $mntpt | grep "filesystem summary:" | awk '{print $3}')
580 local i_hard=$((i_soft + i_soft / 20))
582 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
583 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
586 for usr in $quota_usrs; do
587 echo "Setting up quota on $client:$mntpt for $usr..."
589 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
591 eval $cmd || error "$cmd FAILED!"
593 # display the quota status
594 echo "Quota settings for $usr : "
595 $LFS quota -v -u $usr $mntpt || true
603 # Only supply -o to mount if we have options
604 if [ -n "$MOUNTOPT" ]; then
605 OPTIONS="-o $MOUNTOPT"
607 local device=$MGSNID:/$FSNAME
608 if [ -z "$mnt" -o -z "$FSNAME" ]; then
609 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
613 echo "Starting client: $client: $OPTIONS $device $mnt"
614 do_node $client mkdir -p $mnt
615 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
617 do_node $client "lctl set_param debug=\\\"$PTLDEBUG\\\";
618 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
619 lctl set_param debug_mb=${DEBUG_SIZE}"
632 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
633 if [ $running -ne 0 ]; then
634 echo "Stopping client $client $mnt (opts:$force)"
635 do_node $client lsof -t $mnt || need_kill=no
636 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
637 pids=$(do_node $client lsof -t $mnt | sort -u);
638 if [ -n $pids ]; then
639 do_node $client kill -9 $pids || true
643 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
644 if [ $busy -ne 0 ] ; then
645 echo "$mnt is still busy, wait one second" && sleep 1
646 do_node $client umount $force $mnt
651 # nodes is comma list
652 sanity_mount_check_nodes () {
658 # FIXME: assume that all cluster nodes run the same os
659 [ "$(uname)" = Linux ] || return 0
662 for mnt in $mnts ; do
663 do_nodes $nodes "set -x; running=\\\$(grep -c $mnt' ' /proc/mounts);
664 mpts=\\\$(mount | grep -w -c $mnt);
665 if [ \\\$running -ne \\\$mpts ]; then
666 echo \\\$(hostname) env are INSANE!;
674 sanity_mount_check_servers () {
675 echo Checking servers environments
677 # FIXME: modify get_facets to display all facets wo params
678 local facets="$(get_facets OST),$(get_facets MDS)"
682 for facet in ${facets//,/ }; do
683 node=$(facet_host ${facet})
684 mnt=${MOUNT%/*}/${facet}
685 sanity_mount_check_nodes $node $mnt ||
686 { error "server $node environments are insane!"; return 1; }
690 sanity_mount_check_clients () {
691 local clients=${1:-$CLIENTS}
692 local mntpt=${2:-$MOUNT}
693 local mntpt2=${3:-$MOUNT2}
695 [ -z $clients ] && clients=$(hostname)
696 echo Checking clients $clients environments
698 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
699 error "clients environments are insane!"
702 sanity_mount_check () {
703 sanity_mount_check_servers || return 1
704 sanity_mount_check_clients || return 2
707 # mount clients if not mouted
708 zconf_mount_clients() {
714 # Only supply -o to mount if we have options
715 if [ -n "$MOUNTOPT" ]; then
716 OPTIONS="-o $MOUNTOPT"
718 local device=$MGSNID:/$FSNAME
719 if [ -z "$mnt" -o -z "$FSNAME" ]; then
720 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
724 echo "Starting client $clients: $OPTIONS $device $mnt"
726 do_nodes $clients "set -x;
727 running=\\\$(mount | grep -c $mnt' ');
729 if [ \\\$running -eq 0 ] ; then
731 mount -t lustre $OPTIONS $device $mnt;
736 echo "Started clients $clients: "
737 do_nodes $clients "mount | grep -w $mnt"
739 do_nodes $clients "lctl set_param debug=\\\"$PTLDEBUG\\\";
740 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
741 lctl set_param debug_mb=${DEBUG_SIZE};"
746 zconf_umount_clients() {
753 echo "Stopping clients: $clients $mnt (opts:$force)"
754 do_nodes $clients "set -x; running=\\\$(grep -c $mnt' ' /proc/mounts);
755 if [ \\\$running -ne 0 ] ; then
756 echo Stopping client \\\$(hostname) client $mnt opts:$force;
757 lsof -t $mnt || need_kill=no;
758 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
759 pids=\\\$(lsof -t $mnt | sort -u);
760 if [ -n \\\"\\\$pids\\\" ]; then
764 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy");
765 if [ \\\$busy -ne 0 ] ; then
766 echo "$mnt is still busy, wait one second" && sleep 1;
772 shudown_node_hard () {
776 for i in $(seq $attempts) ; do
779 ping -w 3 -c 1 $host > /dev/null 2>&1 || return 0
780 echo "waiting for $host to fail attempts=$attempts"
781 [ $i -lt $attempts ] || \
782 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
788 local mnt=${2:-$MOUNT}
791 if [ "$FAILURE_MODE" = HARD ]; then
792 shudown_node_hard $client
794 zconf_umount_clients $client $mnt -f
800 if [ "$FAILURE_MODE" = HARD ]; then
801 shudown_node_hard $(facet_active_host $facet)
802 elif [ "$FAILURE_MODE" = SOFT ]; then
809 if [ "$FAILURE_MODE" = HARD ]; then
810 $POWER_UP `facet_active_host $facet`
818 if [ "$FAILURE_MODE" = HARD ]; then
823 # recovery-scale functions
824 check_progs_installed () {
829 do_nodes $clients "set -x ; PATH=:$PATH status=true; for prog in $progs; do
830 which \\\$prog || { echo \\\$prog missing on \\\$(hostname) && status=false; }
836 echo __$(echo $1 | tr '-' 'X')
839 start_client_load() {
842 local var=$(client_var_name $client)_load
843 eval export ${var}=$load
845 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
846 BREAK_ON_ERROR=$BREAK_ON_ERROR \
847 END_RUN_FILE=$END_RUN_FILE \
848 LOAD_PID_FILE=$LOAD_PID_FILE \
849 TESTSUITELOG=$TESTSUITELOG \
851 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
852 log "Started client load: ${load} on $client"
857 start_client_loads () {
858 local -a clients=(${1//,/ })
859 local numloads=${#CLIENT_LOADS[@]}
862 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
863 testnum=$((nodenum % numloads))
864 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
868 # only for remote client
869 check_client_load () {
871 local var=$(client_var_name $client)_load
872 local TESTLOAD=run_${!var}.sh
874 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
876 check_catastrophe $client || return 2
878 # see if the load is still on the client
881 while [ $RC = 254 -a $tries -gt 0 ]; do
885 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
890 if [ $RC = 254 ]; then
891 echo "got a return status of $RC from do_node while checking (i.e. with 'ps') the client load on the remote system"
892 # see if we can diagnose a bit why this is
897 check_client_loads () {
898 local clients=${1//,/ }
902 for client in $clients; do
903 check_client_load $client
905 if [ "$rc" != 0 ]; then
906 log "Client load failed on node $client, rc=$rc"
912 restart_client_loads () {
913 local clients=${1//,/ }
914 local expectedfail=${2:-""}
918 for client in $clients; do
919 check_client_load $client
921 if [ "$rc" != 0 -a "$expectedfail" ]; then
922 start_client_load $client
923 echo "Restarted client load: on $client. Checking ..."
924 check_client_load $client
926 if [ "$rc" != 0 ]; then
927 log "Client load failed to restart on node $client, rc=$rc"
928 # failure one client load means test fail
929 # we do not need to check other
937 # End recovery-scale functions
939 # verify that lustre actually cleaned up properly
941 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
942 error "LBUG/LASSERT detected"
943 BUSY=`dmesg | grep -i destruct || true`
946 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
950 check_mem_leak || exit 204
952 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
953 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
955 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
956 echo "$0: modules still loaded..." 1>&2
973 RESULT=$(do_node $node "$TEST")
974 if [ "$RESULT" == "$FINAL" ]; then
975 echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
978 [ $WAIT -ge $MAX ] && break
979 echo "Waiting $((MAX - WAIT)) secs for update"
980 WAIT=$((WAIT + sleep))
983 echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
987 wait_update_facet () {
989 wait_update $(facet_active_host $facet) "$@"
992 wait_delete_completed () {
993 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
994 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
998 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
1000 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
1001 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1002 [ "$TOTAL" -eq "$TOTALPREV" ] && break
1003 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
1007 echo "Delete completed."
1012 check_network "$host" 900
1013 while ! do_node $host "ls -d $LUSTRE " > /dev/null; do sleep 5; done
1018 local host=`facet_active_host $facet`
1022 wait_recovery_complete () {
1025 # Use default policy if $2 is not passed by caller.
1026 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
1027 # as we are in process of changing obd_timeout in different ways
1028 # let's set MAX longer than that
1029 local MAX=${2:-$(( TIMEOUT * 4 ))}
1031 local var_svc=${facet}_svc
1032 local procfile="*.${!var_svc}.recovery_status"
1036 while [ $WAIT -lt $MAX ]; do
1037 STATUS=$(do_facet $facet lctl get_param -n $procfile | grep status)
1038 [[ $STATUS = "status: COMPLETE" ]] && return 0
1041 echo "Waiting $((MAX - WAIT)) secs for $facet recovery done. $STATUS"
1043 echo "$facet recovery not done in $MAX sec. $STATUS"
1053 # conf-sanity 31 takes a long time cleanup
1054 while [ $WAIT -lt 300 ]; do
1055 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
1056 [ -z "${running}" ] && return 0
1057 echo "waited $WAIT for${running}"
1058 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
1060 WAIT=$((WAIT + INTERVAL))
1062 echo "service didn't stop after $WAIT seconds. Still running:"
1067 wait_remote_prog () {
1073 [ "$PDSH" = "no_dsh" ] && return 0
1075 while [ $WAIT -lt $2 ]; do
1076 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
1077 [ -z "${running}" ] && return 0 || true
1078 echo "waited $WAIT for: "
1080 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
1082 WAIT=$((WAIT + INTERVAL))
1084 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
1085 [ -z "$pids" ] && return 0
1086 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
1087 # FIXME: not portable
1088 for pid in $pids; do
1089 cat /proc/${pid}/status || true
1090 cat /proc/${pid}/wchan || true
1092 kill -9 $pid || true
1101 # not every config has many clients
1102 if [ ! -z "$CLIENTS" ]; then
1103 $PDSH $CLIENTS "df $MOUNT" > /dev/null
1105 df $MOUNT > /dev/null
1109 client_reconnect() {
1110 uname -n >> $MOUNT/recon
1111 if [ -z "$CLIENTS" ]; then
1112 df $MOUNT; uname -n >> $MOUNT/recon
1114 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
1116 echo Connected clients:
1118 ls -l $MOUNT/recon > /dev/null
1125 echo "Failing $facet on node `facet_active_host $facet`"
1126 shutdown_facet $facet
1127 [ -n "$sleep_time" ] && sleep $sleep_time
1131 echo "df pid is $DFPID"
1132 change_active $facet
1133 local TO=`facet_active_host $facet`
1134 echo "Failover $facet to $TO"
1136 mount_facet $facet || error "Restart of $facet failed"
1145 do_facet $facet sync
1147 local svc=${facet}_svc
1148 do_facet $facet $LCTL --device %${!svc} notransno
1149 do_facet $facet $LCTL --device %${!svc} readonly
1150 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1151 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1154 replay_barrier_nodf() {
1155 local facet=$1 echo running=${running}
1156 do_facet $facet sync
1157 local svc=${facet}_svc
1158 echo Replay barrier on ${!svc}
1159 do_facet $facet $LCTL --device %${!svc} notransno
1160 do_facet $facet $LCTL --device %${!svc} readonly
1161 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1162 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1165 replay_barrier_nosync() {
1166 local facet=$1 echo running=${running}
1167 local svc=${facet}_svc
1168 echo Replay barrier on ${!svc}
1169 do_facet $facet $LCTL --device %${!svc} notransno
1170 do_facet $facet $LCTL --device %${!svc} readonly
1171 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1172 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1175 mds_evict_client() {
1176 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
1177 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
1180 ost_evict_client() {
1181 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
1182 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1186 facet_failover $* || error "failover: $?"
1187 df $MOUNT || error "post-failover df: $?"
1192 facet_failover $facet
1198 change_active $facet
1199 mount_facet $facet -o abort_recovery
1200 df $MOUNT || echo "first df failed: $?"
1202 df $MOUNT || error "post-failover df: $?"
1206 echo There is no lmc. This is mountconf, baby.
1211 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1212 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
1218 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1224 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1225 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1226 if [ -z "$ID" ]; then
1227 echo "Could not get a ptl id for $1..."
1236 h2name_or_ip "$1" "tcp"
1241 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1242 if type __h2elan >/dev/null 2>&1; then
1245 ID=`echo $1 | sed 's/[^0-9]*//g'`
1253 h2name_or_ip "$1" "openib"
1255 declare -fx h2openib
1258 h2name_or_ip "$1" "o2ib"
1265 [ "$facet" == client ] && echo -n $HOSTNAME && return
1266 varname=${facet}_HOST
1267 if [ -z "${!varname}" ]; then
1268 if [ "${facet:0:3}" == "ost" ]; then
1269 eval ${facet}_HOST=${ost_HOST}
1277 local activevar=${facet}active
1279 if [ -f $TMP/${facet}active ] ; then
1280 source $TMP/${facet}active
1283 active=${!activevar}
1284 if [ -z "$active" ] ; then
1291 facet_active_host() {
1293 local active=`facet_active $facet`
1294 if [ "$facet" == client ]; then
1297 echo `facet_host $active`
1303 local failover=${facet}failover
1304 host=`facet_host $failover`
1305 [ -z "$host" ] && return
1306 local curactive=`facet_active $facet`
1307 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1308 eval export ${facet}active=$facet
1310 eval export ${facet}active=$failover
1312 # save the active host for this facet
1313 local activevar=${facet}active
1314 echo "$activevar=${!activevar}" > $TMP/$activevar
1321 if [ "$HOST" = "$HOSTNAME" ]; then
1323 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1324 echo "cannot run remote command on $HOST with $myPDSH"
1328 echo "CMD: $HOST $@" >&2
1329 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
1332 if [ "$myPDSH" = "rsh" ]; then
1333 # we need this because rsh does not return exit code of an executed command
1334 local command_status="$TMP/cs"
1335 rsh $HOST ":> $command_status"
1336 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1337 cd $RPWD; sh -c \"$@\") ||
1338 echo command failed >$command_status"
1339 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1342 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
1343 return ${PIPESTATUS[0]}
1346 single_local_node () {
1347 [ "$1" = "$HOSTNAME" ]
1354 if $(single_local_node $rnodes); then
1359 # This is part from do_node
1362 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1363 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1366 echo "CMD: $rnodes $@" >&2
1367 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
1370 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
1371 return ${PIPESTATUS[0]}
1377 local HOST=`facet_active_host $facet`
1378 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1385 # make sure its not already running
1387 rm -f $TMP/${facet}active
1388 do_facet ${facet} $MKFS $*
1394 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1395 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1402 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
1403 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1411 # make sure we are using the primary server, so test-framework will
1412 # be able to clean up properly.
1413 activemds=`facet_active mds1`
1414 if [ $activemds != "mds1" ]; then
1418 local clients=$CLIENTS
1419 [ -z $clients ] && clients=$(hostname)
1421 zconf_umount_clients $clients $MOUNT "$*" || true
1422 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
1424 [ "$CLIENTONLY" ] && return
1425 # The add fn does rm ${facet}active file, this would be enough
1426 # if we use do_facet <facet> only after the facet added, but
1427 # currently we use do_facet mds in local.sh
1428 for num in `seq $MDSCOUNT`; do
1430 rm -f ${TMP}/mds${num}active
1433 for num in `seq $OSTCOUNT`; do
1435 rm -f $TMP/ost${num}active
1450 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
1454 if [ "$IAMDIR" == "yes" ]; then
1455 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --iam-dir"
1456 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --iam-dir"
1459 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1461 if [ ! -z $SEC ]; then
1462 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --param srpc.flavor.default=$SEC"
1463 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --param srpc.flavor.default=$SEC"
1464 OST_MKFS_OPTS="$OST_MKFS_OPTS --param srpc.flavor.default=$SEC"
1468 # We need ldiskfs here, may as well load them all
1470 [ "$CLIENTONLY" ] && return
1471 echo "Formatting mdts, osts"
1472 for num in `seq $MDSCOUNT`; do
1473 echo "Format mds$num: $(mdsdevname $num)"
1475 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
1477 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
1481 for num in `seq $OSTCOUNT`; do
1482 echo "Format ost$num: $(ostdevname $num)"
1484 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
1486 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
1492 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1496 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1500 # 0: success, the old identity set already.
1501 # 1: success, the old identity does not set.
1506 local j=`expr $num - 1`
1507 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
1509 if [ -z "$MDT" ]; then
1513 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1516 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
1518 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
1521 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush \"-1\""
1523 if [ $old = "NONE" ]; then
1532 zconf_umount `hostname` $1 || error "umount failed"
1533 zconf_mount `hostname` $1 || error "mount failed"
1536 writeconf_facet () {
1540 do_facet $facet "$TUNEFS --writeconf $dev"
1544 for num in `seq $MDSCOUNT`; do
1545 DEVNAME=$(mdsdevname $num)
1546 writeconf_facet mds$num $DEVNAME
1549 for num in `seq $OSTCOUNT`; do
1550 DEVNAME=$(ostdevname $num)
1551 writeconf_facet ost$num $DEVNAME
1556 sanity_mount_check ||
1557 error "environments are insane!"
1561 if [ -z "$CLIENTONLY" ]; then
1562 echo "Setup mdts, osts"
1563 echo $WRITECONF | grep -q "writeconf" && \
1565 for num in `seq $MDSCOUNT`; do
1566 DEVNAME=$(mdsdevname $num)
1567 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1569 # We started mds, now we should set failover variables properly.
1570 # Set mds${num}failover_HOST if it is not set (the default failnode).
1571 local varname=mds${num}failover_HOST
1572 if [ -z "${!varname}" ]; then
1573 eval mds${num}failover_HOST=$(facet_host mds$num)
1576 if [ $IDENTITY_UPCALL != "default" ]; then
1577 switch_identity $num $IDENTITY_UPCALL
1580 for num in `seq $OSTCOUNT`; do
1581 DEVNAME=$(ostdevname $num)
1582 start ost$num $DEVNAME $OST_MOUNT_OPTS
1584 # We started ost$num, now we should set ost${num}failover variable properly.
1585 # Set ost${num}failover_HOST if it is not set (the default failnode).
1586 varname=ost${num}failover_HOST
1587 if [ -z "${!varname}" ]; then
1588 eval ost${num}failover_HOST=$(facet_host ost${num})
1593 # wait a while to allow sptlrpc configuration be propogated to targets,
1594 # only needed when mounting new target devices.
1597 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1599 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1601 if [ "$MOUNT_2" ]; then
1602 mount_client $MOUNT2
1603 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1608 # by remounting mdt before ost, initial connect from mdt to ost might
1609 # timeout because ost is not ready yet. wait some time to its fully
1610 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1611 # by a context negotiation rpc with $TIMEOUT.
1612 # FIXME better by monitoring import status.
1614 sleep $((TIMEOUT + 5))
1620 mounted_lustre_filesystems() {
1621 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1624 init_facet_vars () {
1631 eval export ${facet}_dev=${device}
1632 eval export ${facet}_opt=\"$@\"
1634 local dev=${facet}_dev
1635 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
1636 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1638 eval export ${facet}_svc=${label}
1640 local varname=${facet}failover_HOST
1641 if [ -z "${!varname}" ]; then
1642 eval $varname=$(facet_host $facet)
1645 # ${facet}failover_dev is set in cfg file
1646 varname=${facet}failover_dev
1647 if [ -n "${!varname}" ] ; then
1648 eval export ${facet}failover_dev=${!varname}
1650 eval export ${facet}failover_dev=$device
1654 init_facets_vars () {
1657 if ! remote_mds_nodsh; then
1658 for num in `seq $MDSCOUNT`; do
1659 DEVNAME=`mdsdevname $num`
1660 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
1664 remote_ost_nodsh && return
1666 for num in `seq $OSTCOUNT`; do
1667 DEVNAME=`ostdevname $num`
1668 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1672 mds_sanity_check () {
1676 while [ $period -lt $timeout ]; do
1677 count=$(do_facet $SINGLEMDS "lctl dl | grep 'osc.*mdtlov_UUID' | grep ' IN ' 2>/dev/null | wc -l")
1678 if [ $count -eq 0 ]; then
1682 echo "There are $count OST are inactive, wait $period seconds, and try again"
1684 period=$((period+3))
1687 [ $period -lt $timeout ] || log "$count OST are inactive after $timeout seconds, give up"
1691 SOM_ENABLED=$(do_facet $SINGLEMDS "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
1695 init_param_vars () {
1696 if ! remote_ost_nodsh && ! remote_mds_nodsh; then
1697 export MDSVER=$(do_facet $SINGLEMDS "lctl get_param version" | cut -d. -f1,2)
1698 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
1699 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
1703 TIMEOUT=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1705 log "Using TIMEOUT=$TIMEOUT"
1707 mds_sanity_check $TIMEOUT
1709 if [ x"$(som_check)" = x"enabled" ]; then
1712 if [ "$ENABLE_QUOTA" ]; then
1713 setup_quota $MOUNT || return 2
1719 local myMGS_host=$mgs_HOST
1720 if [ "$NETTYPE" = "ptl" ]; then
1721 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
1724 echo Checking config lustre mounted on $mntpt
1725 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
1726 mgshost=$(echo $mgshost | awk -F: '{print $1}')
1728 if [ "$mgshost" != "$myMGS_host" ]; then
1729 log "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
1730 Please use correct config or set mds_HOST correctly!"
1733 sanity_mount_check ||
1734 error "environments are insane!"
1738 local mdstimeout=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1739 local cltimeout=$(lctl get_param -n timeout)
1740 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
1741 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
1746 check_and_setup_lustre() {
1747 local MOUNTED=$(mounted_lustre_filesystems)
1748 if [ -z "$MOUNTED" ] || ! $(echo $MOUNTED | grep -w -q $MOUNT); then
1749 [ "$REFORMAT" ] && formatall
1751 MOUNTED=$(mounted_lustre_filesystems | head -1)
1752 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
1753 export I_MOUNTED=yes
1759 if [ "$ONLY" == "setup" ]; then
1764 cleanup_and_setup_lustre() {
1765 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
1766 lctl set_param debug=0 || true
1768 if [ "$ONLY" == "cleanup" ]; then
1772 check_and_setup_lustre
1775 check_and_cleanup_lustre() {
1776 if [ "`mount | grep $MOUNT`" ]; then
1777 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1778 [ "$ENABLE_QUOTA" ] && restore_quota_type || true
1780 if [ "$I_MOUNTED" = "yes" ]; then
1781 cleanupall -f || error "cleanup failed"
1793 while [ $NETWORK -eq 0 ]; do
1794 ping -c 1 -w 3 $1 > /dev/null
1795 if [ $? -eq 0 ]; then
1799 echo "waiting for $1, $((MAX - WAIT)) secs left"
1802 if [ $WAIT -gt $MAX ]; then
1803 echo "Network not available"
1809 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
1820 # the sed converts spaces to commas, but leaves the last space
1821 # alone, so the line doesn't end with a comma.
1822 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
1825 # list, excluded are the comma separated lists
1826 exclude_items_from_list () {
1832 for item in ${excluded//,/ }; do
1833 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
1835 echo $(comma_list $list)
1838 # list, expand are the comma separated lists
1840 local list=${1//,/ }
1841 local expand=${2//,/ }
1844 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
1845 echo $(comma_list $expanded)
1849 (cd `dirname $1`; echo $PWD/`basename $1`)
1853 local name=$(echo $1 | tr "[:upper:]" "[:lower:]")
1854 local type=$(echo $1 | tr "[:lower:]" "[:upper:]")
1857 local count=${type}COUNT
1858 for ((i=1; i<=${!count}; i++)) do
1859 list="$list ${name}$i"
1861 echo $(comma_list $list)
1864 ##################################
1865 # Adaptive Timeouts funcs
1868 # only check mds, we assume at_max is the same on all nodes
1869 local at_max=$(do_facet $SINGLEMDS "lctl get_param -n at_max")
1870 if [ $at_max -eq 0 ]; then
1880 # suppose that all ost-s has the same at_max set
1881 if [ $facet == "ost" ]; then
1882 do_facet ost1 "lctl get_param -n at_max"
1884 do_facet $facet "lctl get_param -n at_max"
1894 if [ $facet == "ost" ]; then
1895 for i in `seq $OSTCOUNT`; do
1896 do_facet ost$i "lctl set_param at_max=$at_max"
1899 elif [ $facet == "mds" ]; then
1900 for i in `seq $MDSCOUNT`; do
1901 do_facet mds$i "lctl set_param at_max=$at_max"
1904 do_facet $facet "lctl set_param at_max=$at_max"
1909 ##################################
1913 # OBD_FAIL_MDS_ALL_REQUEST_NET
1915 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
1916 do_facet client "$1" || RC=$?
1917 do_facet $SINGLEMDS lctl set_param fail_loc=0
1922 # OBD_FAIL_MDS_ALL_REPLY_NET
1924 do_facet $SINGLEMDS lctl set_param fail_loc=0x122
1925 do_facet client "$@" || RC=$?
1926 do_facet $SINGLEMDS lctl set_param fail_loc=0
1930 drop_reint_reply() {
1931 # OBD_FAIL_MDS_REINT_NET_REP
1933 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
1934 do_facet client "$@" || RC=$?
1935 do_facet $SINGLEMDS lctl set_param fail_loc=0
1940 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1942 do_facet ost1 lctl set_param fail_loc=0x214
1943 do_facet client "$1" || RC=$?
1944 do_facet client "sync"
1945 do_facet ost1 lctl set_param fail_loc=0
1949 drop_ldlm_cancel() {
1950 #define OBD_FAIL_LDLM_CANCEL 0x304
1952 do_facet client lctl set_param fail_loc=0x304
1953 do_facet client "$@" || RC=$?
1954 do_facet client lctl set_param fail_loc=0
1958 drop_bl_callback() {
1959 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
1961 do_facet client lctl set_param fail_loc=0x305
1962 do_facet client "$@" || RC=$?
1963 do_facet client lctl set_param fail_loc=0
1968 #define OBD_FAIL_LDLM_REPLY 0x30c
1970 do_facet $SINGLEMDS lctl set_param fail_loc=0x30c
1971 do_facet client "$@" || RC=$?
1972 do_facet $SINGLEMDS lctl set_param fail_loc=0
1980 echo "clearing fail_loc on $facet"
1981 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
1984 set_nodes_failloc () {
1985 do_nodes $(comma_list $1) lctl set_param fail_loc=$2
1988 cancel_lru_locks() {
1989 $LCTL mark "cancel_lru_locks $1 start"
1990 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
1991 $LCTL set_param -n $d=clear
1993 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
1994 $LCTL mark "cancel_lru_locks $1 stop"
1999 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
2000 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
2001 echo "$DEFAULT_LRU_SIZE"
2006 lctl set_param ldlm.namespaces.*$1*.lru_size=0
2009 lru_resize_disable()
2011 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
2016 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
2017 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
2018 echo there is still data in page cache $FILE ?
2019 lctl get_param -n $FILE
2027 DEBUGSAVE="$(lctl get_param -n debug)"
2031 [ -n "$DEBUGSAVE" ] && lctl set_param debug="${DEBUGSAVE}"
2035 ##################################
2037 ##################################
2040 local TYPE=${TYPE:-"FAIL"}
2042 lctl set_param fail_loc=0 2>/dev/null || true
2043 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
2044 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
2045 echo "Dumping lctl log to $ERRLOG"
2046 # We need to dump the logs on all nodes
2047 do_nodes $(comma_list $(nodes_list)) $NODE $LCTL dk $ERRLOG
2049 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
2055 $FAIL_ON_ERROR && exit 1 || true
2063 # use only if we are ignoring failures for this test, bugno required.
2064 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
2065 # e.g. error_ignore 5494 "your message"
2067 local TYPE="IGNORE (bz$1)"
2074 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
2075 [ "$TESTSUITELOG" ] && \
2076 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
2079 build_test_filter() {
2080 [ "$ONLY" ] && log "only running test `echo $ONLY`"
2084 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
2085 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
2086 [ "$EXCEPT_SLOW" ] && \
2087 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
2088 for E in $EXCEPT $ALWAYS_EXCEPT; do
2089 eval EXCEPT_${E}=true
2091 for E in $EXCEPT_SLOW; do
2092 eval EXCEPT_SLOW_${E}=true
2094 for G in $GRANT_CHECK_LIST; do
2095 eval GCHECK_ONLY_${G}=true
2104 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
2107 # print a newline if the last test was skipped
2108 export LAST_SKIPPED=
2112 export base=`basetest $1`
2113 if [ ! -z "$ONLY" ]; then
2115 if [ ${!testname}x != x ]; then
2116 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2121 if [ ${!testname}x != x ]; then
2122 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2131 if [ ${!testname}x != x ]; then
2133 TESTNAME=test_$1 skip "skipping excluded test $1"
2136 testname=EXCEPT_$base
2137 if [ ${!testname}x != x ]; then
2139 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
2142 testname=EXCEPT_SLOW_$1
2143 if [ ${!testname}x != x ]; then
2145 TESTNAME=test_$1 skip "skipping SLOW test $1"
2148 testname=EXCEPT_SLOW_$base
2149 if [ ${!testname}x != x ]; then
2151 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
2161 EQUALS="======================================================================"
2165 local suffixlen=$((${#EQUALS} - ${#msg}))
2166 [ $suffixlen -lt 5 ] && suffixlen=5
2167 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
2172 lsmod | grep lnet > /dev/null || load_modules
2184 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
2189 strace -o $TMP/$1.strace -ttt $*
2191 log "FINISHED: $*: rc $RC"
2196 $TEST_FAILED && echo -n "FAIL " || echo -n "PASS "
2201 FFREE=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filesfree | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2202 FTOTAL=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filestotal | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2203 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
2207 echo -n "Resetting fail_loc on all nodes..."
2208 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 2>/dev/null || true"
2216 export tdir=d0.${TESTSUITE}/d${base}
2218 local SAVE_UMASK=`umask`
2221 local BEFORE=`date +%s`
2223 log "== test $testnum: $message == `date +%H:%M:%S` ($BEFORE)"
2225 export TESTNAME=test_$testnum
2227 test_${testnum} || error "test_$testnum failed with $?"
2231 check_grant ${testnum} || error "check_grant $testnum failed with $?"
2232 check_catastrophe || error "LBUG/LASSERT detected"
2233 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
2234 pass "($((`date +%s` - $BEFORE))s)"
2242 (cd `dirname $1`; echo $PWD/`basename $1`)
2246 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
2247 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
2252 export base=`basetest $1`
2253 [ "$CHECK_GRANT" == "no" ] && return 0
2255 testname=GCHECK_ONLY_${base}
2256 [ ${!testname}x == x ] && return 0
2258 echo -n "checking grant......"
2260 # write some data to sync client lost_grant
2261 rm -f $DIR1/${tfile}_check_grant_* 2>&1
2262 for i in `seq $OSTCOUNT`; do
2263 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
2264 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
2265 count=1 > /dev/null 2>&1
2267 # sync all the data and make sure no pending data on server
2270 #get client grant and server grant
2272 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
2273 client_grant=$((client_grant + $d))
2276 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
2277 server_grant=$((server_grant + $d))
2280 # cleanup the check_grant file
2281 for i in `seq $OSTCOUNT`; do
2282 rm $DIR1/${tfile}_check_grant_$i
2285 #check whether client grant == server grant
2286 if [ $client_grant != $server_grant ]; then
2287 echo "failed: client:${client_grant} server: ${server_grant}"
2294 ########################
2300 ost=`echo $1 | awk -F_ '{print $3}'`
2301 if [ -z $ost ]; then
2302 ost=`echo $1 | sed 's/-osc.*//'`
2309 [ "$node" != "$(hostname)" ]
2315 for node in $(mdts_nodes); do
2316 remote_node $node && return 0
2323 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
2329 for node in $(osts_nodes) ; do
2330 remote_node $node && return 0
2337 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2343 MGS=$(facet_host mgs)
2344 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2350 for num in `seq $MDSCOUNT`; do
2351 MDSNODES="$MDSNODES $(facet_host mds$num)"
2353 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
2359 remote_ost && remote_mds
2363 local OSTNODES=$(facet_host ost1)
2366 for num in `seq $OSTCOUNT`; do
2367 local myOST=$(facet_host ost$num)
2368 OSTNODES="$OSTNODES $myOST"
2370 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
2376 # FIXME. We need a list of clients
2377 local myNODES=$HOSTNAME
2380 # CLIENTS (if specified) contains the local client
2381 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
2383 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
2384 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
2387 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
2392 remote_nodes_list () {
2393 local rnodes=$(nodes_list)
2394 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2398 init_clients_lists () {
2399 # Sanity check: exclude the local client from RCLIENTS
2400 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2402 # Sanity check: exclude the dup entries
2403 rclients=$(for i in $rclients; do echo $i; done | sort -u)
2405 local clients="$SINGLECLIENT $HOSTNAME $rclients"
2407 # Sanity check: exclude the dup entries from CLIENTS
2408 # for those configs which has SINGLCLIENT set to local client
2409 clients=$(for i in $clients; do echo $i; done | sort -u)
2411 CLIENTS=`comma_list $clients`
2412 local -a remoteclients=($rclients)
2413 for ((i=0; $i<${#remoteclients[@]}; i++)); do
2414 varname=CLIENT$((i + 2))
2415 eval $varname=${remoteclients[i]}
2418 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
2421 get_random_entry () {
2424 rnodes=${rnodes//,/ }
2426 local -a nodes=($rnodes)
2427 local num=${#nodes[@]}
2428 local i=$((RANDOM * num * 2 / 65536))
2435 lctl get_param version | grep -q patchless
2439 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
2444 echo $nodes | wc -w || true
2448 local nodes=$(osts_nodes)
2449 local osscount=$(get_node_count "$nodes")
2450 [ ! "$OSTCOUNT" = "$osscount" ]
2454 local nodes=$(mdts_nodes)
2455 local mdtcount=$(get_node_count "$nodes")
2456 [ ! "$MDSCOUNT" = "$mdtcount" ]
2459 generate_machine_file() {
2460 local nodes=${1//,/ }
2461 local machinefile=$2
2462 rm -f $machinefile || error "can't rm $machinefile"
2463 for node in $nodes; do
2464 echo $node >>$machinefile
2469 local file=$1/stripe
2471 $LFS getstripe -v $file || error
2475 check_runas_id_ret() {
2477 local myRUNAS_UID=$1
2478 local myRUNAS_GID=$2
2481 if [ -z "$myRUNAS" ]; then
2482 error_exit "myRUNAS command must be specified for check_runas_id"
2485 $myRUNAS krb5_login.sh || \
2486 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
2488 mkdir $DIR/d0_runas_test
2490 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
2491 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
2492 rm -rf $DIR/d0_runas_test
2497 local myRUNAS_UID=$1
2498 local myRUNAS_GID=$2
2501 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
2502 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
2503 Please set RUNAS_ID to some UID which exists on MDS and client or
2504 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
2507 # Run multiop in the background, but wait for it to print
2508 # "PAUSING" to its stdout before returning from this function.
2509 multiop_bg_pause() {
2510 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
2514 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
2517 echo "$MULTIOP_PROG $FILE v$ARGS"
2518 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
2520 echo "TMPPIPE=${TMPPIPE}"
2521 read -t 60 multiop_output < $TMPPIPE
2522 if [ $? -ne 0 ]; then
2527 if [ "$multiop_output" != "PAUSING" ]; then
2528 echo "Incorrect multiop output: $multiop_output"
2543 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
2549 inodes_available () {
2550 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
2554 # reset llite stat counters
2555 clear_llite_stats(){
2556 lctl set_param -n llite.*.stats 0
2559 # sum llite stat items
2560 calc_llite_stats() {
2561 local res=$(lctl get_param -n llite.*.stats |
2562 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2566 # reset osc stat counters
2568 lctl set_param -n osc.*.osc_stats 0
2571 # sum osc stat items
2573 local res=$(lctl get_param -n osc.*.osc_stats |
2574 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2579 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
2582 calc_osc_kbytes () {
2583 df $MOUNT > /dev/null
2584 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
2587 # save_lustre_params(node, parameter_mask)
2588 # generate a stream of formatted strings (<node> <param name>=<param value>)
2589 save_lustre_params() {
2591 do_node $1 "lctl get_param $2" | while read s; do echo "$1 $s"; done
2594 # restore lustre parameters from input stream, produces by save_lustre_params
2595 restore_lustre_params() {
2599 while IFS=" =" read node name val; do
2600 do_node $node "lctl set_param -n $name $val"
2604 check_catastrophe() {
2605 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
2606 local C=$CATASTROPHE
2607 [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
2609 if [ $rnodes ]; then
2610 do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
2611 if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
2627 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
2629 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
2630 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
2631 stripe_index=`awk '/obdidx/ {start = 1; getline; print $1; exit}' $tmp_file`
2635 # CMD: determine mds index where directory inode presents
2638 local file=$dir/f0.get_mds_dir_tmpfile
2642 local iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2643 local -a oldused=($iused)
2647 iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2648 local -a newused=($iused)
2651 for ((i=0; i<${#newused[@]}; i++)); do
2652 if [ ${oldused[$i]} -lt ${newused[$i]} ]; then
2658 error "mdt-s : inodes count OLD ${oldused[@]} NEW ${newused[@]}"
2662 local mpirun="$MPIRUN $MPIRUN_OPTIONS"
2663 local command="$mpirun $@"
2664 local mpilog=$TMP/mpi.log
2667 if [ "$MPI_USER" != root -a $mpirun ]; then
2668 echo "+ chmod 0777 $MOUNT"
2670 command="su $MPI_USER sh -c \"$command \""
2675 eval $command 2>&1 > $mpilog || true
2678 if [ $rc -eq 0 ] && grep -q "p4_error: : [^0]" $mpilog ; then
2685 mdsrate_cleanup () {
2686 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
2689 delayed_recovery_enabled () {
2690 local var=${SINGLEMDS}_svc
2691 do_facet $SINGLEMDS lctl get_param -n mdd.${!var}.stale_export_age > /dev/null 2>&1
2694 ########################
2695 convert_facet2name() {
2697 "ost" ) echo "OST0000" ;;
2698 "ost1") echo "OST0000" ;;
2699 "ost2") echo "OST0001" ;;
2700 "ost3") echo "OST0002" ;;
2701 "ost4") echo "OST0003" ;;
2702 "ost5") echo "OST0004" ;;
2703 *) error "unknown facet!" ;;
2707 get_clientosc_proc_path() {
2713 get_lustre_version () {
2714 local node=${1:-"mds"}
2715 do_facet $node $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
2718 get_mds_version_major () {
2719 local version=$(get_lustre_version mds)
2720 echo $version | awk -F. '{print $1}'
2723 get_mds_version_minor () {
2724 local version=$(get_lustre_version mds)
2725 echo $version | awk -F. '{print $2}'
2728 get_mdtosc_proc_path() {
2730 local major=$(get_mds_version_major)
2731 local minor=$(get_mds_version_minor)
2732 if [ $major -le 1 -a $minor -le 8 ] ; then
2735 echo "${ost}-osc-MDT0000"
2739 get_osc_import_name() {
2742 local name=$(convert_facet2name $ost)
2744 if [ "$node" == "mds" ]; then
2745 get_mdtosc_proc_path $name
2749 get_clientosc_proc_path $name
2753 wait_osc_import_state() {
2757 local ost=$(get_osc_import_name $node $ost_facet)
2762 CONN_PROC="osc.${FSNAME}-${ost}.ost_server_uuid"
2763 CONN_STATE=$(do_facet $node lctl get_param -n $CONN_PROC | cut -f2)
2764 while [ "${CONN_STATE}" != "${expected}" ]; do
2765 # for disconn we can check after proc entry is removed
2766 [ "x${CONN_STATE}" == "x" -a "${expected}" == "DISCONN" ] && return 0
2767 # disconnect rpc should be wait not more obd_timeout
2768 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
2769 error "can't put import for ${ost}(${ost_facet}) into ${expected} state" && return 1
2771 CONN_STATE=$(do_facet $node lctl get_param -n $CONN_PROC | cut -f2)
2775 log "${ost_facet} now in ${CONN_STATE} state"