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]"
46 [ "$TESTSUITE" == "lfscktest" ] && return 0
47 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to ${ONLY}."
48 local form="%-13s %-17s %s\n"
49 printf "$form" "status" "script" "skipped tests E(xcluded) S(low)"
50 echo "------------------------------------------------------------------------------------"
51 for O in $TESTSUITE_LIST; do
54 local o=$(echo $O | tr "[:upper:]" "[:lower:]")
57 local log=${TMP}/${o}.log
58 [ -f $log ] && skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
59 [ -f $log ] && slow=$(grep SLOW $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
60 [ "${!O}" = "done" ] && \
61 printf "$form" "Done" "$O" "E=$skipped" && \
62 [ -n "$slow" ] && printf "$form" "-" "-" "S=$slow"
66 for O in $TESTSUITE_LIST; do
67 if [ "${!O}" = "no" ]; then
69 # only for those tests suits which are run directly from acc-sm script:
70 # bonnie, iozone, etc.
71 if [ -f "$TESTSUITELOG" ] && grep FAIL $TESTSUITELOG | grep -q ' '$O ; then
72 printf "$form" "UNFINISHED" "$O" ""
74 printf "$form" "Skipped" "$O" ""
79 for O in $TESTSUITE_LIST; do
80 [ "${!O}" = "done" -o "${!O}" = "no" ] || \
81 printf "$form" "UNFINISHED" "$O" ""
86 export LUSTRE=`absolute_path $LUSTRE`
87 export TESTSUITE=`basename $0 .sh`
88 export TEST_FAILED=false
89 export FAIL_ON_SKIP_ENV=${FAIL_ON_SKIP_ENV:-false}
91 export MKE2FS=${MKE2FS:-mke2fs}
92 export DEBUGFS=${DEBUGFS:-debugfs}
93 export TUNE2FS=${TUNE2FS:-tune2fs}
94 export E2LABEL=${E2LABEL:-e2label}
95 export DUMPE2FS=${DUMPE2FS:-dumpe2fs}
96 export E2FSCK=${E2FSCK:-e2fsck}
98 #[ -d /r ] && export ROOT=${ROOT:-/r}
99 export TMP=${TMP:-$ROOT/tmp}
100 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
101 export HOSTNAME=${HOSTNAME:-`hostname`}
102 if ! echo $PATH | grep -q $LUSTRE/utils; then
103 export PATH=$PATH:$LUSTRE/utils
105 if ! echo $PATH | grep -q $LUSTRE/utils/gss; then
106 export PATH=$PATH:$LUSTRE/utils/gss
108 if ! echo $PATH | grep -q $LUSTRE/tests; then
109 export PATH=$PATH:$LUSTRE/tests
111 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mpi/mdsrate"}
112 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
113 if ! echo $PATH | grep -q $LUSTRE/tests/racer; then
114 export PATH=$PATH:$LUSTRE/tests/racer
116 if ! echo $PATH | grep -q $LUSTRE/tests/mpi; then
117 export PATH=$PATH:$LUSTRE/tests/mpi
119 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
120 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
121 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
122 [ ! -f "$LFS" ] && export LFS=$(which lfs)
123 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
124 if [ ! -f "$L_GETIDENTITY" ]; then
125 if `which l_getidentity > /dev/null 2>&1`; then
126 export L_GETIDENTITY=$(which l_getidentity)
128 export L_GETIDENTITY=NONE
131 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
132 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
133 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
134 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
135 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
136 export LUSTRE_RMMOD=${LUSTRE_RMMOD:-$LUSTRE/scripts/lustre_rmmod}
137 [ ! -f "$LUSTRE_RMMOD" ] && export LUSTRE_RMMOD=$(which lustre_rmmod 2> /dev/null)
138 export FSTYPE=${FSTYPE:-"ldiskfs"}
139 export NAME=${NAME:-local}
140 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
141 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
142 export LGSSD=$(which lgssd)
143 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
144 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd 2> /dev/null)
145 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
147 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
150 if [ "$ACCEPTOR_PORT" ]; then
151 export PORT_OPT="--port $ACCEPTOR_PORT"
156 echo "Using GSS/krb5 ptlrpc security flavor"
157 which lgss_keyring > /dev/null 2>&1 || \
158 error "built with gss disabled! SEC=$SEC"
169 IDENTITY_UPCALL=false
173 # Paths on remote nodes, if different
174 export RLUSTRE=${RLUSTRE:-$LUSTRE}
175 export RPWD=${RPWD:-$PWD}
176 export I_MOUNTED=${I_MOUNTED:-"no"}
180 while getopts "rvwf:" opt $*; do
183 r) REFORMAT=--reformat;;
185 w) WRITECONF=writeconf;;
190 shift $((OPTIND - 1))
193 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
198 2.4.*) EXT=".o"; USE_QUOTA=no; [ ! "$CLIENTONLY" ] && FSTYPE=ext3;;
199 *) EXT=".ko"; USE_QUOTA=yes;;
206 BASE=`basename $module $EXT`
207 lsmod | grep -q ${BASE} || \
208 if [ -f ${LUSTRE}/${module}${EXT} ]; then
209 insmod ${LUSTRE}/${module}${EXT} $@
211 # must be testing a "make install" or "rpm" installation
212 # note failed to load ptlrpc_gss is considered not fatal
213 if [ "$BASE" == "ptlrpc_gss" ]; then
214 modprobe $BASE $@ 2>/dev/null || echo "gss/krb5 is not supported"
222 if [ -n "$MODPROBE" ]; then
226 if [ "$HAVE_MODULES" = true ]; then
232 echo Loading modules from $LUSTRE
233 load_module ../libcfs/libcfs/libcfs
234 [ "$PTLDEBUG" ] && lctl set_param debug="$PTLDEBUG"
235 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug="${SUBSYSTEM# }"
237 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
238 [ ! "$MODPROBECONF" -a -d /etc/modprobe.d ] && MODPROBECONF=/etc/modprobe.d/Lustre
239 [ -z "$LNETOPTS" -a "$MODPROBECONF" ] && \
240 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
241 echo $LNETOPTS | grep -q "accept=all" || LNETOPTS="$LNETOPTS accept=all";
242 echo "lnet options: '$LNETOPTS'"
243 # note that insmod will ignore anything in modprobe.conf
244 load_module ../lnet/lnet/lnet $LNETOPTS
245 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
246 load_module ../lnet/klnds/$LNETLND
247 load_module lvfs/lvfs
248 load_module obdclass/obdclass
249 load_module ptlrpc/ptlrpc
250 load_module ptlrpc/gss/ptlrpc_gss
251 [ "$USE_QUOTA" = "yes" -a "$LQUOTA" != "no" ] && load_module quota/lquota
259 if [ -z "$CLIENTONLY" ] && [ -z "$CLIENTMODSONLY" ]; then
260 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
261 grep -q jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
262 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
267 load_module lvfs/fsfilt_$FSTYPE
271 load_module obdfilter/obdfilter
274 load_module llite/lustre
275 load_module llite/llite_lloop
276 [ -d /r ] && OGDB=${OGDB:-"/r/tmp"}
278 rm -f $OGDB/ogdb-$HOSTNAME
279 $LCTL modules > $OGDB/ogdb-$HOSTNAME
281 # 'mount' doesn't look in $PATH, just sbin
282 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
286 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
287 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
288 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
289 echo "$LEAK_LUSTRE" 1>&2
290 echo "$LEAK_PORTALS" 1>&2
291 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
292 echo "Memory leaks detected"
293 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
299 wait_exit_ST client # bug 12845
301 $LUSTRE_RMMOD $FSTYPE || return 2
305 check_mem_leak || return 254
307 echo "modules unloaded."
311 check_gss_daemon_facet() {
315 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
316 if [ $num -ne 1 ]; then
317 echo "$num instance of $dname on $facet"
326 do_facet $facet "killall -2 $@ 2>/dev/null || true"
329 start_gss_daemons() {
331 for num in `seq $MDSCOUNT`; do
332 do_facet mds$num "$LSVCGSSD -v"
334 do_facet mds$num "$LGSSD -v"
338 for num in `seq $OSTCOUNT`; do
339 do_facet ost$num "$LSVCGSSD -v"
342 # FIXME: is "client" the right facet name?
344 do_facet client "$LGSSD -v"
347 # wait daemons entering "stable" status
351 # check daemons are running
353 for num in `seq $MDSCOUNT`; do
354 check_gss_daemon_facet mds$num lsvcgssd
356 check_gss_daemon_facet mds$num lgssd
359 for num in `seq $OSTCOUNT`; do
360 check_gss_daemon_facet ost$num lsvcgssd
363 check_gss_daemon_facet client lgssd
368 for num in `seq $MDSCOUNT`; do
369 send_sigint mds$num lsvcgssd lgssd
371 for num in `seq $OSTCOUNT`; do
372 send_sigint ost$num lsvcgssd
374 send_sigint client lgssd
381 if [ -n "$LGSS_KEYRING_DEBUG" ]; then
382 echo $LGSS_KEYRING_DEBUG > /proc/fs/lustre/sptlrpc/gss/lgss_keyring/debug_level
390 # maybe cleanup credential cache?
396 local device=`mdsdevname $num`
397 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
403 local device=`ostdevname $num`
404 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
412 local dev=$(facet_active $facet)_dev
413 local opt=${facet}_opt
414 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
415 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
417 if [ $RC -ne 0 ]; then
418 echo "mount -t lustre $@ ${!dev} ${MOUNT%/*}/${facet}"
419 echo "Start of ${!dev} on ${facet} failed ${RC}"
421 do_facet ${facet} "lctl set_param debug=\\\"$PTLDEBUG\\\"; \
422 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\"; \
423 lctl set_param debug_mb=${DEBUG_SIZE}; \
426 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
427 [ -z "$label" ] && echo no label for ${!dev} && exit 1
428 eval export ${facet}_svc=${label}
429 echo Started ${label}
434 # start facet device options
440 eval export ${facet}_dev=${device}
441 eval export ${facet}_opt=\"$@\"
443 local varname=${facet}failover_dev
444 if [ -n "${!varname}" ] ; then
445 eval export ${facet}failover_dev=${!varname}
447 eval export ${facet}failover_dev=$device
450 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
460 HOST=`facet_active_host $facet`
461 [ -z $HOST ] && echo stop: no host for $facet && return 0
463 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
464 if [ ${running} -ne 0 ]; then
465 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
466 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
469 # umount should block, but we should wait for unrelated obd's
470 # like the MGS or MGC to also stop.
471 wait_exit_ST ${facet}
474 # save quota version (both administrative and operational quotas)
475 # add an additional parameter if mountpoint is ever different from $MOUNT
476 quota_save_version() {
477 local fsname=${2:-$FSNAME}
479 local ver=$(tr -c -d "123" <<< $spec)
480 local type=$(tr -c -d "ug" <<< $spec)
482 [ -n "$ver" -a "$ver" != "3" ] && error "wrong quota version specifier"
484 [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; }
486 do_facet mgs "lctl conf_param ${fsname}-MDT*.mdd.quota_type=$spec"
488 local osts=$(get_facets OST)
489 for ost in ${osts//,/ }; do
491 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$spec"
495 # client could mount several lustre
497 local fsname=${1:-$FSNAME}
499 do_facet mgs lctl get_param mdd.${fsname}-MDT*.quota_type || rc=$?
500 do_nodes $(comma_list $(osts_nodes)) \
501 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
505 restore_quota_type () {
506 local mntpt=${1:-$MOUNT}
507 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
508 if [ ! "$old_QUOTA_TYPE" ] || [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
511 quota_save_version $old_QUOTA_TYPE
518 # 1. run quotacheck only if quota is off
519 # 2. save the original quota_type params, restore them after testing
521 # Suppose that quota type the same on mds and ost
522 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
523 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
524 echo "[HOST:$HOSTNAME] [old_quota_type:$quota_type] [new_quota_type:$QUOTA_TYPE]"
525 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
526 export old_QUOTA_TYPE=$quota_type
527 quota_save_version $QUOTA_TYPE
530 local quota_usrs=$QUOTA_USERS
532 # get_filesystem_size
533 local disksz=$(lfs df $mntpt | grep "filesystem summary:" | awk '{print $3}')
534 local blk_soft=$((disksz + 1024))
535 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
537 local Inodes=$(lfs df -i $mntpt | grep "filesystem summary:" | awk '{print $3}')
539 local i_hard=$((i_soft + i_soft / 20))
541 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
542 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
545 for usr in $quota_usrs; do
546 echo "Setting up quota on $HOSTNAME:$mntpt for $usr..."
548 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
550 eval $cmd || error "$cmd FAILED!"
552 # display the quota status
553 echo "Quota settings for $usr : "
554 $LFS quota -v -u $usr $mntpt || true
562 # Only supply -o to mount if we have options
563 if [ -n "$MOUNTOPT" ]; then
564 OPTIONS="-o $MOUNTOPT"
566 local device=$MGSNID:/$FSNAME
567 if [ -z "$mnt" -o -z "$FSNAME" ]; then
568 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
572 echo "Starting client: $client: $OPTIONS $device $mnt"
573 do_node $client mkdir -p $mnt
574 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
576 do_node $client "lctl set_param debug=\\\"$PTLDEBUG\\\";
577 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
578 lctl set_param debug_mb=${DEBUG_SIZE}"
591 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
592 if [ $running -ne 0 ]; then
593 echo "Stopping client $client $mnt (opts:$force)"
594 do_node $client lsof -t $mnt || need_kill=no
595 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
596 pids=$(do_node $client lsof -t $mnt | sort -u);
597 if [ -n $pids ]; then
598 do_node $client kill -9 $pids || true
602 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
603 if [ $busy -ne 0 ] ; then
604 echo "$mnt is still busy, wait one second" && sleep 1
605 do_node $client umount $force $mnt
610 # nodes is comma list
611 sanity_mount_check_nodes () {
617 # FIXME: assume that all cluster nodes run the same os
618 [ "$(uname)" = Linux ] || return 0
621 for mnt in $mnts ; do
622 do_nodes $nodes "running=\\\$(grep -c $mnt' ' /proc/mounts);
623 mpts=\\\$(mount | grep -w -c $mnt);
624 if [ \\\$running -ne \\\$mpts ]; then
625 echo \\\$(hostname) env are INSANE!;
633 sanity_mount_check_servers () {
635 { echo "CLIENTONLY mode, skip mount_check_servers"; return 0; } || true
636 echo Checking servers environments
638 # FIXME: modify get_facets to display all facets wo params
639 local facets="$(get_facets OST),$(get_facets MDS),mgs"
643 for facet in ${facets//,/ }; do
644 node=$(facet_host ${facet})
645 mnt=${MOUNT%/*}/${facet}
646 sanity_mount_check_nodes $node $mnt ||
647 { error "server $node environments are insane!"; return 1; }
651 sanity_mount_check_clients () {
652 local clients=${1:-$CLIENTS}
653 local mntpt=${2:-$MOUNT}
654 local mntpt2=${3:-$MOUNT2}
656 [ -z $clients ] && clients=$(hostname)
657 echo Checking clients $clients environments
659 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
660 error "clients environments are insane!"
663 sanity_mount_check () {
664 sanity_mount_check_servers || return 1
665 sanity_mount_check_clients || return 2
668 # mount clients if not mouted
669 zconf_mount_clients() {
675 # Only supply -o to mount if we have options
676 if [ -n "$MOUNTOPT" ]; then
677 OPTIONS="-o $MOUNTOPT"
679 local device=$MGSNID:/$FSNAME
680 if [ -z "$mnt" -o -z "$FSNAME" ]; then
681 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
685 echo "Starting client $clients: $OPTIONS $device $mnt"
688 running=\\\$(mount | grep -c $mnt' ');
690 if [ \\\$running -eq 0 ] ; then
692 mount -t lustre $OPTIONS $device $mnt;
695 exit \\\$rc" || return ${PIPESTATUS[0]}
697 echo "Started clients $clients: "
698 do_nodes $clients "mount | grep -w $mnt"
700 do_nodes $clients "lctl set_param debug=\\\"$PTLDEBUG\\\";
701 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
702 lctl set_param debug_mb=${DEBUG_SIZE};"
707 zconf_umount_clients() {
714 echo "Stopping clients: $clients $mnt (opts:$force)"
715 do_nodes $clients "running=\\\$(grep -c $mnt' ' /proc/mounts);
716 if [ \\\$running -ne 0 ] ; then
717 echo Stopping client \\\$(hostname) client $mnt opts:$force;
718 lsof -t $mnt || need_kill=no;
719 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
720 pids=\\\$(lsof -t $mnt | sort -u);
721 if [ -n \\\"\\\$pids\\\" ]; then
725 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy");
726 if [ \\\$busy -ne 0 ] ; then
727 echo "$mnt is still busy, wait one second" && sleep 1;
733 shudown_node_hard () {
737 for i in $(seq $attempts) ; do
740 ping -w 3 -c 1 $host > /dev/null 2>&1 || return 0
741 echo "waiting for $host to fail attempts=$attempts"
742 [ $i -lt $attempts ] || \
743 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
749 local mnt=${2:-$MOUNT}
752 if [ "$FAILURE_MODE" = HARD ]; then
753 shudown_node_hard $client
755 zconf_umount_clients $client $mnt -f
761 if [ "$FAILURE_MODE" = HARD ]; then
762 shudown_node_hard $(facet_active_host $facet)
763 elif [ "$FAILURE_MODE" = SOFT ]; then
770 if [ "$FAILURE_MODE" = HARD ]; then
771 $POWER_UP `facet_active_host $facet`
779 if [ "$FAILURE_MODE" = HARD ]; then
785 # recovery-scale functions
786 check_progs_installed () {
791 do_nodes $clients "PATH=:$PATH; status=true;
792 for prog in $progs; do
793 if ! [ \\\"\\\$(which \\\$prog)\\\" -o \\\"\\\${!prog}\\\" ]; then
794 echo \\\$prog missing on \\\$(hostname);
802 echo __$(echo $1 | tr '-' 'X')
805 start_client_load() {
808 local var=$(client_var_name $client)_load
809 eval export ${var}=$load
811 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
812 BREAK_ON_ERROR=$BREAK_ON_ERROR \
813 END_RUN_FILE=$END_RUN_FILE \
814 LOAD_PID_FILE=$LOAD_PID_FILE \
815 TESTSUITELOG=$TESTSUITELOG \
817 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
818 log "Started client load: ${load} on $client"
823 start_client_loads () {
824 local -a clients=(${1//,/ })
825 local numloads=${#CLIENT_LOADS[@]}
828 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
829 testnum=$((nodenum % numloads))
830 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
834 # only for remote client
835 check_client_load () {
837 local var=$(client_var_name $client)_load
838 local TESTLOAD=run_${!var}.sh
840 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
842 # bug 18914: try to connect several times not only when
843 # check ps, but while check_catastrophe also
846 while [ $RC = 254 -a $tries -gt 0 ]; do
850 if ! check_catastrophe $client; then
852 if [ $RC -eq 254 ]; then
853 # FIXME: not sure how long we shuold sleep here
857 echo "check catastrophe failed: RC=$RC "
861 # We can continue try to connect if RC=254
862 # Just print the warning about this
863 if [ $RC = 254 ]; then
864 echo "got a return status of $RC from do_node while checking catastrophe on $client"
867 # see if the load is still on the client
870 while [ $RC = 254 -a $tries -gt 0 ]; do
874 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
879 if [ $RC = 254 ]; then
880 echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
881 # see if we can diagnose a bit why this is
886 check_client_loads () {
887 local clients=${1//,/ }
891 for client in $clients; do
892 check_client_load $client
894 if [ "$rc" != 0 ]; then
895 log "Client load failed on node $client, rc=$rc"
901 restart_client_loads () {
902 local clients=${1//,/ }
903 local expectedfail=${2:-""}
907 for client in $clients; do
908 check_client_load $client
910 if [ "$rc" != 0 -a "$expectedfail" ]; then
911 local var=$(client_var_name $client)_load
912 start_client_load $client ${!var}
913 echo "Restarted client load ${!var}: on $client. Checking ..."
914 check_client_load $client
916 if [ "$rc" != 0 ]; then
917 log "Client load failed to restart on node $client, rc=$rc"
918 # failure one client load means test fail
919 # we do not need to check other
927 # End recovery-scale functions
929 # verify that lustre actually cleaned up properly
931 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
932 error "LBUG/LASSERT detected"
933 BUSY=`dmesg | grep -i destruct || true`
936 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
940 check_mem_leak || exit 204
942 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
943 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
945 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
946 echo "$0: modules still loaded..." 1>&2
963 RESULT=$(do_node $node "$TEST")
964 if [ "$RESULT" == "$FINAL" ]; then
965 echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
968 [ $WAIT -ge $MAX ] && break
969 echo "Waiting $((MAX - WAIT)) secs for update"
970 WAIT=$((WAIT + sleep))
973 echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
977 wait_update_facet () {
979 wait_update $(facet_active_host $facet) "$@"
982 wait_delete_completed () {
983 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
984 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
988 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
990 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
991 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
992 [ "$TOTAL" -eq "$TOTALPREV" ] && break
993 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
997 echo "Delete completed."
1002 check_network "$host" 900
1003 while ! do_node $host hostname > /dev/null; do sleep 5; done
1008 local host=`facet_active_host $facet`
1012 wait_recovery_complete () {
1015 # Use default policy if $2 is not passed by caller.
1016 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
1017 # as we are in process of changing obd_timeout in different ways
1018 # let's set MAX longer than that
1019 local MAX=${2:-$(( TIMEOUT * 4 ))}
1021 local var_svc=${facet}_svc
1022 local procfile="*.${!var_svc}.recovery_status"
1026 while [ $WAIT -lt $MAX ]; do
1027 STATUS=$(do_facet $facet lctl get_param -n $procfile | grep status)
1028 [[ $STATUS = "status: COMPLETE" ]] && return 0
1031 echo "Waiting $((MAX - WAIT)) secs for $facet recovery done. $STATUS"
1033 echo "$facet recovery not done in $MAX sec. $STATUS"
1043 # conf-sanity 31 takes a long time cleanup
1044 while [ $WAIT -lt 300 ]; do
1045 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
1046 [ -z "${running}" ] && return 0
1047 echo "waited $WAIT for${running}"
1048 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
1050 WAIT=$((WAIT + INTERVAL))
1052 echo "service didn't stop after $WAIT seconds. Still running:"
1057 wait_remote_prog () {
1063 [ "$PDSH" = "no_dsh" ] && return 0
1065 while [ $WAIT -lt $2 ]; do
1066 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
1067 [ -z "${running}" ] && return 0 || true
1068 echo "waited $WAIT for: "
1070 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
1072 WAIT=$((WAIT + INTERVAL))
1074 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
1075 [ -z "$pids" ] && return 0
1076 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
1077 # FIXME: not portable
1078 for pid in $pids; do
1079 cat /proc/${pid}/status || true
1080 cat /proc/${pid}/wchan || true
1082 kill -9 $pid || true
1091 # not every config has many clients
1092 if [ ! -z "$CLIENTS" ]; then
1093 $PDSH $CLIENTS "df $MOUNT" > /dev/null
1095 df $MOUNT > /dev/null
1099 client_reconnect() {
1100 uname -n >> $MOUNT/recon
1101 if [ -z "$CLIENTS" ]; then
1102 df $MOUNT; uname -n >> $MOUNT/recon
1104 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
1106 echo Connected clients:
1108 ls -l $MOUNT/recon > /dev/null
1115 echo "Failing $facet on node `facet_active_host $facet`"
1116 shutdown_facet $facet
1117 [ -n "$sleep_time" ] && sleep $sleep_time
1119 change_active $facet
1120 local TO=`facet_active_host $facet`
1121 echo "Failover $facet to $TO"
1123 mount_facet $facet || error "Restart of $facet failed"
1132 do_facet $facet sync
1134 local svc=${facet}_svc
1135 do_facet $facet $LCTL --device %${!svc} notransno
1136 do_facet $facet $LCTL --device %${!svc} readonly
1137 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1138 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1141 replay_barrier_nodf() {
1142 local facet=$1 echo running=${running}
1143 do_facet $facet sync
1144 local svc=${facet}_svc
1145 echo Replay barrier on ${!svc}
1146 do_facet $facet $LCTL --device %${!svc} notransno
1147 do_facet $facet $LCTL --device %${!svc} readonly
1148 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1149 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1152 replay_barrier_nosync() {
1153 local facet=$1 echo running=${running}
1154 local svc=${facet}_svc
1155 echo Replay barrier on ${!svc}
1156 do_facet $facet $LCTL --device %${!svc} notransno
1157 do_facet $facet $LCTL --device %${!svc} readonly
1158 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1159 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1162 mds_evict_client() {
1163 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
1164 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
1167 ost_evict_client() {
1168 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
1169 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1173 facet_failover $* || error "failover: $?"
1174 client_df || error "post-failover df: $?"
1179 facet_failover $facet
1185 change_active $facet
1186 mount_facet $facet -o abort_recovery
1187 client_df || echo "first df failed: $?"
1189 client_df || error "post-failover df: $?"
1193 echo There is no lmc. This is mountconf, baby.
1198 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1199 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
1205 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1211 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1212 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1213 if [ -z "$ID" ]; then
1214 echo "Could not get a ptl id for $1..."
1223 h2name_or_ip "$1" "tcp"
1228 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1229 if type __h2elan >/dev/null 2>&1; then
1232 ID=`echo $1 | sed 's/[^0-9]*//g'`
1240 h2name_or_ip "$1" "openib"
1242 declare -fx h2openib
1245 h2name_or_ip "$1" "o2ib"
1252 [ "$facet" == client ] && echo -n $HOSTNAME && return
1253 varname=${facet}_HOST
1254 if [ -z "${!varname}" ]; then
1255 if [ "${facet:0:3}" == "ost" ]; then
1256 eval ${facet}_HOST=${ost_HOST}
1264 local activevar=${facet}active
1266 if [ -f $TMP/${facet}active ] ; then
1267 source $TMP/${facet}active
1270 active=${!activevar}
1271 if [ -z "$active" ] ; then
1278 facet_active_host() {
1280 local active=`facet_active $facet`
1281 if [ "$facet" == client ]; then
1284 echo `facet_host $active`
1290 local failover=${facet}failover
1291 host=`facet_host $failover`
1292 [ -z "$host" ] && return
1293 local curactive=`facet_active $facet`
1294 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1295 eval export ${facet}active=$facet
1297 eval export ${facet}active=$failover
1299 # save the active host for this facet
1300 local activevar=${facet}active
1301 echo "$activevar=${!activevar}" > $TMP/$activevar
1306 # do not stripe off hostname if verbose, bug 19215
1307 if [ x$1 = x--verbose ]; then
1315 if [ "$HOST" = "$HOSTNAME" ]; then
1317 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1318 echo "cannot run remote command on $HOST with $myPDSH"
1322 echo "CMD: $HOST $@" >&2
1323 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
1326 if [ "$myPDSH" = "rsh" ]; then
1327 # we need this because rsh does not return exit code of an executed command
1328 local command_status="$TMP/cs"
1329 rsh $HOST ":> $command_status"
1330 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1331 cd $RPWD; sh -c \"$@\") ||
1332 echo command failed >$command_status"
1333 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1338 # print HOSTNAME for myPDSH="no_dsh"
1339 if [[ $myPDSH = no_dsh ]]; then
1340 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
1342 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1345 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
1347 return ${PIPESTATUS[0]}
1350 single_local_node () {
1351 [ "$1" = "$HOSTNAME" ]
1356 # do not stripe off hostname if verbose, bug 19215
1357 if [ x$1 = x--verbose ]; then
1365 if $(single_local_node $rnodes); then
1367 do_node --verbose $rnodes $@
1374 # This is part from do_node
1377 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1378 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1381 echo "CMD: $rnodes $@" >&2
1382 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
1386 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1388 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
1390 return ${PIPESTATUS[0]}
1396 local HOST=`facet_active_host $facet`
1397 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1404 # make sure its not already running
1406 rm -f $TMP/${facet}active
1407 do_facet ${facet} $MKFS $*
1413 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1414 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1421 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
1422 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1430 # make sure we are using the primary server, so test-framework will
1431 # be able to clean up properly.
1432 activemds=`facet_active mds1`
1433 if [ $activemds != "mds1" ]; then
1437 local clients=$CLIENTS
1438 [ -z $clients ] && clients=$(hostname)
1440 zconf_umount_clients $clients $MOUNT "$*" || true
1441 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
1443 [ "$CLIENTONLY" ] && return
1444 # The add fn does rm ${facet}active file, this would be enough
1445 # if we use do_facet <facet> only after the facet added, but
1446 # currently we use do_facet mds in local.sh
1447 for num in `seq $MDSCOUNT`; do
1449 rm -f ${TMP}/mds${num}active
1452 for num in `seq $OSTCOUNT`; do
1454 rm -f $TMP/ost${num}active
1461 nfs_client_mode && return
1471 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
1475 if [ "$IAMDIR" == "yes" ]; then
1476 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --iam-dir"
1477 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --iam-dir"
1480 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1482 if [ ! -z $SEC ]; then
1483 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --param srpc.flavor.default=$SEC"
1484 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --param srpc.flavor.default=$SEC"
1485 OST_MKFS_OPTS="$OST_MKFS_OPTS --param srpc.flavor.default=$SEC"
1489 # We need ldiskfs here, may as well load them all
1491 [ "$CLIENTONLY" ] && return
1492 echo Formatting mgs, mds, osts
1493 if [[ $MDSDEV1 != $MGSDEV ]] || [[ $mds1_HOST != $mgs_HOST ]]; then
1494 add mgs $mgs_MKFS_OPTS $FSTYPE_OPT --reformat $MGSDEV || exit 10
1497 for num in `seq $MDSCOUNT`; do
1498 echo "Format mds$num: $(mdsdevname $num)"
1500 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
1502 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
1506 for num in `seq $OSTCOUNT`; do
1507 echo "Format ost$num: $(ostdevname $num)"
1509 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
1511 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
1517 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1521 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1525 # 0: success, the old identity set already.
1526 # 1: success, the old identity does not set.
1531 local j=`expr $num - 1`
1532 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
1534 if [ -z "$MDT" ]; then
1538 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1541 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
1543 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
1546 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush \"-1\""
1548 if [ $old = "NONE" ]; then
1557 zconf_umount `hostname` $1 || error "umount failed"
1558 zconf_mount `hostname` $1 || error "mount failed"
1561 writeconf_facet () {
1565 do_facet $facet "$TUNEFS --writeconf $dev"
1569 for num in `seq $MDSCOUNT`; do
1570 DEVNAME=$(mdsdevname $num)
1571 writeconf_facet mds$num $DEVNAME
1574 for num in `seq $OSTCOUNT`; do
1575 DEVNAME=$(ostdevname $num)
1576 writeconf_facet ost$num $DEVNAME
1581 nfs_client_mode && return
1583 sanity_mount_check ||
1584 error "environments are insane!"
1588 if [ -z "$CLIENTONLY" ]; then
1589 echo Setup mgs, mdt, osts
1590 echo $WRITECONF | grep -q "writeconf" && \
1592 if [[ $mds1_HOST != $mgs_HOST ]] || [[ $MDSDEV1 != $MGSDEV ]]; then
1593 start mgs $MGSDEV $mgs_MOUNT_OPTS
1596 for num in `seq $MDSCOUNT`; do
1597 DEVNAME=$(mdsdevname $num)
1598 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1600 # We started mds, now we should set failover variables properly.
1601 # Set mds${num}failover_HOST if it is not set (the default failnode).
1602 local varname=mds${num}failover_HOST
1603 if [ -z "${!varname}" ]; then
1604 eval mds${num}failover_HOST=$(facet_host mds$num)
1607 if [ $IDENTITY_UPCALL != "default" ]; then
1608 switch_identity $num $IDENTITY_UPCALL
1611 for num in `seq $OSTCOUNT`; do
1612 DEVNAME=$(ostdevname $num)
1613 start ost$num $DEVNAME $OST_MOUNT_OPTS
1615 # We started ost$num, now we should set ost${num}failover variable properly.
1616 # Set ost${num}failover_HOST if it is not set (the default failnode).
1617 varname=ost${num}failover_HOST
1618 if [ -z "${!varname}" ]; then
1619 eval ost${num}failover_HOST=$(facet_host ost${num})
1624 # wait a while to allow sptlrpc configuration be propogated to targets,
1625 # only needed when mounting new target devices.
1628 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1630 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1632 if [ "$MOUNT_2" ]; then
1633 mount_client $MOUNT2
1634 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1639 # by remounting mdt before ost, initial connect from mdt to ost might
1640 # timeout because ost is not ready yet. wait some time to its fully
1641 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1642 # by a context negotiation rpc with $TIMEOUT.
1643 # FIXME better by monitoring import status.
1645 sleep $((TIMEOUT + 5))
1651 mounted_lustre_filesystems() {
1652 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1655 init_facet_vars () {
1656 [ "$CLIENTONLY" ] && return 0
1663 eval export ${facet}_dev=${device}
1664 eval export ${facet}_opt=\"$@\"
1666 local dev=${facet}_dev
1667 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
1668 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1670 eval export ${facet}_svc=${label}
1672 local varname=${facet}failover_HOST
1673 if [ -z "${!varname}" ]; then
1674 eval $varname=$(facet_host $facet)
1677 # ${facet}failover_dev is set in cfg file
1678 varname=${facet}failover_dev
1679 if [ -n "${!varname}" ] ; then
1680 eval export ${facet}failover_dev=${!varname}
1682 eval export ${facet}failover_dev=$device
1686 init_facets_vars () {
1689 if ! remote_mds_nodsh; then
1690 for num in `seq $MDSCOUNT`; do
1691 DEVNAME=`mdsdevname $num`
1692 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
1696 remote_ost_nodsh && return
1698 for num in `seq $OSTCOUNT`; do
1699 DEVNAME=`ostdevname $num`
1700 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1704 osc_ensure_active () {
1710 while [ $period -lt $timeout ]; do
1711 count=$(do_facet $facet "lctl dl | grep '${FSNAME}-OST.*-osc-${type}' | grep ' IN ' 2>/dev/null | wc -l")
1712 if [ $count -eq 0 ]; then
1716 echo "There are $count OST are inactive, wait $period seconds, and try again"
1718 period=$((period+3))
1721 [ $period -lt $timeout ] || log "$count OST are inactive after $timeout seconds, give up"
1725 SOM_ENABLED=$(do_facet $SINGLEMDS "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
1729 init_param_vars () {
1730 if ! remote_ost_nodsh && ! remote_mds_nodsh; then
1731 export MDSVER=$(do_facet $SINGLEMDS "lctl get_param version" | cut -d. -f1,2)
1732 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
1733 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
1737 TIMEOUT=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1739 log "Using TIMEOUT=$TIMEOUT"
1741 osc_ensure_active $SINGLEMDS M $TIMEOUT
1742 osc_ensure_active client c $TIMEOUT
1744 if [ x"$(som_check)" = x"enabled" ]; then
1747 if [ "$ENABLE_QUOTA" ]; then
1748 setup_quota $MOUNT || return 2
1752 nfs_client_mode () {
1753 if [ "$NFSCLIENT" ]; then
1754 echo "NFSCLIENT mode: setup, cleanup, check config skipped"
1755 local clients=$CLIENTS
1756 [ -z $clients ] && clients=$(hostname)
1758 # FIXME: remove hostname when 19215 fixed
1759 do_nodes $clients "echo \\\$(hostname); grep ' '$MOUNT' ' /proc/mounts"
1760 declare -a nfsexport=(`grep ' '$MOUNT' ' /proc/mounts | awk '{print $1}' | awk -F: '{print $1 " " $2}'`)
1761 do_nodes ${nfsexport[0]} "echo \\\$(hostname); df -T ${nfsexport[1]}"
1768 nfs_client_mode && return
1772 local mounted=$(mount | grep " $mntpt ")
1773 if [ "$CLIENTONLY" ]; then
1775 # CLIENTONLY should not depend on *_HOST settings
1776 local mgc=$($LCTL device_list | awk '/MGC/ {print $4}')
1777 # in theory someone could create a new,
1778 # client-only config file that assumed lustre was already
1779 # configured and didn't set the MGSNID. If MGSNID is not set,
1780 # then we should use the mgs nid currently being used
1781 # as the default value. bug 18021
1782 [[ x$MGSNID = x ]] &&
1785 if [[ x$mgc != xMGC$MGSNID ]]; then
1786 if [ "$mgs_HOST" ]; then
1787 local mgc_ip=$(ping -q -c1 -w1 $mgs_HOST | grep PING | awk '{print $3}' | sed -e "s/(//g" -e "s/)//g")
1788 [[ x$mgc = xMGC$mgc_ip@$NETTYPE ]] ||
1789 error_exit "MGSNID=$MGSNID, mounted: $mounted, MGC : $mgc"
1795 local myMGS_host=$mgs_HOST
1796 if [ "$NETTYPE" = "ptl" ]; then
1797 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
1800 echo Checking config lustre mounted on $mntpt
1801 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
1802 mgshost=$(echo $mgshost | awk -F: '{print $1}')
1804 # if [ "$mgshost" != "$myMGS_host" ]; then
1805 # error_exit "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
1806 # Please use correct config or set mds_HOST correctly!"
1809 sanity_mount_check ||
1810 error "environments are insane!"
1814 local mdstimeout=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1815 local cltimeout=$(lctl get_param -n timeout)
1816 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
1817 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
1822 check_and_setup_lustre() {
1823 nfs_client_mode && return
1825 local MOUNTED=$(mounted_lustre_filesystems)
1826 if [ -z "$MOUNTED" ] || ! $(echo $MOUNTED | grep -w -q $MOUNT); then
1827 [ "$REFORMAT" ] && formatall
1829 MOUNTED=$(mounted_lustre_filesystems | head -1)
1830 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
1831 export I_MOUNTED=yes
1837 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=\\\"$PTLDEBUG\\\";
1838 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
1839 lctl set_param debug_mb=${DEBUG_SIZE};
1842 if [ "$ONLY" == "setup" ]; then
1847 cleanup_and_setup_lustre() {
1848 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
1849 lctl set_param debug=0 || true
1851 if [ "$ONLY" == "cleanup" ]; then
1855 check_and_setup_lustre
1858 check_and_cleanup_lustre() {
1859 if [ "`mount | grep $MOUNT`" ]; then
1860 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1861 [ "$ENABLE_QUOTA" ] && restore_quota_type || true
1863 if [ "$I_MOUNTED" = "yes" ]; then
1864 cleanupall -f || error "cleanup failed"
1876 while [ $NETWORK -eq 0 ]; do
1877 if ping -c 1 -w 3 $1 > /dev/null; then
1881 echo "waiting for $1, $((MAX - WAIT)) secs left"
1884 if [ $WAIT -gt $MAX ]; then
1885 echo "Network not available"
1891 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
1902 # the sed converts spaces to commas, but leaves the last space
1903 # alone, so the line doesn't end with a comma.
1904 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
1907 # list, excluded are the comma separated lists
1908 exclude_items_from_list () {
1914 for item in ${excluded//,/ }; do
1915 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
1917 echo $(comma_list $list)
1920 # list, expand are the comma separated lists
1922 local list=${1//,/ }
1923 local expand=${2//,/ }
1926 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
1927 echo $(comma_list $expanded)
1931 (cd `dirname $1`; echo $PWD/`basename $1`)
1935 local name=$(echo $1 | tr "[:upper:]" "[:lower:]")
1936 local type=$(echo $1 | tr "[:lower:]" "[:upper:]")
1939 local count=${type}COUNT
1940 for ((i=1; i<=${!count}; i++)) do
1941 list="$list ${name}$i"
1943 echo $(comma_list $list)
1946 ##################################
1947 # Adaptive Timeouts funcs
1950 # only check mds, we assume at_max is the same on all nodes
1951 local at_max=$(do_facet $SINGLEMDS "lctl get_param -n at_max")
1952 if [ $at_max -eq 0 ]; then
1962 # suppose that all ost-s has the same at_max set
1963 if [ $facet == "ost" ]; then
1964 do_facet ost1 "lctl get_param -n at_max"
1966 do_facet $facet "lctl get_param -n at_max"
1976 if [ $facet == "ost" ]; then
1977 for i in `seq $OSTCOUNT`; do
1978 do_facet ost$i "lctl set_param at_max=$at_max"
1981 elif [ $facet == "mds" ]; then
1982 for i in `seq $MDSCOUNT`; do
1983 do_facet mds$i "lctl set_param at_max=$at_max"
1986 do_facet $facet "lctl set_param at_max=$at_max"
1991 ##################################
1995 # OBD_FAIL_MDS_ALL_REQUEST_NET
1997 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
1998 do_facet client "$1" || RC=$?
1999 do_facet $SINGLEMDS lctl set_param fail_loc=0
2004 # OBD_FAIL_MDS_ALL_REPLY_NET
2006 do_facet $SINGLEMDS lctl set_param fail_loc=0x122
2007 do_facet client "$@" || RC=$?
2008 do_facet $SINGLEMDS lctl set_param fail_loc=0
2012 drop_reint_reply() {
2013 # OBD_FAIL_MDS_REINT_NET_REP
2015 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
2016 do_facet client "$@" || RC=$?
2017 do_facet $SINGLEMDS lctl set_param fail_loc=0
2022 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2024 do_facet ost1 lctl set_param fail_loc=0x214
2025 do_facet client "$1" || RC=$?
2026 do_facet client "sync"
2027 do_facet ost1 lctl set_param fail_loc=0
2031 drop_ldlm_cancel() {
2032 #define OBD_FAIL_LDLM_CANCEL 0x304
2034 do_facet client lctl set_param fail_loc=0x304
2035 do_facet client "$@" || RC=$?
2036 do_facet client lctl set_param fail_loc=0
2040 drop_bl_callback() {
2041 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
2043 do_facet client lctl set_param fail_loc=0x305
2044 do_facet client "$@" || RC=$?
2045 do_facet client lctl set_param fail_loc=0
2050 #define OBD_FAIL_LDLM_REPLY 0x30c
2052 do_facet $SINGLEMDS lctl set_param fail_loc=0x30c
2053 do_facet client "$@" || RC=$?
2054 do_facet $SINGLEMDS lctl set_param fail_loc=0
2062 echo "clearing fail_loc on $facet"
2063 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
2066 set_nodes_failloc () {
2067 do_nodes $(comma_list $1) lctl set_param fail_loc=$2
2070 cancel_lru_locks() {
2071 $LCTL mark "cancel_lru_locks $1 start"
2072 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
2073 $LCTL set_param -n $d=clear
2075 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
2076 $LCTL mark "cancel_lru_locks $1 stop"
2081 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
2082 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
2083 echo "$DEFAULT_LRU_SIZE"
2088 lctl set_param ldlm.namespaces.*$1*.lru_size=0
2091 lru_resize_disable()
2093 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
2098 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
2099 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
2100 echo there is still data in page cache $FILE ?
2101 lctl get_param -n $FILE
2105 if [[ $MDSDEV1 != $MGSDEV ]]; then
2113 DEBUGSAVE="$(lctl get_param -n debug)"
2117 [ -n "$DEBUGSAVE" ] && \
2118 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=\\\"${DEBUGSAVE}\\\";"
2123 DEBUG_SIZE_SAVED="$(lctl get_param -n debug_mb)"
2126 debug_size_restore() {
2127 [ -n "$DEBUG_SIZE_SAVED" ] && \
2128 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE_SAVED"
2132 start_full_debug_logging() {
2137 local DEBUG_SIZE=150
2139 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE"
2140 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=$FULLDEBUG;"
2143 stop_full_debug_logging() {
2148 ##################################
2150 ##################################
2153 local TYPE=${TYPE:-"FAIL"}
2155 lctl set_param fail_loc=0 2>/dev/null || true
2158 # do not dump logs if $1=false
2159 if [ "x$1" = "xfalse" ]; then
2164 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
2167 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
2168 echo "Dumping lctl log to $ERRLOG"
2169 # We need to dump the logs on all nodes
2170 do_nodes $(comma_list $(nodes_list)) $NODE $LCTL dk $ERRLOG
2173 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
2179 $FAIL_ON_ERROR && exit 1 || true
2187 # use only if we are ignoring failures for this test, bugno required.
2188 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
2189 # e.g. error_ignore 5494 "your message"
2191 local TYPE="IGNORE (bz$1)"
2197 $FAIL_ON_SKIP_ENV && error false $@ || skip $@
2202 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
2203 [ "$TESTSUITELOG" ] && \
2204 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
2207 build_test_filter() {
2208 [ "$ONLY" ] && log "only running test `echo $ONLY`"
2212 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
2213 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
2214 [ "$EXCEPT_SLOW" ] && \
2215 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
2216 for E in $EXCEPT $ALWAYS_EXCEPT; do
2217 eval EXCEPT_${E}=true
2219 for E in $EXCEPT_SLOW; do
2220 eval EXCEPT_SLOW_${E}=true
2222 for G in $GRANT_CHECK_LIST; do
2223 eval GCHECK_ONLY_${G}=true
2231 # print a newline if the last test was skipped
2232 export LAST_SKIPPED=
2236 export base=`basetest $1`
2237 if [ ! -z "$ONLY" ]; then
2239 if [ ${!testname}x != x ]; then
2240 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2245 if [ ${!testname}x != x ]; then
2246 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2255 if [ ${!testname}x != x ]; then
2257 TESTNAME=test_$1 skip "skipping excluded test $1"
2260 testname=EXCEPT_$base
2261 if [ ${!testname}x != x ]; then
2263 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
2266 testname=EXCEPT_SLOW_$1
2267 if [ ${!testname}x != x ]; then
2269 TESTNAME=test_$1 skip "skipping SLOW test $1"
2272 testname=EXCEPT_SLOW_$base
2273 if [ ${!testname}x != x ]; then
2275 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
2285 EQUALS="======================================================================"
2289 local suffixlen=$((${#EQUALS} - ${#msg}))
2290 [ $suffixlen -lt 5 ] && suffixlen=5
2291 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
2296 lsmod | grep lnet > /dev/null || load_modules
2308 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
2313 strace -o $TMP/$1.strace -ttt $*
2315 log "FINISHED: $*: rc $RC"
2320 $TEST_FAILED && echo -n "FAIL " || echo -n "PASS "
2325 FFREE=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filesfree | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2326 FTOTAL=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filestotal | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2327 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
2331 echo -n "Resetting fail_loc on all nodes..."
2332 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 2>/dev/null || true"
2340 export tdir=d0.${TESTSUITE}/d${base}
2342 local SAVE_UMASK=`umask`
2345 local BEFORE=`date +%s`
2347 log "== test $testnum: $message == `date +%H:%M:%S` ($BEFORE)"
2349 export TESTNAME=test_$testnum
2351 test_${testnum} || error "test_$testnum failed with $?"
2355 check_grant ${testnum} || error "check_grant $testnum failed with $?"
2356 check_catastrophe || error "LBUG/LASSERT detected"
2357 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
2358 pass "($((`date +%s` - $BEFORE))s)"
2366 (cd `dirname $1`; echo $PWD/`basename $1`)
2370 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
2371 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
2376 export base=`basetest $1`
2377 [ "$CHECK_GRANT" == "no" ] && return 0
2379 testname=GCHECK_ONLY_${base}
2380 [ ${!testname}x == x ] && return 0
2382 echo -n "checking grant......"
2384 # write some data to sync client lost_grant
2385 rm -f $DIR1/${tfile}_check_grant_* 2>&1
2386 for i in `seq $OSTCOUNT`; do
2387 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
2388 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
2389 count=1 > /dev/null 2>&1
2391 # sync all the data and make sure no pending data on server
2394 #get client grant and server grant
2396 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
2397 client_grant=$((client_grant + $d))
2400 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
2401 server_grant=$((server_grant + $d))
2404 # cleanup the check_grant file
2405 for i in `seq $OSTCOUNT`; do
2406 rm $DIR1/${tfile}_check_grant_$i
2409 #check whether client grant == server grant
2410 if [ $client_grant != $server_grant ]; then
2411 echo "failed: client:${client_grant} server: ${server_grant}"
2418 ########################
2424 ost=`echo $1 | awk -F_ '{print $3}'`
2425 if [ -z $ost ]; then
2426 ost=`echo $1 | sed 's/-osc.*//'`
2433 [ "$node" != "$(hostname)" ]
2439 for node in $(mdts_nodes); do
2440 remote_node $node && return 0
2447 [ "$CLIENTONLY" ] && return 0 || true
2448 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
2454 for node in $(osts_nodes) ; do
2455 remote_node $node && return 0
2462 [ "$CLIENTONLY" ] && return 0 || true
2463 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2469 MGS=$(facet_host mgs)
2470 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2476 for num in `seq $MDSCOUNT`; do
2477 MDSNODES="$MDSNODES $(facet_host mds$num)"
2479 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
2485 remote_ost && remote_mds
2489 local OSTNODES=$(facet_host ost1)
2492 for num in `seq $OSTCOUNT`; do
2493 local myOST=$(facet_host ost$num)
2494 OSTNODES="$OSTNODES $myOST"
2496 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
2502 # FIXME. We need a list of clients
2503 local myNODES=$HOSTNAME
2506 # CLIENTS (if specified) contains the local client
2507 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
2509 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
2510 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
2513 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
2518 remote_nodes_list () {
2519 local rnodes=$(nodes_list)
2520 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2524 init_clients_lists () {
2525 # Sanity check: exclude the local client from RCLIENTS
2526 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2528 # Sanity check: exclude the dup entries
2529 rclients=$(for i in $rclients; do echo $i; done | sort -u)
2531 local clients="$SINGLECLIENT $HOSTNAME $rclients"
2533 # Sanity check: exclude the dup entries from CLIENTS
2534 # for those configs which has SINGLCLIENT set to local client
2535 clients=$(for i in $clients; do echo $i; done | sort -u)
2537 CLIENTS=`comma_list $clients`
2538 local -a remoteclients=($rclients)
2539 for ((i=0; $i<${#remoteclients[@]}; i++)); do
2540 varname=CLIENT$((i + 2))
2541 eval $varname=${remoteclients[i]}
2544 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
2547 get_random_entry () {
2550 rnodes=${rnodes//,/ }
2552 local -a nodes=($rnodes)
2553 local num=${#nodes[@]}
2554 local i=$((RANDOM * num * 2 / 65536))
2561 lctl get_param version | grep -q patchless
2565 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
2570 echo $nodes | wc -w || true
2574 local nodes=$(osts_nodes)
2575 local osscount=$(get_node_count "$nodes")
2576 [ ! "$OSTCOUNT" = "$osscount" ]
2580 local nodes=$(mdts_nodes)
2581 local mdtcount=$(get_node_count "$nodes")
2582 [ ! "$MDSCOUNT" = "$mdtcount" ]
2585 generate_machine_file() {
2586 local nodes=${1//,/ }
2587 local machinefile=$2
2588 rm -f $machinefile || error "can't rm $machinefile"
2589 for node in $nodes; do
2590 echo $node >>$machinefile
2595 local file=$1/stripe
2597 $LFS getstripe -v $file || error
2601 check_runas_id_ret() {
2603 local myRUNAS_UID=$1
2604 local myRUNAS_GID=$2
2607 if [ -z "$myRUNAS" ]; then
2608 error_exit "myRUNAS command must be specified for check_runas_id"
2611 $myRUNAS krb5_login.sh || \
2612 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
2614 mkdir $DIR/d0_runas_test
2616 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
2617 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
2618 rm -rf $DIR/d0_runas_test
2623 local myRUNAS_UID=$1
2624 local myRUNAS_GID=$2
2627 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
2628 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
2629 Please set RUNAS_ID to some UID which exists on MDS and client or
2630 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
2633 # obtain the UID/GID for MPI_USER
2637 MPI_USER_UID=$(do_facet client "getent passwd $mpi_user | cut -d: -f3;
2638 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the UID for $mpi_user"
2640 MPI_USER_GID=$(do_facet client "getent passwd $mpi_user | cut -d: -f4;
2641 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the GID for $mpi_user"
2644 # obtain and cache Kerberos ticket-granting ticket
2645 refresh_krb5_tgt() {
2646 local myRUNAS_UID=$1
2647 local myRUNAS_GID=$2
2650 if [ -z "$myRUNAS" ]; then
2651 error_exit "myRUNAS command must be specified for refresh_krb5_tgt"
2654 CLIENTS=${CLIENTS:-$HOSTNAME}
2655 do_nodes $CLIENTS "set -x
2656 if ! $myRUNAS krb5_login.sh; then
2657 echo "Failed to refresh Krb5 TGT for UID/GID $myRUNAS_UID/$myRUNAS_GID."
2662 # Run multiop in the background, but wait for it to print
2663 # "PAUSING" to its stdout before returning from this function.
2664 multiop_bg_pause() {
2665 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
2669 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
2672 echo "$MULTIOP_PROG $FILE v$ARGS"
2673 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
2675 echo "TMPPIPE=${TMPPIPE}"
2676 read -t 60 multiop_output < $TMPPIPE
2677 if [ $? -ne 0 ]; then
2682 if [ "$multiop_output" != "PAUSING" ]; then
2683 echo "Incorrect multiop output: $multiop_output"
2698 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
2704 inodes_available () {
2705 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
2709 # reset llite stat counters
2710 clear_llite_stats(){
2711 lctl set_param -n llite.*.stats 0
2714 # sum llite stat items
2715 calc_llite_stats() {
2716 local res=$(lctl get_param -n llite.*.stats |
2717 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2721 # reset osc stat counters
2723 lctl set_param -n osc.*.osc_stats 0
2726 # sum osc stat items
2728 local res=$(lctl get_param -n osc.*.osc_stats |
2729 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2734 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
2737 calc_osc_kbytes () {
2738 df $MOUNT > /dev/null
2739 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
2742 # save_lustre_params(node, parameter_mask)
2743 # generate a stream of formatted strings (<node> <param name>=<param value>)
2744 save_lustre_params() {
2746 do_nodes --verbose $1 "lctl get_param $2 | while read s; do echo \\\$s; done"
2749 # restore lustre parameters from input stream, produces by save_lustre_params
2750 restore_lustre_params() {
2754 while IFS=" =" read node name val; do
2755 do_node ${node//:/} "lctl set_param -n $name $val"
2759 check_catastrophe() {
2760 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
2761 local C=$CATASTROPHE
2762 [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
2764 if [ $rnodes ]; then
2765 do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
2766 if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
2782 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
2784 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
2785 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
2786 stripe_index=`awk '$1 ~ /stripe_offset/ {print $2}' $tmp_file`
2790 # CMD: determine mds index where directory inode presents
2793 local file=$dir/f0.get_mds_dir_tmpfile
2797 local iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2798 local -a oldused=($iused)
2802 iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2803 local -a newused=($iused)
2806 for ((i=0; i<${#newused[@]}; i++)); do
2807 if [ ${oldused[$i]} -lt ${newused[$i]} ]; then
2813 error "mdt-s : inodes count OLD ${oldused[@]} NEW ${newused[@]}"
2816 mdsrate_cleanup () {
2817 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
2820 delayed_recovery_enabled () {
2821 local var=${SINGLEMDS}_svc
2822 do_facet $SINGLEMDS lctl get_param -n mdd.${!var}.stale_export_age > /dev/null 2>&1
2825 ########################
2826 convert_facet2name() {
2828 "ost" ) echo "OST0000" ;;
2829 "ost1") echo "OST0000" ;;
2830 "ost2") echo "OST0001" ;;
2831 "ost3") echo "OST0002" ;;
2832 "ost4") echo "OST0003" ;;
2833 "ost5") echo "OST0004" ;;
2834 *) error "unknown facet!" ;;
2838 get_clientosc_proc_path() {
2844 get_lustre_version () {
2845 local node=${1:-"mds"}
2846 do_facet $node $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
2849 get_mds_version_major () {
2850 local version=$(get_lustre_version mds)
2851 echo $version | awk -F. '{print $1}'
2854 get_mds_version_minor () {
2855 local version=$(get_lustre_version mds)
2856 echo $version | awk -F. '{print $2}'
2859 get_mdtosc_proc_path() {
2861 local major=$(get_mds_version_major)
2862 local minor=$(get_mds_version_minor)
2863 if [ $major -le 1 -a $minor -le 8 ] ; then
2866 echo "${ost}-osc-MDT0000"
2870 get_osc_import_name() {
2873 local name=$(convert_facet2name $ost)
2875 if [ "$node" == "mds" ]; then
2876 get_mdtosc_proc_path $name
2880 get_clientosc_proc_path $name
2884 wait_osc_import_state() {
2888 local ost=$(get_osc_import_name $node $ost_facet)
2893 CONN_PROC="osc.${FSNAME}-${ost}.ost_server_uuid"
2894 CONN_STATE=$(do_facet $node lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
2895 while [ "${CONN_STATE}" != "${expected}" ]; do
2896 if [ "${expected}" == "DISCONN" ]; then
2897 # for disconn we can check after proc entry is removed
2898 [ "x${CONN_STATE}" == "x" ] && return 0
2899 # with AT we can have connect request timeout ~ reconnect timeout
2900 # and test can't see real disconnect
2901 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
2903 # disconnect rpc should be wait not more obd_timeout
2904 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
2905 error "can't put import for ${ost}(${ost_facet}) into ${expected} state" && return 1
2907 CONN_STATE=$(do_facet $node lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
2911 log "${ost_facet} now in ${CONN_STATE} state"