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 # bug 18914: try to connect several times not only when
877 # check ps, but while check_catastrophe also
880 while [ $RC = 254 -a $tries -gt 0 ]; do
884 if ! check_catastrophe $client; then
886 if [ $RC -eq 254 ]; then
887 # FIXME: not sure how long we shuold sleep here
891 echo "check catastrophe failed: RC=$RC "
896 # We can continue try to connect if RC=254
897 # Just print the warning about this
898 if [ $RC = 254 ]; then
899 echo "got a return status of $RC from do_node while checking catastrophe on $client"
902 # see if the load is still on the client
905 while [ $RC = 254 -a $tries -gt 0 ]; do
909 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
914 if [ $RC = 254 ]; then
915 echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
916 # see if we can diagnose a bit why this is
921 check_client_loads () {
922 local clients=${1//,/ }
926 for client in $clients; do
927 check_client_load $client
929 if [ "$rc" != 0 ]; then
930 log "Client load failed on node $client, rc=$rc"
936 restart_client_loads () {
937 local clients=${1//,/ }
938 local expectedfail=${2:-""}
942 for client in $clients; do
943 check_client_load $client
945 if [ "$rc" != 0 -a "$expectedfail" ]; then
946 start_client_load $client
947 echo "Restarted client load: on $client. Checking ..."
948 check_client_load $client
950 if [ "$rc" != 0 ]; then
951 log "Client load failed to restart on node $client, rc=$rc"
952 # failure one client load means test fail
953 # we do not need to check other
961 # End recovery-scale functions
963 # verify that lustre actually cleaned up properly
965 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
966 error "LBUG/LASSERT detected"
967 BUSY=`dmesg | grep -i destruct || true`
970 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
974 check_mem_leak || exit 204
976 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
977 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
979 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
980 echo "$0: modules still loaded..." 1>&2
997 RESULT=$(do_node $node "$TEST")
998 if [ "$RESULT" == "$FINAL" ]; then
999 echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
1002 [ $WAIT -ge $MAX ] && break
1003 echo "Waiting $((MAX - WAIT)) secs for update"
1004 WAIT=$((WAIT + sleep))
1007 echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
1011 wait_update_facet () {
1013 wait_update $(facet_active_host $facet) "$@"
1016 wait_delete_completed () {
1017 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
1018 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1022 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
1024 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
1025 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1026 [ "$TOTAL" -eq "$TOTALPREV" ] && break
1027 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
1031 echo "Delete completed."
1036 check_network "$host" 900
1037 while ! do_node $host "ls -d $LUSTRE " > /dev/null; do sleep 5; done
1042 local host=`facet_active_host $facet`
1046 wait_recovery_complete () {
1049 # Use default policy if $2 is not passed by caller.
1050 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
1051 # as we are in process of changing obd_timeout in different ways
1052 # let's set MAX longer than that
1053 local MAX=${2:-$(( TIMEOUT * 4 ))}
1055 local var_svc=${facet}_svc
1056 local procfile="*.${!var_svc}.recovery_status"
1060 while [ $WAIT -lt $MAX ]; do
1061 STATUS=$(do_facet $facet lctl get_param -n $procfile | grep status)
1062 [[ $STATUS = "status: COMPLETE" ]] && return 0
1065 echo "Waiting $((MAX - WAIT)) secs for $facet recovery done. $STATUS"
1067 echo "$facet recovery not done in $MAX sec. $STATUS"
1077 # conf-sanity 31 takes a long time cleanup
1078 while [ $WAIT -lt 300 ]; do
1079 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
1080 [ -z "${running}" ] && return 0
1081 echo "waited $WAIT for${running}"
1082 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
1084 WAIT=$((WAIT + INTERVAL))
1086 echo "service didn't stop after $WAIT seconds. Still running:"
1091 wait_remote_prog () {
1097 [ "$PDSH" = "no_dsh" ] && return 0
1099 while [ $WAIT -lt $2 ]; do
1100 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
1101 [ -z "${running}" ] && return 0 || true
1102 echo "waited $WAIT for: "
1104 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
1106 WAIT=$((WAIT + INTERVAL))
1108 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
1109 [ -z "$pids" ] && return 0
1110 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
1111 # FIXME: not portable
1112 for pid in $pids; do
1113 cat /proc/${pid}/status || true
1114 cat /proc/${pid}/wchan || true
1116 kill -9 $pid || true
1125 # not every config has many clients
1126 if [ ! -z "$CLIENTS" ]; then
1127 $PDSH $CLIENTS "df $MOUNT" > /dev/null
1129 df $MOUNT > /dev/null
1133 client_reconnect() {
1134 uname -n >> $MOUNT/recon
1135 if [ -z "$CLIENTS" ]; then
1136 df $MOUNT; uname -n >> $MOUNT/recon
1138 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
1140 echo Connected clients:
1142 ls -l $MOUNT/recon > /dev/null
1149 echo "Failing $facet on node `facet_active_host $facet`"
1150 shutdown_facet $facet
1151 [ -n "$sleep_time" ] && sleep $sleep_time
1155 echo "df pid is $DFPID"
1156 change_active $facet
1157 local TO=`facet_active_host $facet`
1158 echo "Failover $facet to $TO"
1160 mount_facet $facet || error "Restart of $facet failed"
1169 do_facet $facet sync
1171 local svc=${facet}_svc
1172 do_facet $facet $LCTL --device %${!svc} notransno
1173 do_facet $facet $LCTL --device %${!svc} readonly
1174 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1175 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1178 replay_barrier_nodf() {
1179 local facet=$1 echo running=${running}
1180 do_facet $facet sync
1181 local svc=${facet}_svc
1182 echo Replay barrier on ${!svc}
1183 do_facet $facet $LCTL --device %${!svc} notransno
1184 do_facet $facet $LCTL --device %${!svc} readonly
1185 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1186 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1189 replay_barrier_nosync() {
1190 local facet=$1 echo running=${running}
1191 local svc=${facet}_svc
1192 echo Replay barrier on ${!svc}
1193 do_facet $facet $LCTL --device %${!svc} notransno
1194 do_facet $facet $LCTL --device %${!svc} readonly
1195 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1196 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1199 mds_evict_client() {
1200 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
1201 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
1204 ost_evict_client() {
1205 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
1206 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1210 facet_failover $* || error "failover: $?"
1211 df $MOUNT || error "post-failover df: $?"
1216 facet_failover $facet
1222 change_active $facet
1223 mount_facet $facet -o abort_recovery
1224 df $MOUNT || echo "first df failed: $?"
1226 df $MOUNT || error "post-failover df: $?"
1230 echo There is no lmc. This is mountconf, baby.
1235 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1236 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
1242 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1248 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1249 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1250 if [ -z "$ID" ]; then
1251 echo "Could not get a ptl id for $1..."
1260 h2name_or_ip "$1" "tcp"
1265 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1266 if type __h2elan >/dev/null 2>&1; then
1269 ID=`echo $1 | sed 's/[^0-9]*//g'`
1277 h2name_or_ip "$1" "openib"
1279 declare -fx h2openib
1282 h2name_or_ip "$1" "o2ib"
1289 [ "$facet" == client ] && echo -n $HOSTNAME && return
1290 varname=${facet}_HOST
1291 if [ -z "${!varname}" ]; then
1292 if [ "${facet:0:3}" == "ost" ]; then
1293 eval ${facet}_HOST=${ost_HOST}
1301 local activevar=${facet}active
1303 if [ -f $TMP/${facet}active ] ; then
1304 source $TMP/${facet}active
1307 active=${!activevar}
1308 if [ -z "$active" ] ; then
1315 facet_active_host() {
1317 local active=`facet_active $facet`
1318 if [ "$facet" == client ]; then
1321 echo `facet_host $active`
1327 local failover=${facet}failover
1328 host=`facet_host $failover`
1329 [ -z "$host" ] && return
1330 local curactive=`facet_active $facet`
1331 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1332 eval export ${facet}active=$facet
1334 eval export ${facet}active=$failover
1336 # save the active host for this facet
1337 local activevar=${facet}active
1338 echo "$activevar=${!activevar}" > $TMP/$activevar
1345 if [ "$HOST" = "$HOSTNAME" ]; then
1347 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1348 echo "cannot run remote command on $HOST with $myPDSH"
1352 echo "CMD: $HOST $@" >&2
1353 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
1356 if [ "$myPDSH" = "rsh" ]; then
1357 # we need this because rsh does not return exit code of an executed command
1358 local command_status="$TMP/cs"
1359 rsh $HOST ":> $command_status"
1360 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1361 cd $RPWD; sh -c \"$@\") ||
1362 echo command failed >$command_status"
1363 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1366 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
1367 return ${PIPESTATUS[0]}
1370 single_local_node () {
1371 [ "$1" = "$HOSTNAME" ]
1378 if $(single_local_node $rnodes); then
1383 # This is part from do_node
1386 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1387 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1390 echo "CMD: $rnodes $@" >&2
1391 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
1394 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
1395 return ${PIPESTATUS[0]}
1401 local HOST=`facet_active_host $facet`
1402 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1409 # make sure its not already running
1411 rm -f $TMP/${facet}active
1412 do_facet ${facet} $MKFS $*
1418 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1419 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1426 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
1427 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1435 # make sure we are using the primary server, so test-framework will
1436 # be able to clean up properly.
1437 activemds=`facet_active mds1`
1438 if [ $activemds != "mds1" ]; then
1442 local clients=$CLIENTS
1443 [ -z $clients ] && clients=$(hostname)
1445 zconf_umount_clients $clients $MOUNT "$*" || true
1446 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
1448 [ "$CLIENTONLY" ] && return
1449 # The add fn does rm ${facet}active file, this would be enough
1450 # if we use do_facet <facet> only after the facet added, but
1451 # currently we use do_facet mds in local.sh
1452 for num in `seq $MDSCOUNT`; do
1454 rm -f ${TMP}/mds${num}active
1457 for num in `seq $OSTCOUNT`; do
1459 rm -f $TMP/ost${num}active
1474 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
1478 if [ "$IAMDIR" == "yes" ]; then
1479 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --iam-dir"
1480 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --iam-dir"
1483 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1485 if [ ! -z $SEC ]; then
1486 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --param srpc.flavor.default=$SEC"
1487 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --param srpc.flavor.default=$SEC"
1488 OST_MKFS_OPTS="$OST_MKFS_OPTS --param srpc.flavor.default=$SEC"
1492 # We need ldiskfs here, may as well load them all
1494 [ "$CLIENTONLY" ] && return
1495 echo "Formatting mdts, osts"
1496 for num in `seq $MDSCOUNT`; do
1497 echo "Format mds$num: $(mdsdevname $num)"
1499 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
1501 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
1505 for num in `seq $OSTCOUNT`; do
1506 echo "Format ost$num: $(ostdevname $num)"
1508 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
1510 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
1516 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1520 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1524 # 0: success, the old identity set already.
1525 # 1: success, the old identity does not set.
1530 local j=`expr $num - 1`
1531 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
1533 if [ -z "$MDT" ]; then
1537 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1540 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
1542 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
1545 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush \"-1\""
1547 if [ $old = "NONE" ]; then
1556 zconf_umount `hostname` $1 || error "umount failed"
1557 zconf_mount `hostname` $1 || error "mount failed"
1560 writeconf_facet () {
1564 do_facet $facet "$TUNEFS --writeconf $dev"
1568 for num in `seq $MDSCOUNT`; do
1569 DEVNAME=$(mdsdevname $num)
1570 writeconf_facet mds$num $DEVNAME
1573 for num in `seq $OSTCOUNT`; do
1574 DEVNAME=$(ostdevname $num)
1575 writeconf_facet ost$num $DEVNAME
1580 sanity_mount_check ||
1581 error "environments are insane!"
1585 if [ -z "$CLIENTONLY" ]; then
1586 echo "Setup mdts, osts"
1587 echo $WRITECONF | grep -q "writeconf" && \
1589 for num in `seq $MDSCOUNT`; do
1590 DEVNAME=$(mdsdevname $num)
1591 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1593 # We started mds, now we should set failover variables properly.
1594 # Set mds${num}failover_HOST if it is not set (the default failnode).
1595 local varname=mds${num}failover_HOST
1596 if [ -z "${!varname}" ]; then
1597 eval mds${num}failover_HOST=$(facet_host mds$num)
1600 if [ $IDENTITY_UPCALL != "default" ]; then
1601 switch_identity $num $IDENTITY_UPCALL
1604 for num in `seq $OSTCOUNT`; do
1605 DEVNAME=$(ostdevname $num)
1606 start ost$num $DEVNAME $OST_MOUNT_OPTS
1608 # We started ost$num, now we should set ost${num}failover variable properly.
1609 # Set ost${num}failover_HOST if it is not set (the default failnode).
1610 varname=ost${num}failover_HOST
1611 if [ -z "${!varname}" ]; then
1612 eval ost${num}failover_HOST=$(facet_host ost${num})
1617 # wait a while to allow sptlrpc configuration be propogated to targets,
1618 # only needed when mounting new target devices.
1621 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1623 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1625 if [ "$MOUNT_2" ]; then
1626 mount_client $MOUNT2
1627 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1632 # by remounting mdt before ost, initial connect from mdt to ost might
1633 # timeout because ost is not ready yet. wait some time to its fully
1634 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1635 # by a context negotiation rpc with $TIMEOUT.
1636 # FIXME better by monitoring import status.
1638 sleep $((TIMEOUT + 5))
1644 mounted_lustre_filesystems() {
1645 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1648 init_facet_vars () {
1655 eval export ${facet}_dev=${device}
1656 eval export ${facet}_opt=\"$@\"
1658 local dev=${facet}_dev
1659 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
1660 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1662 eval export ${facet}_svc=${label}
1664 local varname=${facet}failover_HOST
1665 if [ -z "${!varname}" ]; then
1666 eval $varname=$(facet_host $facet)
1669 # ${facet}failover_dev is set in cfg file
1670 varname=${facet}failover_dev
1671 if [ -n "${!varname}" ] ; then
1672 eval export ${facet}failover_dev=${!varname}
1674 eval export ${facet}failover_dev=$device
1678 init_facets_vars () {
1681 if ! remote_mds_nodsh; then
1682 for num in `seq $MDSCOUNT`; do
1683 DEVNAME=`mdsdevname $num`
1684 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
1688 remote_ost_nodsh && return
1690 for num in `seq $OSTCOUNT`; do
1691 DEVNAME=`ostdevname $num`
1692 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1696 mds_sanity_check () {
1700 while [ $period -lt $timeout ]; do
1701 count=$(do_facet $SINGLEMDS "lctl dl | grep 'osc.*mdtlov_UUID' | grep ' IN ' 2>/dev/null | wc -l")
1702 if [ $count -eq 0 ]; then
1706 echo "There are $count OST are inactive, wait $period seconds, and try again"
1708 period=$((period+3))
1711 [ $period -lt $timeout ] || log "$count OST are inactive after $timeout seconds, give up"
1715 SOM_ENABLED=$(do_facet $SINGLEMDS "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
1719 init_param_vars () {
1720 if ! remote_ost_nodsh && ! remote_mds_nodsh; then
1721 export MDSVER=$(do_facet $SINGLEMDS "lctl get_param version" | cut -d. -f1,2)
1722 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
1723 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
1727 TIMEOUT=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1729 log "Using TIMEOUT=$TIMEOUT"
1731 mds_sanity_check $TIMEOUT
1733 if [ x"$(som_check)" = x"enabled" ]; then
1736 if [ "$ENABLE_QUOTA" ]; then
1737 setup_quota $MOUNT || return 2
1743 local myMGS_host=$mgs_HOST
1744 if [ "$NETTYPE" = "ptl" ]; then
1745 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
1748 echo Checking config lustre mounted on $mntpt
1749 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
1750 mgshost=$(echo $mgshost | awk -F: '{print $1}')
1752 if [ "$mgshost" != "$myMGS_host" ]; then
1753 log "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
1754 Please use correct config or set mds_HOST correctly!"
1757 sanity_mount_check ||
1758 error "environments are insane!"
1762 local mdstimeout=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1763 local cltimeout=$(lctl get_param -n timeout)
1764 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
1765 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
1770 check_and_setup_lustre() {
1771 local MOUNTED=$(mounted_lustre_filesystems)
1772 if [ -z "$MOUNTED" ] || ! $(echo $MOUNTED | grep -w -q $MOUNT); then
1773 [ "$REFORMAT" ] && formatall
1775 MOUNTED=$(mounted_lustre_filesystems | head -1)
1776 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
1777 export I_MOUNTED=yes
1783 if [ "$ONLY" == "setup" ]; then
1788 cleanup_and_setup_lustre() {
1789 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
1790 lctl set_param debug=0 || true
1792 if [ "$ONLY" == "cleanup" ]; then
1796 check_and_setup_lustre
1799 check_and_cleanup_lustre() {
1800 if [ "`mount | grep $MOUNT`" ]; then
1801 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1802 [ "$ENABLE_QUOTA" ] && restore_quota_type || true
1804 if [ "$I_MOUNTED" = "yes" ]; then
1805 cleanupall -f || error "cleanup failed"
1817 while [ $NETWORK -eq 0 ]; do
1818 ping -c 1 -w 3 $1 > /dev/null
1819 if [ $? -eq 0 ]; then
1823 echo "waiting for $1, $((MAX - WAIT)) secs left"
1826 if [ $WAIT -gt $MAX ]; then
1827 echo "Network not available"
1833 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
1844 # the sed converts spaces to commas, but leaves the last space
1845 # alone, so the line doesn't end with a comma.
1846 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
1849 # list, excluded are the comma separated lists
1850 exclude_items_from_list () {
1856 for item in ${excluded//,/ }; do
1857 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
1859 echo $(comma_list $list)
1862 # list, expand are the comma separated lists
1864 local list=${1//,/ }
1865 local expand=${2//,/ }
1868 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
1869 echo $(comma_list $expanded)
1873 (cd `dirname $1`; echo $PWD/`basename $1`)
1877 local name=$(echo $1 | tr "[:upper:]" "[:lower:]")
1878 local type=$(echo $1 | tr "[:lower:]" "[:upper:]")
1881 local count=${type}COUNT
1882 for ((i=1; i<=${!count}; i++)) do
1883 list="$list ${name}$i"
1885 echo $(comma_list $list)
1888 ##################################
1889 # Adaptive Timeouts funcs
1892 # only check mds, we assume at_max is the same on all nodes
1893 local at_max=$(do_facet $SINGLEMDS "lctl get_param -n at_max")
1894 if [ $at_max -eq 0 ]; then
1904 # suppose that all ost-s has the same at_max set
1905 if [ $facet == "ost" ]; then
1906 do_facet ost1 "lctl get_param -n at_max"
1908 do_facet $facet "lctl get_param -n at_max"
1918 if [ $facet == "ost" ]; then
1919 for i in `seq $OSTCOUNT`; do
1920 do_facet ost$i "lctl set_param at_max=$at_max"
1923 elif [ $facet == "mds" ]; then
1924 for i in `seq $MDSCOUNT`; do
1925 do_facet mds$i "lctl set_param at_max=$at_max"
1928 do_facet $facet "lctl set_param at_max=$at_max"
1933 ##################################
1937 # OBD_FAIL_MDS_ALL_REQUEST_NET
1939 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
1940 do_facet client "$1" || RC=$?
1941 do_facet $SINGLEMDS lctl set_param fail_loc=0
1946 # OBD_FAIL_MDS_ALL_REPLY_NET
1948 do_facet $SINGLEMDS lctl set_param fail_loc=0x122
1949 do_facet client "$@" || RC=$?
1950 do_facet $SINGLEMDS lctl set_param fail_loc=0
1954 drop_reint_reply() {
1955 # OBD_FAIL_MDS_REINT_NET_REP
1957 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
1958 do_facet client "$@" || RC=$?
1959 do_facet $SINGLEMDS lctl set_param fail_loc=0
1964 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1966 do_facet ost1 lctl set_param fail_loc=0x214
1967 do_facet client "$1" || RC=$?
1968 do_facet client "sync"
1969 do_facet ost1 lctl set_param fail_loc=0
1973 drop_ldlm_cancel() {
1974 #define OBD_FAIL_LDLM_CANCEL 0x304
1976 do_facet client lctl set_param fail_loc=0x304
1977 do_facet client "$@" || RC=$?
1978 do_facet client lctl set_param fail_loc=0
1982 drop_bl_callback() {
1983 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
1985 do_facet client lctl set_param fail_loc=0x305
1986 do_facet client "$@" || RC=$?
1987 do_facet client lctl set_param fail_loc=0
1992 #define OBD_FAIL_LDLM_REPLY 0x30c
1994 do_facet $SINGLEMDS lctl set_param fail_loc=0x30c
1995 do_facet client "$@" || RC=$?
1996 do_facet $SINGLEMDS lctl set_param fail_loc=0
2004 echo "clearing fail_loc on $facet"
2005 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
2008 set_nodes_failloc () {
2009 do_nodes $(comma_list $1) lctl set_param fail_loc=$2
2012 cancel_lru_locks() {
2013 $LCTL mark "cancel_lru_locks $1 start"
2014 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
2015 $LCTL set_param -n $d=clear
2017 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
2018 $LCTL mark "cancel_lru_locks $1 stop"
2023 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
2024 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
2025 echo "$DEFAULT_LRU_SIZE"
2030 lctl set_param ldlm.namespaces.*$1*.lru_size=0
2033 lru_resize_disable()
2035 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
2040 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
2041 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
2042 echo there is still data in page cache $FILE ?
2043 lctl get_param -n $FILE
2051 DEBUGSAVE="$(lctl get_param -n debug)"
2055 [ -n "$DEBUGSAVE" ] && lctl set_param debug="${DEBUGSAVE}"
2059 ##################################
2061 ##################################
2064 local TYPE=${TYPE:-"FAIL"}
2066 lctl set_param fail_loc=0 2>/dev/null || true
2067 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
2068 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
2069 echo "Dumping lctl log to $ERRLOG"
2070 # We need to dump the logs on all nodes
2071 do_nodes $(comma_list $(nodes_list)) $NODE $LCTL dk $ERRLOG
2073 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
2079 $FAIL_ON_ERROR && exit 1 || true
2087 # use only if we are ignoring failures for this test, bugno required.
2088 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
2089 # e.g. error_ignore 5494 "your message"
2091 local TYPE="IGNORE (bz$1)"
2098 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
2099 [ "$TESTSUITELOG" ] && \
2100 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
2103 build_test_filter() {
2104 [ "$ONLY" ] && log "only running test `echo $ONLY`"
2108 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
2109 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
2110 [ "$EXCEPT_SLOW" ] && \
2111 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
2112 for E in $EXCEPT $ALWAYS_EXCEPT; do
2113 eval EXCEPT_${E}=true
2115 for E in $EXCEPT_SLOW; do
2116 eval EXCEPT_SLOW_${E}=true
2118 for G in $GRANT_CHECK_LIST; do
2119 eval GCHECK_ONLY_${G}=true
2128 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
2131 # print a newline if the last test was skipped
2132 export LAST_SKIPPED=
2136 export base=`basetest $1`
2137 if [ ! -z "$ONLY" ]; then
2139 if [ ${!testname}x != x ]; then
2140 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2145 if [ ${!testname}x != x ]; then
2146 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2155 if [ ${!testname}x != x ]; then
2157 TESTNAME=test_$1 skip "skipping excluded test $1"
2160 testname=EXCEPT_$base
2161 if [ ${!testname}x != x ]; then
2163 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
2166 testname=EXCEPT_SLOW_$1
2167 if [ ${!testname}x != x ]; then
2169 TESTNAME=test_$1 skip "skipping SLOW test $1"
2172 testname=EXCEPT_SLOW_$base
2173 if [ ${!testname}x != x ]; then
2175 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
2185 EQUALS="======================================================================"
2189 local suffixlen=$((${#EQUALS} - ${#msg}))
2190 [ $suffixlen -lt 5 ] && suffixlen=5
2191 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
2196 lsmod | grep lnet > /dev/null || load_modules
2208 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
2213 strace -o $TMP/$1.strace -ttt $*
2215 log "FINISHED: $*: rc $RC"
2220 $TEST_FAILED && echo -n "FAIL " || echo -n "PASS "
2225 FFREE=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filesfree | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2226 FTOTAL=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filestotal | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2227 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
2231 echo -n "Resetting fail_loc on all nodes..."
2232 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 2>/dev/null || true"
2240 export tdir=d0.${TESTSUITE}/d${base}
2242 local SAVE_UMASK=`umask`
2245 local BEFORE=`date +%s`
2247 log "== test $testnum: $message == `date +%H:%M:%S` ($BEFORE)"
2249 export TESTNAME=test_$testnum
2251 test_${testnum} || error "test_$testnum failed with $?"
2255 check_grant ${testnum} || error "check_grant $testnum failed with $?"
2256 check_catastrophe || error "LBUG/LASSERT detected"
2257 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
2258 pass "($((`date +%s` - $BEFORE))s)"
2266 (cd `dirname $1`; echo $PWD/`basename $1`)
2270 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
2271 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
2276 export base=`basetest $1`
2277 [ "$CHECK_GRANT" == "no" ] && return 0
2279 testname=GCHECK_ONLY_${base}
2280 [ ${!testname}x == x ] && return 0
2282 echo -n "checking grant......"
2284 # write some data to sync client lost_grant
2285 rm -f $DIR1/${tfile}_check_grant_* 2>&1
2286 for i in `seq $OSTCOUNT`; do
2287 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
2288 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
2289 count=1 > /dev/null 2>&1
2291 # sync all the data and make sure no pending data on server
2294 #get client grant and server grant
2296 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
2297 client_grant=$((client_grant + $d))
2300 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
2301 server_grant=$((server_grant + $d))
2304 # cleanup the check_grant file
2305 for i in `seq $OSTCOUNT`; do
2306 rm $DIR1/${tfile}_check_grant_$i
2309 #check whether client grant == server grant
2310 if [ $client_grant != $server_grant ]; then
2311 echo "failed: client:${client_grant} server: ${server_grant}"
2318 ########################
2324 ost=`echo $1 | awk -F_ '{print $3}'`
2325 if [ -z $ost ]; then
2326 ost=`echo $1 | sed 's/-osc.*//'`
2333 [ "$node" != "$(hostname)" ]
2339 for node in $(mdts_nodes); do
2340 remote_node $node && return 0
2347 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
2353 for node in $(osts_nodes) ; do
2354 remote_node $node && return 0
2361 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2367 MGS=$(facet_host mgs)
2368 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2374 for num in `seq $MDSCOUNT`; do
2375 MDSNODES="$MDSNODES $(facet_host mds$num)"
2377 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
2383 remote_ost && remote_mds
2387 local OSTNODES=$(facet_host ost1)
2390 for num in `seq $OSTCOUNT`; do
2391 local myOST=$(facet_host ost$num)
2392 OSTNODES="$OSTNODES $myOST"
2394 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
2400 # FIXME. We need a list of clients
2401 local myNODES=$HOSTNAME
2404 # CLIENTS (if specified) contains the local client
2405 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
2407 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
2408 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
2411 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
2416 remote_nodes_list () {
2417 local rnodes=$(nodes_list)
2418 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2422 init_clients_lists () {
2423 # Sanity check: exclude the local client from RCLIENTS
2424 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2426 # Sanity check: exclude the dup entries
2427 rclients=$(for i in $rclients; do echo $i; done | sort -u)
2429 local clients="$SINGLECLIENT $HOSTNAME $rclients"
2431 # Sanity check: exclude the dup entries from CLIENTS
2432 # for those configs which has SINGLCLIENT set to local client
2433 clients=$(for i in $clients; do echo $i; done | sort -u)
2435 CLIENTS=`comma_list $clients`
2436 local -a remoteclients=($rclients)
2437 for ((i=0; $i<${#remoteclients[@]}; i++)); do
2438 varname=CLIENT$((i + 2))
2439 eval $varname=${remoteclients[i]}
2442 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
2445 get_random_entry () {
2448 rnodes=${rnodes//,/ }
2450 local -a nodes=($rnodes)
2451 local num=${#nodes[@]}
2452 local i=$((RANDOM * num * 2 / 65536))
2459 lctl get_param version | grep -q patchless
2463 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
2468 echo $nodes | wc -w || true
2472 local nodes=$(osts_nodes)
2473 local osscount=$(get_node_count "$nodes")
2474 [ ! "$OSTCOUNT" = "$osscount" ]
2478 local nodes=$(mdts_nodes)
2479 local mdtcount=$(get_node_count "$nodes")
2480 [ ! "$MDSCOUNT" = "$mdtcount" ]
2483 generate_machine_file() {
2484 local nodes=${1//,/ }
2485 local machinefile=$2
2486 rm -f $machinefile || error "can't rm $machinefile"
2487 for node in $nodes; do
2488 echo $node >>$machinefile
2493 local file=$1/stripe
2495 $LFS getstripe -v $file || error
2499 check_runas_id_ret() {
2501 local myRUNAS_UID=$1
2502 local myRUNAS_GID=$2
2505 if [ -z "$myRUNAS" ]; then
2506 error_exit "myRUNAS command must be specified for check_runas_id"
2509 $myRUNAS krb5_login.sh || \
2510 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
2512 mkdir $DIR/d0_runas_test
2514 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
2515 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
2516 rm -rf $DIR/d0_runas_test
2521 local myRUNAS_UID=$1
2522 local myRUNAS_GID=$2
2525 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
2526 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
2527 Please set RUNAS_ID to some UID which exists on MDS and client or
2528 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
2531 # Run multiop in the background, but wait for it to print
2532 # "PAUSING" to its stdout before returning from this function.
2533 multiop_bg_pause() {
2534 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
2538 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
2541 echo "$MULTIOP_PROG $FILE v$ARGS"
2542 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
2544 echo "TMPPIPE=${TMPPIPE}"
2545 read -t 60 multiop_output < $TMPPIPE
2546 if [ $? -ne 0 ]; then
2551 if [ "$multiop_output" != "PAUSING" ]; then
2552 echo "Incorrect multiop output: $multiop_output"
2567 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
2573 inodes_available () {
2574 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
2578 # reset llite stat counters
2579 clear_llite_stats(){
2580 lctl set_param -n llite.*.stats 0
2583 # sum llite stat items
2584 calc_llite_stats() {
2585 local res=$(lctl get_param -n llite.*.stats |
2586 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2590 # reset osc stat counters
2592 lctl set_param -n osc.*.osc_stats 0
2595 # sum osc stat items
2597 local res=$(lctl get_param -n osc.*.osc_stats |
2598 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2603 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
2606 calc_osc_kbytes () {
2607 df $MOUNT > /dev/null
2608 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
2611 # save_lustre_params(node, parameter_mask)
2612 # generate a stream of formatted strings (<node> <param name>=<param value>)
2613 save_lustre_params() {
2615 do_node $1 "lctl get_param $2" | while read s; do echo "$1 $s"; done
2618 # restore lustre parameters from input stream, produces by save_lustre_params
2619 restore_lustre_params() {
2623 while IFS=" =" read node name val; do
2624 do_node $node "lctl set_param -n $name $val"
2628 check_catastrophe() {
2629 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
2630 local C=$CATASTROPHE
2631 [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
2633 if [ $rnodes ]; then
2634 do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
2635 if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
2651 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
2653 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
2654 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
2655 stripe_index=`awk '/obdidx/ {start = 1; getline; print $1; exit}' $tmp_file`
2659 # CMD: determine mds index where directory inode presents
2662 local file=$dir/f0.get_mds_dir_tmpfile
2666 local iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2667 local -a oldused=($iused)
2671 iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2672 local -a newused=($iused)
2675 for ((i=0; i<${#newused[@]}; i++)); do
2676 if [ ${oldused[$i]} -lt ${newused[$i]} ]; then
2682 error "mdt-s : inodes count OLD ${oldused[@]} NEW ${newused[@]}"
2686 local mpirun="$MPIRUN $MPIRUN_OPTIONS"
2687 local command="$mpirun $@"
2688 local mpilog=$TMP/mpi.log
2691 if [ "$MPI_USER" != root -a $mpirun ]; then
2692 echo "+ chmod 0777 $MOUNT"
2694 command="su $MPI_USER sh -c \"$command \""
2699 eval $command 2>&1 > $mpilog || true
2702 if [ $rc -eq 0 ] && grep -q "p4_error: : [^0]" $mpilog ; then
2709 mdsrate_cleanup () {
2710 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
2713 delayed_recovery_enabled () {
2714 local var=${SINGLEMDS}_svc
2715 do_facet $SINGLEMDS lctl get_param -n mdd.${!var}.stale_export_age > /dev/null 2>&1
2718 ########################
2719 convert_facet2name() {
2721 "ost" ) echo "OST0000" ;;
2722 "ost1") echo "OST0000" ;;
2723 "ost2") echo "OST0001" ;;
2724 "ost3") echo "OST0002" ;;
2725 "ost4") echo "OST0003" ;;
2726 "ost5") echo "OST0004" ;;
2727 *) error "unknown facet!" ;;
2731 get_clientosc_proc_path() {
2737 get_lustre_version () {
2738 local node=${1:-"mds"}
2739 do_facet $node $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
2742 get_mds_version_major () {
2743 local version=$(get_lustre_version mds)
2744 echo $version | awk -F. '{print $1}'
2747 get_mds_version_minor () {
2748 local version=$(get_lustre_version mds)
2749 echo $version | awk -F. '{print $2}'
2752 get_mdtosc_proc_path() {
2754 local major=$(get_mds_version_major)
2755 local minor=$(get_mds_version_minor)
2756 if [ $major -le 1 -a $minor -le 8 ] ; then
2759 echo "${ost}-osc-MDT0000"
2763 get_osc_import_name() {
2766 local name=$(convert_facet2name $ost)
2768 if [ "$node" == "mds" ]; then
2769 get_mdtosc_proc_path $name
2773 get_clientosc_proc_path $name
2777 wait_osc_import_state() {
2781 local ost=$(get_osc_import_name $node $ost_facet)
2786 CONN_PROC="osc.${FSNAME}-${ost}.ost_server_uuid"
2787 CONN_STATE=$(do_facet $node lctl get_param -n $CONN_PROC | cut -f2)
2788 while [ "${CONN_STATE}" != "${expected}" ]; do
2789 # for disconn we can check after proc entry is removed
2790 [ "x${CONN_STATE}" == "x" -a "${expected}" == "DISCONN" ] && return 0
2791 # disconnect rpc should be wait not more obd_timeout
2792 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
2793 error "can't put import for ${ost}(${ost_facet}) into ${expected} state" && return 1
2795 CONN_STATE=$(do_facet $node lctl get_param -n $CONN_PROC | cut -f2)
2799 log "${ost_facet} now in ${CONN_STATE} state"