2 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
4 trap 'print_summary && touch $TF_FAIL && \
5 echo "test-framework exiting on error"' ERR
9 export REFORMAT=${REFORMAT:-""}
10 export WRITECONF=${WRITECONF:-""}
12 export CATASTROPHE=${CATASTROPHE:-/proc/sys/lnet/catastrophe}
15 export GSS_PIPEFS=false
16 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
24 . $LUSTRE/tests/yaml.sh
26 LUSTRE_TESTS_CFG_DIR=${LUSTRE_TESTS_CFG_DIR:-${LUSTRE}/tests/cfg}
28 EXCEPT_LIST_FILE=${EXCEPT_LIST_FILE:-${LUSTRE_TESTS_CFG_DIR}/tests-to-skip.sh}
30 if [ -f "$EXCEPT_LIST_FILE" ]; then
31 echo "Reading test skip list from $EXCEPT_LIST_FILE"
36 [ -z "$MODPROBECONF" -a -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
37 [ -z "$MODPROBECONF" -a -f /etc/modprobe.d/Lustre ] && MODPROBECONF=/etc/modprobe.d/Lustre
41 [[ $DIR/ = $MOUNT/* ]] || \
42 { failed=1 && echo "DIR=$DIR not in $MOUNT. Aborting."; }
43 [[ $DIR1/ = $MOUNT1/* ]] || \
44 { failed=1 && echo "DIR1=$DIR1 not in $MOUNT1. Aborting."; }
45 [[ $DIR2/ = $MOUNT2/* ]] || \
46 { failed=1 && echo "DIR2=$DIR2 not in $MOUNT2. Aborting"; }
48 [ -n "$failed" ] && exit 99 || true
52 echo "usage: $0 [-r] [-f cfgfile]"
60 [ "$TESTSUITE" == "lfsck" ] && return 0
61 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to ${ONLY}."
62 local form="%-13s %-17s %s\n"
63 printf "$form" "status" "script" "skipped tests E(xcluded) S(low)"
64 echo "------------------------------------------------------------------------------------"
65 for O in $DEFAULT_SUITES; do
68 O=$(echo $O | tr "-" "_" | tr "[:lower:]" "[:upper:]")
69 local o=$(echo $O | tr "[:upper:]" "[:lower:]")
71 local log=${TMP}/${o}.log
72 [ -f $log ] && skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
73 [ -f $log ] && slow=$(grep SLOW $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
74 [ "${!O}" = "done" ] && \
75 printf "$form" "Done" "$O" "E=$skipped" && \
76 [ -n "$slow" ] && printf "$form" "-" "-" "S=$slow"
80 for O in $DEFAULT_SUITES; do
81 O=$(echo $O | tr "-" "_" | tr "[:lower:]" "[:upper:]")
82 if [ "${!O}" = "no" ]; then
84 # only for those tests suits which are run directly from acc-sm script:
85 # bonnie, iozone, etc.
86 if [ -f "$TESTSUITELOG" ] && grep FAIL $TESTSUITELOG | grep -q ' '$O ; then
87 printf "$form" "UNFINISHED" "$O" ""
89 printf "$form" "Skipped" "$O" ""
94 for O in $DEFAULT_SUITES; do
95 O=$(echo $O | tr "-" "_" | tr "[:lower:]" "[:upper:]")
96 [ "${!O}" = "done" -o "${!O}" = "no" ] || \
97 printf "$form" "UNFINISHED" "$O" ""
102 export LUSTRE=`absolute_path $LUSTRE`
103 export TESTSUITE=`basename $0 .sh`
104 export TEST_FAILED=false
105 export FAIL_ON_SKIP_ENV=${FAIL_ON_SKIP_ENV:-false}
107 export MKE2FS=${MKE2FS:-mke2fs}
108 export DEBUGFS=${DEBUGFS:-debugfs}
109 export TUNE2FS=${TUNE2FS:-tune2fs}
110 export E2LABEL=${E2LABEL:-e2label}
111 export DUMPE2FS=${DUMPE2FS:-dumpe2fs}
112 export E2FSCK=${E2FSCK:-e2fsck}
113 export LFSCK_BIN=${LFSCK_BIN:-lfsck}
114 export LFSCK_ALWAYS=${LFSCK_ALWAYS:-"no"} # check filesystem after each test suit
115 export SKIP_LFSCK=${SKIP_LFSCK:-"yes"} # bug 13698, change to "no" when fixed
116 export SHARED_DIRECTORY=${SHARED_DIRECTORY:-"/tmp"}
117 export FSCK_MAX_ERR=4 # File system errors left uncorrected
118 if [ "$SKIP_LFSCK" == "no" ]; then
119 if [ ! -x `which $LFSCK_BIN` ]; then
121 error_exit "$E2FSCK does not support lfsck"
124 export MDSDB=${MDSDB:-$SHARED_DIRECTORY/mdsdb}
125 export OSTDB=${OSTDB:-$SHARED_DIRECTORY/ostdb}
126 export MDSDB_OPT="--mdsdb $MDSDB"
127 export OSTDB_OPT="--ostdb $OSTDB-\$ostidx"
129 #[ -d /r ] && export ROOT=${ROOT:-/r}
130 export TMP=${TMP:-$ROOT/tmp}
131 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
132 if [[ -z $LOGDIRSET ]]; then
133 export LOGDIR=${LOGDIR:-${TMP}/test_logs/}/$(date +%s)
134 export LOGDIRSET=true
136 export HOSTNAME=${HOSTNAME:-`hostname`}
137 if ! echo $PATH | grep -q $LUSTRE/utils; then
138 export PATH=$PATH:$LUSTRE/utils
140 if ! echo $PATH | grep -q $LUSTRE/utils/gss; then
141 export PATH=$PATH:$LUSTRE/utils/gss
143 if ! echo $PATH | grep -q $LUSTRE/tests; then
144 export PATH=$LUSTRE/tests:$PATH
146 if ! echo $PATH | grep -q $LUSTRE/../lustre-iokit/sgpdd-survey; then
147 export PATH=$PATH:$LUSTRE/../lustre-iokit/sgpdd-survey
149 export LST=${LST:-"$LUSTRE/../lnet/utils/lst"}
150 [ ! -f "$LST" ] && export LST=$(which lst)
151 export SGPDDSURVEY=${SGPDDSURVEY:-"$LUSTRE/../lustre-iokit/sgpdd-survey/sgpdd-survey")}
152 [ ! -f "$SGPDDSURVEY" ] && export SGPDDSURVEY=$(which sgpdd-survey)
153 # Ubuntu, at least, has a truncate command in /usr/bin
154 # so fully path our truncate command.
155 export TRUNCATE=${TRUNCATE:-$LUSTRE/tests/truncate}
156 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mpi/mdsrate"}
157 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
158 if ! echo $PATH | grep -q $LUSTRE/tests/racer; then
159 export PATH=$LUSTRE/tests/racer:$PATH:
161 if ! echo $PATH | grep -q $LUSTRE/tests/mpi; then
162 export PATH=$PATH:$LUSTRE/tests/mpi
164 export RSYNC_RSH=${RSYNC_RSH:-rsh}
165 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
166 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
167 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
168 [ ! -f "$LFS" ] && export LFS=$(which lfs)
169 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
170 if [ ! -f "$L_GETIDENTITY" ]; then
171 if `which l_getidentity > /dev/null 2>&1`; then
172 export L_GETIDENTITY=$(which l_getidentity)
174 export L_GETIDENTITY=NONE
177 export LL_DECODE_FILTER_FID=${LL_DECODE_FILTER_FID:-"$LUSTRE/utils/ll_decode_filter_fid"}
178 [ ! -f "$LL_DECODE_FILTER_FID" ] && export LL_DECODE_FILTER_FID=$(which ll_decode_filter_fid)
179 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
180 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
181 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
182 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
183 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
184 export LUSTRE_RMMOD=${LUSTRE_RMMOD:-$LUSTRE/scripts/lustre_rmmod}
185 [ ! -f "$LUSTRE_RMMOD" ] && export LUSTRE_RMMOD=$(which lustre_rmmod 2> /dev/null)
186 export FSTYPE=${FSTYPE:-"ldiskfs"}
187 export NAME=${NAME:-local}
188 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
189 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
190 export LGSSD=$(which lgssd)
191 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
192 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd 2> /dev/null)
193 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
195 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
198 if [ "$ACCEPTOR_PORT" ]; then
199 export PORT_OPT="--port $ACCEPTOR_PORT"
204 echo "Using GSS/krb5 ptlrpc security flavor"
205 which lgss_keyring > /dev/null 2>&1 || \
206 error_exit "built with gss disabled! SEC=$SEC"
217 IDENTITY_UPCALL=false
220 export LOAD_MODULES_REMOTE=${LOAD_MODULES_REMOTE:-false}
222 # Paths on remote nodes, if different
223 export RLUSTRE=${RLUSTRE:-$LUSTRE}
224 export RPWD=${RPWD:-$PWD}
225 export I_MOUNTED=${I_MOUNTED:-"no"}
226 if [ ! -f /lib/modules/$(uname -r)/kernel/fs/lustre/mds.ko -a \
227 ! -f /lib/modules/$(uname -r)/updates/kernel/fs/lustre/mds.ko -a \
228 ! -f `dirname $0`/../mds/mds.ko ]; then
229 export CLIENTMODSONLY=yes
234 while getopts "rvwf:" opt $*; do
237 r) REFORMAT=--reformat;;
239 w) WRITECONF=writeconf;;
244 shift $((OPTIND - 1))
247 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
252 2.4.*) EXT=".o"; USE_QUOTA=no; [ ! "$CLIENTONLY" ] && FSTYPE=ext3;;
253 *) EXT=".ko"; USE_QUOTA=yes;;
258 /sbin/lsmod | grep -q $1
261 # Load a module on the system where this is running.
263 # Synopsis: load_module module_name [module arguments for insmod/modprobe]
265 # If module arguments are not given but MODOPTS_<MODULE> is set, then its value
266 # will be used as the arguments. Otherwise arguments will be obtained from
267 # /etc/modprobe.conf, from /etc/modprobe.d/Lustre, or else none will be used.
274 BASE=`basename $module $EXT`
276 module_loaded ${BASE} && return
278 # If no module arguments were passed, get them from $MODOPTS_<MODULE>, else from
280 if [ $# -eq 0 ]; then
281 # $MODOPTS_<MODULE>; we could use associative arrays, but that's not in
282 # Bash until 4.x, so we resort to eval.
283 optvar="MODOPTS_$(basename $module | tr a-z A-Z)"
284 eval set -- \$$optvar
285 if [ $# -eq 0 -a -n "$MODPROBECONF" ]; then
286 # Nothing in $MODOPTS_<MODULE>; try modprobe.conf
287 set -- $(grep "^options\\s*\<${module}\>" $MODPROBECONF)
288 # Get rid of "options $module"
289 (($# > 0)) && shift 2
291 # Ensure we have accept=all for lnet
292 if [ $(basename $module) = lnet ]; then
293 # OK, this is a bit wordy...
294 local arg accept_all_present=false
296 [ "$arg" = accept=all ] && accept_all_present=true
298 $accept_all_present || set -- "$@" accept=all
303 [ $# -gt 0 ] && echo "${module} options: '$*'"
305 # Note that insmod will ignore anything in modprobe.conf, which is why we're
306 # passing options on the command-line.
307 if [ "$BASE" == "lnet_selftest" ] && \
308 [ -f ${LUSTRE}/../lnet/selftest/${module}${EXT} ]; then
309 insmod ${LUSTRE}/../lnet/selftest/${module}${EXT}
310 elif [ -f ${LUSTRE}/${module}${EXT} ]; then
311 insmod ${LUSTRE}/${module}${EXT} "$@"
313 # must be testing a "make install" or "rpm" installation
314 # note failed to load ptlrpc_gss is considered not fatal
315 if [ "$BASE" == "ptlrpc_gss" ]; then
316 modprobe $BASE "$@" 2>/dev/null || echo "gss/krb5 is not supported"
323 load_modules_local() {
324 if [ -n "$MODPROBE" ]; then
326 echo "Using modprobe to load modules"
330 echo Loading modules from $LUSTRE
331 load_module ../libcfs/libcfs/libcfs
332 [ "$PTLDEBUG" ] && lctl set_param debug="$PTLDEBUG"
333 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug="${SUBSYSTEM# }"
334 load_module ../lnet/lnet/lnet
335 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
336 load_module ../lnet/klnds/$LNETLND
337 load_module lvfs/lvfs
338 load_module obdclass/obdclass
339 load_module ptlrpc/ptlrpc
340 load_module ptlrpc/gss/ptlrpc_gss
341 [ "$USE_QUOTA" = "yes" -a "$LQUOTA" != "no" ] && load_module quota/lquota $LQUOTAOPTS
349 if ! client_only; then
350 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
351 grep -q -w jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
352 grep -q -w jbd2 /proc/kallsyms || { modprobe jbd2 2>/dev/null || true; }
353 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
358 load_module lvfs/fsfilt_$FSTYPE
360 load_module osd-ldiskfs/osd_ldiskfs
362 load_module obdfilter/obdfilter
365 load_module llite/lustre
366 load_module llite/llite_lloop
367 [ -d /r ] && OGDB=${OGDB:-"/r/tmp"}
369 rm -f $OGDB/ogdb-$HOSTNAME
370 $LCTL modules > $OGDB/ogdb-$HOSTNAME
372 # 'mount' doesn't look in $PATH, just sbin
373 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
379 # load modules on remote nodes optionally
380 # lustre-tests have to be installed on these nodes
381 if $LOAD_MODULES_REMOTE ; then
382 local list=$(comma_list $(remote_nodes_list))
383 echo loading modules on $list
384 do_rpc_nodes $list load_modules
389 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
390 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
391 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
392 echo "$LEAK_LUSTRE" 1>&2
393 echo "$LEAK_PORTALS" 1>&2
394 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
395 echo "Memory leaks detected"
396 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
402 wait_exit_ST client # bug 12845
404 $LUSTRE_RMMOD $FSTYPE || return 2
406 if $LOAD_MODULES_REMOTE ; then
407 local list=$(comma_list $(remote_nodes_list))
408 if [ ! -z $list ]; then
409 echo unloading modules on $list
410 do_rpc_nodes $list $LUSTRE_RMMOD $FSTYPE
411 do_rpc_nodes $list check_mem_leak
415 check_mem_leak || return 254
417 echo "modules unloaded."
421 check_gss_daemon_nodes() {
425 do_nodesv $list "num=\\\$(ps -o cmd -C $dname | grep $dname | wc -l);
426 if [ \\\"\\\$num\\\" -ne 1 ]; then
427 echo \\\$num instance of $dname;
432 check_gss_daemon_facet() {
436 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
437 if [ $num -ne 1 ]; then
438 echo "$num instance of $dname on $facet"
447 echo Stopping $@ on $list
448 do_nodes $list "killall -2 $@ 2>/dev/null || true"
451 # start gss daemons on all nodes, or
452 # "daemon" on "list" if set
453 start_gss_daemons() {
457 if [ "$list" ] && [ "$daemon" ] ; then
458 echo "Starting gss daemon on nodes: $list"
459 do_nodes $list "$daemon" || return 8
463 local list=$(comma_list $(mdts_nodes))
465 echo "Starting gss daemon on mds: $list"
466 do_nodes $list "$LSVCGSSD -v" || return 1
468 do_nodes $list "$LGSSD -v" || return 2
471 list=$(comma_list $(osts_nodes))
472 echo "Starting gss daemon on ost: $list"
473 do_nodes $list "$LSVCGSSD -v" || return 3
474 # starting on clients
476 local clients=${CLIENTS:-`hostname`}
478 echo "Starting $LGSSD on clients $clients "
479 do_nodes $clients "$LGSSD -v" || return 4
482 # wait daemons entering "stable" status
486 # check daemons are running
488 list=$(comma_list $(mdts_nodes) $(osts_nodes))
489 check_gss_daemon_nodes $list lsvcgssd || return 5
491 list=$(comma_list $(mdts_nodes))
492 check_gss_daemon_nodes $list lgssd || return 6
495 check_gss_daemon_nodes $clients lgssd || return 7
500 local list=$(comma_list $(mdts_nodes))
502 send_sigint $list lsvcgssd lgssd
504 list=$(comma_list $(osts_nodes))
505 send_sigint $list lsvcgssd
507 list=${CLIENTS:-`hostname`}
508 send_sigint $list lgssd
513 if ! module_loaded ptlrpc_gss; then
514 load_module ptlrpc/gss/ptlrpc_gss
515 module_loaded ptlrpc_gss ||
516 error_exit "init_gss : GSS=$GSS, but gss/krb5 is not supported!"
518 start_gss_daemons || error_exit "start gss daemon failed! rc=$?"
520 if [ -n "$LGSS_KEYRING_DEBUG" ]; then
521 echo $LGSS_KEYRING_DEBUG > /proc/fs/lustre/sptlrpc/gss/lgss_keyring/debug_level
529 # maybe cleanup credential cache?
535 local device=`mdsdevname $num`
536 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
542 local device=`ostdevname $num`
543 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
549 local facets=${1:-$(get_facets)}
552 for facet in ${facets//,/ }; do
553 mount_facet $facet || error "Restart of $facet failed!"
560 local dev=$(facet_active $facet)_dev
561 local opt=${facet}_opt
562 local mntpt=$(facet_mntpt $facet)
564 echo "Starting ${facet}: ${!opt} $@ ${!dev} $mntpt"
565 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} $mntpt
567 if [ $RC -ne 0 ]; then
568 echo "mount -t lustre $@ ${!dev} $mntpt"
569 echo "Start of ${!dev} on ${facet} failed ${RC}"
571 do_facet ${facet} "lctl set_param debug=\\\"$PTLDEBUG\\\"; \
572 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\"; \
573 lctl set_param debug_mb=${DEBUG_SIZE}; \
576 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
577 [ -z "$label" ] && echo no label for ${!dev} && exit 1
578 eval export ${facet}_svc=${label}
579 echo Started ${label}
584 # start facet device options
590 eval export ${facet}_dev=${device}
591 eval export ${facet}_opt=\"$@\"
593 local varname=${facet}failover_dev
594 if [ -n "${!varname}" ] ; then
595 eval export ${facet}failover_dev=${!varname}
597 eval export ${facet}failover_dev=$device
600 local mntpt=$(facet_mntpt $facet)
601 do_facet ${facet} mkdir -p $mntpt
602 eval export ${facet}_MOUNT=$mntpt
612 local HOST=`facet_active_host $facet`
613 [ -z $HOST ] && echo stop: no host for $facet && return 0
615 local mntpt=$(facet_mntpt $facet)
616 running=$(do_facet ${facet} "grep -c $mntpt' ' /proc/mounts") || true
617 if [ ${running} -ne 0 ]; then
618 echo "Stopping $mntpt (opts:$@)"
619 do_facet ${facet} umount -d $@ $mntpt
622 # umount should block, but we should wait for unrelated obd's
623 # like the MGS or MGC to also stop.
624 wait_exit_ST ${facet}
627 # save quota version (both administrative and operational quotas)
628 # add an additional parameter if mountpoint is ever different from $MOUNT
629 quota_save_version() {
630 local fsname=${2:-$FSNAME}
632 local ver=$(tr -c -d "123" <<< $spec)
633 local type=$(tr -c -d "ug" <<< $spec)
635 [ -n "$ver" -a "$ver" != "3" ] && error "wrong quota version specifier"
637 [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; }
639 do_facet mgs "lctl conf_param ${fsname}-MDT*.mdd.quota_type=$spec"
641 local osts=$(get_facets OST)
642 for ost in ${osts//,/ }; do
644 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$spec"
648 # client could mount several lustre
650 local fsname=${1:-$FSNAME}
652 do_facet mgs lctl get_param mdd.${fsname}-MDT*.quota_type || rc=$?
653 do_nodes $(comma_list $(osts_nodes)) \
654 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
658 restore_quota_type () {
659 local mntpt=${1:-$MOUNT}
660 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
661 if [ ! "$old_QUOTA_TYPE" ] || [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
664 quota_save_version $old_QUOTA_TYPE
670 # We need save the original quota_type params, and restore them after testing
672 # Suppose that quota type the same on mds and ost
673 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
674 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
675 echo "[HOST:$HOSTNAME] [old_quota_type:$quota_type] [new_quota_type:$QUOTA_TYPE]"
676 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
677 export old_QUOTA_TYPE=$quota_type
678 quota_save_version $QUOTA_TYPE
680 qtype=$(tr -c -d "ug" <<< $QUOTA_TYPE)
681 $LFS quotacheck -$qtype $mntpt || error "quotacheck has failed for $type"
684 local quota_usrs=$QUOTA_USERS
686 # get_filesystem_size
687 local disksz=$(lfs df $mntpt | grep "filesystem summary:" | awk '{print $3}')
688 local blk_soft=$((disksz + 1024))
689 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
691 local Inodes=$(lfs df -i $mntpt | grep "filesystem summary:" | awk '{print $3}')
693 local i_hard=$((i_soft + i_soft / 20))
695 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
696 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
699 for usr in $quota_usrs; do
700 echo "Setting up quota on $HOSTNAME:$mntpt for $usr..."
702 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
704 eval $cmd || error "$cmd FAILED!"
706 # display the quota status
707 echo "Quota settings for $usr : "
708 $LFS quota -v -u $usr $mntpt || true
716 # Only supply -o to mount if we have options
717 if [ -n "$MOUNTOPT" ]; then
718 OPTIONS="-o $MOUNTOPT"
720 local device=$MGSNID:/$FSNAME
721 if [ -z "$mnt" -o -z "$FSNAME" ]; then
722 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
726 echo "Starting client: $client: $OPTIONS $device $mnt"
727 do_node $client mkdir -p $mnt
728 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
730 do_node $client "lctl set_param debug=\\\"$PTLDEBUG\\\";
731 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
732 lctl set_param debug_mb=${DEBUG_SIZE}"
745 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
746 if [ $running -ne 0 ]; then
747 echo "Stopping client $client $mnt (opts:$force)"
748 do_node $client lsof -t $mnt || need_kill=no
749 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
750 pids=$(do_node $client lsof -t $mnt | sort -u);
751 if [ -n $pids ]; then
752 do_node $client kill -9 $pids || true
756 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
757 if [ $busy -ne 0 ] ; then
758 echo "$mnt is still busy, wait one second" && sleep 1
759 do_node $client umount $force $mnt
764 # nodes is comma list
765 sanity_mount_check_nodes () {
771 # FIXME: assume that all cluster nodes run the same os
772 [ "$(uname)" = Linux ] || return 0
775 for mnt in $mnts ; do
776 do_nodes $nodes "running=\\\$(grep -c $mnt' ' /proc/mounts);
777 mpts=\\\$(mount | grep -w -c $mnt);
778 if [ \\\$running -ne \\\$mpts ]; then
779 echo \\\$(hostname) env are INSANE!;
787 sanity_mount_check_servers () {
789 { echo "CLIENTONLY mode, skip mount_check_servers"; return 0; } || true
790 echo Checking servers environments
792 # FIXME: modify get_facets to display all facets wo params
793 local facets="$(get_facets OST),$(get_facets MDS),mgs"
797 for facet in ${facets//,/ }; do
798 node=$(facet_host ${facet})
799 mntpt=$(facet_mntpt $facet)
800 sanity_mount_check_nodes $node $mntpt ||
801 { error "server $node environments are insane!"; return 1; }
805 sanity_mount_check_clients () {
806 local clients=${1:-$CLIENTS}
807 local mntpt=${2:-$MOUNT}
808 local mntpt2=${3:-$MOUNT2}
810 [ -z $clients ] && clients=$(hostname)
811 echo Checking clients $clients environments
813 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
814 error "clients environments are insane!"
817 sanity_mount_check () {
818 sanity_mount_check_servers || return 1
819 sanity_mount_check_clients || return 2
822 # mount clients if not mouted
823 zconf_mount_clients() {
826 local OPTIONS=${3:-$MOUNTOPT}
828 # Only supply -o to mount if we have options
829 if [ "$OPTIONS" ]; then
830 OPTIONS="-o $OPTIONS"
832 local device=$MGSNID:/$FSNAME
833 if [ -z "$mnt" -o -z "$FSNAME" ]; then
834 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
838 echo "Starting client $clients: $OPTIONS $device $mnt"
841 running=\\\$(mount | grep -c $mnt' ');
843 if [ \\\$running -eq 0 ] ; then
845 mount -t lustre $OPTIONS $device $mnt;
848 exit \\\$rc" || return ${PIPESTATUS[0]}
850 echo "Started clients $clients: "
851 do_nodes $clients "mount | grep -w $mnt"
853 do_nodes $clients "lctl set_param debug=\\\"$PTLDEBUG\\\";
854 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
855 lctl set_param debug_mb=${DEBUG_SIZE};"
860 zconf_umount_clients() {
867 echo "Stopping clients: $clients $mnt (opts:$force)"
868 do_nodes $clients "running=\\\$(grep -c $mnt' ' /proc/mounts);
869 if [ \\\$running -ne 0 ] ; then
870 echo Stopping client \\\$(hostname) $mnt opts:$force;
871 lsof -t $mnt || need_kill=no;
872 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
873 pids=\\\$(lsof -t $mnt | sort -u);
874 if [ -n \\\"\\\$pids\\\" ]; then
878 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy");
879 if [ \\\$busy -ne 0 ] ; then
880 echo "$mnt is still busy, wait one second" && sleep 1;
888 echo + $POWER_DOWN $node
892 shutdown_node_hard () {
896 for i in $(seq $attempts) ; do
899 ping -w 3 -c 1 $host > /dev/null 2>&1 || return 0
900 echo "waiting for $host to fail attempts=$attempts"
901 [ $i -lt $attempts ] || \
902 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
908 local mnt=${2:-$MOUNT}
911 if [ "$FAILURE_MODE" = HARD ]; then
912 shutdown_node_hard $client
914 zconf_umount_clients $client $mnt -f
920 local facets="$(get_facets OST),$(get_facets MDS)"
923 combined_mgs_mds || facets="$facets,mgs"
925 for facet in ${facets//,/ }; do
926 if [ $(facet_active_host $facet) == $host ]; then
927 affected="$affected $facet"
931 echo $(comma_list $affected)
936 local host=${2:-$(facet_host $facet)}
938 local label=$(convert_facet2label $facet)
939 do_node $host lctl dl | awk '{print $4}' | grep -q $label
942 facets_up_on_host () {
944 local facets=$(facets_on_host $host)
947 for facet in ${facets//,/ }; do
948 if $(facet_up $facet $host); then
949 affected_up="$affected_up $facet"
953 echo $(comma_list $affected_up)
959 if [ "$FAILURE_MODE" = HARD ]; then
960 shutdown_node_hard $(facet_active_host $facet)
968 echo + $POWER_UP $node
981 if [ "$FAILURE_MODE" = HARD ]; then
982 reboot_node $(facet_active_host $facet)
990 if [ "$FAILURE_MODE" = HARD ]; then
1000 for facet in ${facets//,/ }; do
1001 hosts=$(expand_list $hosts $(facet_host $facet) )
1007 _check_progs_installed () {
1011 for prog in $progs; do
1012 if ! [ "$(which $prog)" -o "${!prog}" ]; then
1013 echo $prog missing on $(hostname)
1020 check_progs_installed () {
1024 do_rpc_nodes $nodes _check_progs_installed $@
1027 # recovery-scale functions
1029 echo __$(echo $1 | tr '-' 'X')
1032 start_client_load() {
1035 local var=$(client_var_name $client)_load
1036 eval export ${var}=$load
1038 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
1039 BREAK_ON_ERROR=$BREAK_ON_ERROR \
1040 END_RUN_FILE=$END_RUN_FILE \
1041 LOAD_PID_FILE=$LOAD_PID_FILE \
1042 TESTSUITELOG=$TESTSUITELOG \
1044 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
1045 log "Started client load: ${load} on $client"
1050 start_client_loads () {
1051 local -a clients=(${1//,/ })
1052 local numloads=${#CLIENT_LOADS[@]}
1055 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
1056 testnum=$((nodenum % numloads))
1057 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
1059 # bug 22169: wait the background threads to start
1063 # only for remote client
1064 check_client_load () {
1066 local var=$(client_var_name $client)_load
1067 local TESTLOAD=run_${!var}.sh
1069 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
1071 # bug 18914: try to connect several times not only when
1072 # check ps, but while check_catastrophe also
1075 while [ $RC = 254 -a $tries -gt 0 ]; do
1079 if ! check_catastrophe $client; then
1081 if [ $RC -eq 254 ]; then
1082 # FIXME: not sure how long we shuold sleep here
1086 echo "check catastrophe failed: RC=$RC "
1090 # We can continue try to connect if RC=254
1091 # Just print the warning about this
1092 if [ $RC = 254 ]; then
1093 echo "got a return status of $RC from do_node while checking catastrophe on $client"
1096 # see if the load is still on the client
1099 while [ $RC = 254 -a $tries -gt 0 ]; do
1103 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
1108 if [ $RC = 254 ]; then
1109 echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
1110 # see if we can diagnose a bit why this is
1115 check_client_loads () {
1116 local clients=${1//,/ }
1120 for client in $clients; do
1121 check_client_load $client
1123 if [ "$rc" != 0 ]; then
1124 log "Client load failed on node $client, rc=$rc"
1130 restart_client_loads () {
1131 local clients=${1//,/ }
1132 local expectedfail=${2:-""}
1136 for client in $clients; do
1137 check_client_load $client
1139 if [ "$rc" != 0 -a "$expectedfail" ]; then
1140 local var=$(client_var_name $client)_load
1141 start_client_load $client ${!var}
1142 echo "Restarted client load ${!var}: on $client. Checking ..."
1143 check_client_load $client
1145 if [ "$rc" != 0 ]; then
1146 log "Client load failed to restart on node $client, rc=$rc"
1147 # failure one client load means test fail
1148 # we do not need to check other
1156 # End recovery-scale functions
1158 # verify that lustre actually cleaned up properly
1160 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1161 error "LBUG/LASSERT detected"
1162 BUSY=`dmesg | grep -i destruct || true`
1163 if [ "$BUSY" ]; then
1165 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
1169 check_mem_leak || exit 204
1171 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
1172 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
1174 if module_loaded lnet || module_loaded libcfs; then
1175 echo "$0: modules still loaded..." 1>&2
1192 RESULT=$(do_node $node "$TEST")
1193 if [ "$RESULT" == "$FINAL" ]; then
1194 echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
1197 [ $WAIT -ge $MAX ] && break
1198 echo "Waiting $((MAX - WAIT)) secs for update"
1199 WAIT=$((WAIT + sleep))
1202 echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
1206 wait_update_facet () {
1208 wait_update $(facet_active_host $facet) "$@"
1211 wait_delete_completed () {
1212 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
1213 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1217 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
1219 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
1220 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1221 [ "$TOTAL" -eq "$TOTALPREV" ] && return 0
1222 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
1226 echo "Delete is not completed in $MAX_WAIT sec"
1233 # we can use "for" here because we are waiting the slowest
1234 for host in ${hostlist//,/ }; do
1235 check_network "$host" 900
1237 while ! do_nodes $hostlist hostname > /dev/null; do sleep 5; done
1244 for facet in ${facetlist//,/ }; do
1245 hostlist=$(expand_list $hostlist $(facet_active_host $facet))
1247 wait_for_host $hostlist
1250 _wait_recovery_complete () {
1253 # Use default policy if $2 is not passed by caller.
1254 local MAX=${2:-$(max_recovery_time)}
1259 while [ $WAIT -lt $MAX ]; do
1260 STATUS=$(lctl get_param -n $param | grep status)
1262 [[ $STATUS = "status: COMPLETE" || $STATUS = "status: INACTIVE" ]] && return 0
1265 echo "Waiting $((MAX - WAIT)) secs for $param recovery done. $STATUS"
1267 echo "$param recovery not done in $MAX sec. $STATUS"
1271 wait_recovery_complete () {
1274 # with an assumption that at_max is the same on all nodes
1275 local MAX=${2:-$(max_recovery_time)}
1278 if [ "$FAILURE_MODE" = HARD ]; then
1279 facets=$(facets_on_host $(facet_active_host $facet))
1281 echo affected facets: $facets
1283 # we can use "for" here because we are waiting the slowest
1284 for facet in ${facets//,/ }; do
1285 local var_svc=${facet}_svc
1286 local param="*.${!var_svc}.recovery_status"
1288 local host=$(facet_active_host $facet)
1289 do_rpc_nodes $host _wait_recovery_complete $param $MAX
1293 wait_mds_ost_sync () {
1294 # just because recovery is done doesn't mean we've finished
1295 # orphan cleanup. Wait for llogs to get synchronized.
1296 echo "Waiting for orphan cleanup..."
1297 # MAX value includes time needed for MDS-OST reconnection
1298 local MAX=$(( TIMEOUT * 2 ))
1300 while [ $WAIT -lt $MAX ]; do
1301 local -a sync=($(do_nodes $(comma_list $(osts_nodes)) \
1302 "$LCTL get_param -n obdfilter.*.mds_sync"))
1305 for ((i=0; i<${#sync[@]}; i++)); do
1306 [ ${sync[$i]} -eq 0 ] && continue
1307 # there is a not finished MDS-OST synchronization
1311 sleep 2 # increase waiting time and cover statfs cache
1312 [ ${con} -eq 1 ] && return 0
1313 echo "Waiting $WAIT secs for $facet mds-ost sync done."
1316 echo "$facet recovery not done in $MAX sec. $STATUS"
1320 wait_destroy_complete () {
1321 echo "Waiting for destroy to be done..."
1322 # MAX value shouldn't be big as this mean server responsiveness
1323 # never increase this just to make test pass but investigate
1324 # why it takes so long time
1327 while [ $WAIT -lt $MAX ]; do
1328 local -a RPCs=($($LCTL get_param -n osc.*.destroys_in_flight))
1330 for ((i=0; i<${#RPCs[@]}; i++)); do
1331 [ ${RPCs[$i]} -eq 0 ] && continue
1332 # there are still some destroy RPCs in flight
1337 [ ${con} -eq 1 ] && return 0 # done waiting
1338 echo "Waiting $WAIT secs for destroys to be done."
1341 echo "Destroys weren't done in $MAX sec."
1351 # conf-sanity 31 takes a long time cleanup
1352 while [ $WAIT -lt 300 ]; do
1353 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
1354 [ -z "${running}" ] && return 0
1355 echo "waited $WAIT for${running}"
1356 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
1358 WAIT=$((WAIT + INTERVAL))
1360 echo "service didn't stop after $WAIT seconds. Still running:"
1365 wait_remote_prog () {
1371 [ "$PDSH" = "no_dsh" ] && return 0
1373 while [ $WAIT -lt $2 ]; do
1374 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
1375 [ -z "${running}" ] && return 0 || true
1376 echo "waited $WAIT for: "
1378 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
1380 WAIT=$((WAIT + INTERVAL))
1382 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
1383 [ -z "$pids" ] && return 0
1384 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
1385 # FIXME: not portable
1386 for pid in $pids; do
1387 cat /proc/${pid}/status || true
1388 cat /proc/${pid}/wchan || true
1390 kill -9 $pid || true
1399 # not every config has many clients
1401 if [ ! -z "$CLIENTS" ]; then
1402 $PDSH $CLIENTS "stat -f $MOUNT" > /dev/null
1404 stat -f $MOUNT > /dev/null
1410 # usually checked on particular client or locally
1412 if [ ! -z "$client" ]; then
1413 $PDSH $client "stat -f $MOUNT" > /dev/null
1415 stat -f $MOUNT > /dev/null
1423 client_reconnect() {
1424 uname -n >> $MOUNT/recon
1425 if [ -z "$CLIENTS" ]; then
1426 df $MOUNT; uname -n >> $MOUNT/recon
1428 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
1430 echo Connected clients:
1432 ls -l $MOUNT/recon > /dev/null
1436 affected_facets () {
1439 local host=$(facet_active_host $facet)
1440 local affected=$facet
1442 if [ "$FAILURE_MODE" = HARD ]; then
1443 affected=$(facets_up_on_host $host)
1451 local host=$(facet_active_host $facet)
1453 echo "Failing $facet on node $host"
1455 local affected=$(affected_facets $facet)
1457 shutdown_facet $facet
1459 echo affected facets: $affected
1461 [ -n "$sleep_time" ] && sleep $sleep_time
1465 change_active $affected
1467 wait_for_facet $affected
1468 # start mgs first if it is affected
1469 if ! combined_mgs_mds && list_member $affected mgs; then
1470 mount_facet mgs || error "Restart of mgs failed"
1472 # FIXME; has to be changed to mount all facets concurrently
1473 affected=$(exclude_items_from_list $affected mgs)
1474 mount_facets $affected
1483 do_facet $facet sync
1485 local svc=${facet}_svc
1486 do_facet $facet $LCTL --device %${!svc} notransno
1487 do_facet $facet $LCTL --device %${!svc} readonly
1488 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1489 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1492 replay_barrier_nodf() {
1493 local facet=$1 echo running=${running}
1494 do_facet $facet sync
1495 local svc=${facet}_svc
1496 echo Replay barrier on ${!svc}
1497 do_facet $facet $LCTL --device %${!svc} notransno
1498 do_facet $facet $LCTL --device %${!svc} readonly
1499 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1500 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1503 replay_barrier_nosync() {
1504 local facet=$1 echo running=${running}
1505 local svc=${facet}_svc
1506 echo Replay barrier on ${!svc}
1507 do_facet $facet $LCTL --device %${!svc} notransno
1508 do_facet $facet $LCTL --device %${!svc} readonly
1509 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1510 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1513 mds_evict_client() {
1514 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
1515 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
1518 ost_evict_client() {
1519 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
1520 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1524 facet_failover $* || error "failover: $?"
1525 clients_up || error "post-failover df: $?"
1530 facet_failover $facet
1536 change_active $facet
1537 mount_facet $facet -o abort_recovery
1538 clients_up || echo "first df failed: $?"
1539 clients_up || error "post-failover df: $?"
1543 echo There is no lmc. This is mountconf, baby.
1548 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1554 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1555 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1556 if [ -z "$ID" ]; then
1557 echo "Could not get a ptl id for $1..."
1566 h2name_or_ip "$1" "tcp"
1571 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1572 if type __h2elan >/dev/null 2>&1; then
1575 ID=`echo $1 | sed 's/[^0-9]*//g'`
1583 h2name_or_ip "$1" "o2ib"
1590 [ "$facet" == client ] && echo -n $HOSTNAME && return
1591 varname=${facet}_HOST
1592 if [ -z "${!varname}" ]; then
1593 if [ "${facet:0:3}" == "ost" ]; then
1594 eval ${facet}_HOST=${ost_HOST}
1602 local activevar=${facet}active
1604 if [ -f $TMP/${facet}active ] ; then
1605 source $TMP/${facet}active
1608 active=${!activevar}
1609 if [ -z "$active" ] ; then
1616 facet_active_host() {
1618 local active=`facet_active $facet`
1619 if [ "$facet" == client ]; then
1622 echo `facet_host $active`
1630 facetlist=$(exclude_items_from_list $facetlist mgs)
1632 for facet in ${facetlist//,/ }; do
1633 local failover=${facet}failover
1634 local host=`facet_host $failover`
1635 [ -z "$host" ] && return
1637 local curactive=`facet_active $facet`
1638 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1639 eval export ${facet}active=$facet
1641 eval export ${facet}active=$failover
1643 # save the active host for this facet
1644 local activevar=${facet}active
1645 echo "$activevar=${!activevar}" > $TMP/$activevar
1646 local TO=`facet_active_host $facet`
1647 echo "Failover $facet to $TO"
1653 # do not stripe off hostname if verbose, bug 19215
1654 if [ x$1 = x--verbose ]; then
1662 if [ "$HOST" = "$HOSTNAME" ]; then
1664 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1665 echo "cannot run remote command on $HOST with $myPDSH"
1669 echo "CMD: $HOST $@" >&2
1670 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
1673 if [ "$myPDSH" = "rsh" ]; then
1674 # we need this because rsh does not return exit code of an executed command
1675 local command_status="$TMP/cs"
1676 rsh $HOST ":> $command_status"
1677 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1678 cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\") ||
1679 echo command failed >$command_status"
1680 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1685 # print HOSTNAME for myPDSH="no_dsh"
1686 if [[ $myPDSH = no_dsh ]]; then
1687 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
1689 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")"
1692 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed "s/^${HOST}: //"
1694 return ${PIPESTATUS[0]}
1698 do_node --verbose "$@"
1701 single_local_node () {
1702 [ "$1" = "$HOSTNAME" ]
1705 # Outputs environment variable assignments that should be passed to remote nodes
1710 for var in ${!MODOPTS_*}; do
1712 echo "${var}=\"$value\""
1718 # do not stripe off hostname if verbose, bug 19215
1719 if [ x$1 = x--verbose ]; then
1727 if single_local_node $rnodes; then
1729 do_nodev $rnodes "$@"
1731 do_node $rnodes "$@"
1736 # This is part from do_node
1739 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1740 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1743 echo "CMD: $rnodes $@" >&2
1744 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
1747 # do not replace anything from pdsh output if -N is used
1748 # -N Disable hostname: prefix on lines of output.
1749 if $verbose || [[ $myPDSH = *-N* ]]; then
1750 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" $(get_env_vars) sh -c \"$@\")"
1752 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" $(get_env_vars) sh -c \"$@\")" | sed -re "s/^[^:]*: //g"
1754 return ${PIPESTATUS[0]}
1760 local HOST=`facet_active_host $facet`
1761 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1766 do_nodes --verbose "$@"
1772 # make sure its not already running
1774 rm -f $TMP/${facet}active
1775 do_facet ${facet} $MKFS $*
1781 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1782 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1789 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
1790 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1796 local var=${facet}_MOUNT
1797 eval mntpt=${!var:-${MOUNT%/*}/$facet}
1806 # make sure we are using the primary server, so test-framework will
1807 # be able to clean up properly.
1808 activemds=`facet_active mds1`
1809 if [ $activemds != "mds1" ]; then
1813 local clients=$CLIENTS
1814 [ -z $clients ] && clients=$(hostname)
1816 zconf_umount_clients $clients $MOUNT "$*" || true
1817 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
1819 [ "$CLIENTONLY" ] && return
1820 # The add fn does rm ${facet}active file, this would be enough
1821 # if we use do_facet <facet> only after the facet added, but
1822 # currently we use do_facet mds in local.sh
1823 for num in `seq $MDSCOUNT`; do
1825 rm -f ${TMP}/mds${num}active
1828 for num in `seq $OSTCOUNT`; do
1830 rm -f $TMP/ost${num}active
1833 if ! combined_mgs_mds ; then
1840 cleanup_echo_devs () {
1841 local devs=$($LCTL dl | grep echo | awk '{print $4}')
1843 for dev in $devs; do
1844 $LCTL --device $dev cleanup
1845 $LCTL --device $dev detach
1850 nfs_client_mode && return
1859 combined_mgs_mds () {
1860 [[ $MDSDEV1 = $MGSDEV ]] && [[ $mds1_HOST = $mgs_HOST ]]
1866 local tgt=$(echo $facet | tr -d [:digit:] | tr "[:lower:]" "[:upper:]")
1867 local optvar=${tgt}_MKFS_OPTS
1868 local opt=${!optvar}
1870 # FIXME: ! combo mgs/mds + mgsfailover is not supported yet
1871 [[ $facet = mgs ]] && echo $opt && return
1874 # --failnode options
1875 local var=${facet}failover_HOST
1876 if [ x"${!var}" != x ] && [ x"${!var}" != x$(facet_host $facet) ] ; then
1877 local failnode=$(h2$NETTYPE ${!var})
1878 failnode="--failnode=$failnode"
1879 # options does not contain
1880 # or contains wrong --failnode=
1881 if [[ $opt != *${failnode}* ]]; then
1882 opt=$(echo $opt | sed 's/--failnode=.* / /')
1883 opt="$opt $failnode"
1889 # no additional mkfs mds "--mgsnode" option for this configuration
1890 if [[ $facet = mds ]] && combined_mgs_mds; then
1895 # additional mkfs "--mgsnode"
1896 local mgsnode="--mgsnode=$MGSNID"
1897 opt=${opt//$mgsnode }
1898 for nid in ${MGSNID//:/ }; do
1899 local mgsnode="--mgsnode=$nid"
1900 # options does not contain
1902 if [[ $opt != *${mgsnode}" "* ]]; then
1903 opt="$opt --mgsnode=$nid"
1911 if [ "$IAMDIR" == "yes" ]; then
1912 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --iam-dir"
1915 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1918 # We need ldiskfs here, may as well load them all
1920 [ "$CLIENTONLY" ] && return
1921 echo Formatting mgs, mds, osts
1922 if ! combined_mgs_mds ; then
1923 add mgs $(mkfs_opts mgs) $FSTYPE_OPT --reformat $MGSDEV || exit 10
1926 for num in `seq $MDSCOUNT`; do
1927 echo "Format mds$num: $(mdsdevname $num)"
1929 add mds$num $(mkfs_opts mds) $FSTYPE_OPT --reformat $(mdsdevname $num) || exit 10
1931 add mds$num $(mkfs_opts mds) $FSTYPE_OPT --reformat $(mdsdevname $num) > /dev/null || exit 10
1935 # the ost-s could have different OST_MKFS_OPTS
1936 # because of different failnode-s
1937 for num in `seq $OSTCOUNT`; do
1938 echo "Format ost$num: $(ostdevname $num)"
1940 add ost$num $(mkfs_opts ost${num}) $FSTYPE_OPT --reformat `ostdevname $num` || exit 10
1942 add ost$num $(mkfs_opts ost${num}) $FSTYPE_OPT --reformat `ostdevname $num` > /dev/null || exit 10
1948 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1952 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1956 # 0: success, the old identity set already.
1957 # 1: success, the old identity does not set.
1962 local j=`expr $num - 1`
1963 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
1965 if [ -z "$MDT" ]; then
1969 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1972 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
1974 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
1977 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush=-1"
1979 if [ $old = "NONE" ]; then
1988 zconf_umount `hostname` $1 || error "umount failed"
1989 zconf_mount `hostname` $1 || error "mount failed"
1992 writeconf_facet () {
1996 do_facet $facet "$TUNEFS --writeconf $dev"
2000 for num in `seq $MDSCOUNT`; do
2001 DEVNAME=$(mdsdevname $num)
2002 writeconf_facet mds$num $DEVNAME
2005 for num in `seq $OSTCOUNT`; do
2006 DEVNAME=$(ostdevname $num)
2007 writeconf_facet ost$num $DEVNAME
2012 nfs_client_mode && return
2014 sanity_mount_check ||
2015 error "environments are insane!"
2019 if [ -z "$CLIENTONLY" ]; then
2020 echo Setup mgs, mdt, osts
2021 echo $WRITECONF | grep -q "writeconf" && \
2023 if ! combined_mgs_mds ; then
2024 start mgs $MGSDEV $MGS_MOUNT_OPTS
2027 for num in `seq $MDSCOUNT`; do
2028 DEVNAME=$(mdsdevname $num)
2029 start mds$num $DEVNAME $MDS_MOUNT_OPTS
2031 # We started mds, now we should set failover variables properly.
2032 # Set mds${num}failover_HOST if it is not set (the default failnode).
2033 local varname=mds${num}failover_HOST
2034 if [ -z "${!varname}" ]; then
2035 eval mds${num}failover_HOST=$(facet_host mds$num)
2038 if [ $IDENTITY_UPCALL != "default" ]; then
2039 switch_identity $num $IDENTITY_UPCALL
2042 for num in `seq $OSTCOUNT`; do
2043 DEVNAME=$(ostdevname $num)
2044 start ost$num $DEVNAME $OST_MOUNT_OPTS
2046 # We started ost$num, now we should set ost${num}failover variable properly.
2047 # Set ost${num}failover_HOST if it is not set (the default failnode).
2048 varname=ost${num}failover_HOST
2049 if [ -z "${!varname}" ]; then
2050 eval ost${num}failover_HOST=$(facet_host ost${num})
2058 # wait a while to allow sptlrpc configuration be propogated to targets,
2059 # only needed when mounting new target devices.
2064 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
2066 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
2068 if [ "$MOUNT_2" ]; then
2069 mount_client $MOUNT2
2070 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
2075 # by remounting mdt before ost, initial connect from mdt to ost might
2076 # timeout because ost is not ready yet. wait some time to its fully
2077 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
2078 # by a context negotiation rpc with $TIMEOUT.
2079 # FIXME better by monitoring import status.
2082 sleep $((TIMEOUT + 5))
2088 mounted_lustre_filesystems() {
2089 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
2092 init_facet_vars () {
2093 [ "$CLIENTONLY" ] && return 0
2100 eval export ${facet}_dev=${device}
2101 eval export ${facet}_opt=\"$@\"
2103 local dev=${facet}_dev
2104 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
2105 [ -z "$label" ] && echo no label for ${!dev} && exit 1
2107 eval export ${facet}_svc=${label}
2109 local varname=${facet}failover_HOST
2110 if [ -z "${!varname}" ]; then
2111 eval $varname=$(facet_host $facet)
2114 # ${facet}failover_dev is set in cfg file
2115 varname=${facet}failover_dev
2116 if [ -n "${!varname}" ] ; then
2117 eval export ${facet}failover_dev=${!varname}
2119 eval export ${facet}failover_dev=$device
2122 # get mount point of already mounted device
2123 # is facet_dev is already mounted then use the real
2124 # mount point of this facet; otherwise use $(facet_mntpt $facet)
2125 # i.e. ${facet}_MOUNT if specified by user or default
2126 local mntpt=$(do_facet ${facet} cat /proc/mounts | \
2127 awk '"'${!dev}'" == $1 && $3 == "lustre" { print $2 }')
2128 if [ -z $mntpt ]; then
2129 mntpt=$(facet_mntpt $facet)
2131 eval export ${facet}_MOUNT=$mntpt
2134 init_facets_vars () {
2137 if ! remote_mds_nodsh; then
2138 for num in `seq $MDSCOUNT`; do
2139 DEVNAME=`mdsdevname $num`
2140 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
2144 combined_mgs_mds || init_facet_vars mgs $MGSDEV $MGS_MOUNT_OPTS
2146 remote_ost_nodsh && return
2148 for num in `seq $OSTCOUNT`; do
2149 DEVNAME=`ostdevname $num`
2150 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
2154 osc_ensure_active () {
2159 while [ $period -lt $timeout ]; do
2160 count=$(do_facet $facet "lctl dl | grep ' IN osc ' 2>/dev/null | wc -l")
2161 if [ $count -eq 0 ]; then
2165 echo "There are $count OST are inactive, wait $period seconds, and try again"
2167 period=$((period+3))
2170 [ $period -lt $timeout ] || log "$count OST are inactive after $timeout seconds, give up"
2173 init_param_vars () {
2174 if ! remote_ost_nodsh && ! remote_mds_nodsh; then
2175 export MDSVER=$(do_facet $SINGLEMDS "lctl get_param version" | cut -d. -f1,2)
2176 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
2177 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
2181 TIMEOUT=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
2183 log "Using TIMEOUT=$TIMEOUT"
2185 osc_ensure_active $SINGLEMDS $TIMEOUT
2186 osc_ensure_active client $TIMEOUT
2188 if [ $QUOTA_AUTO -ne 0 ]; then
2189 if [ "$ENABLE_QUOTA" ]; then
2190 echo "enable quota as required"
2191 setup_quota $MOUNT || return 2
2193 echo "disable quota as required"
2194 $LFS quotaoff -ug $MOUNT > /dev/null 2>&1
2201 nfs_client_mode () {
2202 if [ "$NFSCLIENT" ]; then
2203 echo "NFSCLIENT mode: setup, cleanup, check config skipped"
2204 local clients=$CLIENTS
2205 [ -z $clients ] && clients=$(hostname)
2207 # FIXME: remove hostname when 19215 fixed
2208 do_nodes $clients "echo \\\$(hostname); grep ' '$MOUNT' ' /proc/mounts"
2209 declare -a nfsexport=(`grep ' '$MOUNT' ' /proc/mounts | awk '{print $1}' | awk -F: '{print $1 " " $2}'`)
2210 do_nodes ${nfsexport[0]} "echo \\\$(hostname); df -T ${nfsexport[1]}"
2216 check_config_client () {
2219 local mounted=$(mount | grep " $mntpt ")
2220 if [ "$CLIENTONLY" ]; then
2222 # CLIENTONLY should not depend on *_HOST settings
2223 local mgc=$($LCTL device_list | awk '/MGC/ {print $4}')
2224 # in theory someone could create a new,
2225 # client-only config file that assumed lustre was already
2226 # configured and didn't set the MGSNID. If MGSNID is not set,
2227 # then we should use the mgs nid currently being used
2228 # as the default value. bug 18021
2229 [[ x$MGSNID = x ]] &&
2232 if [[ x$mgc != xMGC$MGSNID ]]; then
2233 if [ "$mgs_HOST" ]; then
2234 local mgc_ip=$(ping -q -c1 -w1 $mgs_HOST | grep PING | awk '{print $3}' | sed -e "s/(//g" -e "s/)//g")
2235 # [[ x$mgc = xMGC$mgc_ip@$NETTYPE ]] ||
2236 # error_exit "MGSNID=$MGSNID, mounted: $mounted, MGC : $mgc"
2242 local myMGS_host=$mgs_HOST
2243 if [ "$NETTYPE" = "ptl" ]; then
2244 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
2247 echo Checking config lustre mounted on $mntpt
2248 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
2249 mgshost=$(echo $mgshost | awk -F: '{print $1}')
2251 # if [ "$mgshost" != "$myMGS_host" ]; then
2252 # log "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
2253 # Please use correct config or set mds_HOST correctly!"
2258 check_config_clients () {
2259 local clients=${CLIENTS:-$HOSTNAME}
2262 nfs_client_mode && return
2264 do_rpc_nodes $clients check_config_client $mntpt
2266 sanity_mount_check ||
2267 error "environments are insane!"
2271 local mdstimeout=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
2272 local cltimeout=$(lctl get_param -n timeout)
2273 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
2274 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
2281 [ -z $mntpt ] && return 1
2282 local mounted=$(mounted_lustre_filesystems)
2284 echo $mounted' ' | grep -w -q $mntpt' '
2288 [ $(find $1 -maxdepth 1 -print | wc -l) = 1 ] && return 0
2292 # empty lustre filesystem may have empty directories lost+found and .lustre
2294 [ $(find $1 -maxdepth 1 -name lost+found -o -name .lustre -prune -o \
2295 -print | wc -l) = 1 ] || return 1
2296 [ ! -d $1/lost+found ] || is_empty_dir $1/lost+found && return 0
2297 [ ! -d $1/.lustre ] || is_empty_dir $1/.lustre && return 0
2301 check_and_setup_lustre() {
2302 nfs_client_mode && return
2304 local MOUNTED=$(mounted_lustre_filesystems)
2308 # both MOUNT and MOUNT2 are not mounted
2309 if ! is_mounted $MOUNT && ! is_mounted $MOUNT2; then
2310 [ "$REFORMAT" ] && formatall
2311 # setupall mounts both MOUNT and MOUNT2 (if MOUNT_2 is set)
2313 is_mounted $MOUNT || error "NAME=$NAME not mounted"
2314 export I_MOUNTED=yes
2318 elif is_mounted $MOUNT2; then
2320 # MOUNT2 is mounted, while MOUNT_2 is not set
2321 if ! [ "$MOUNT_2" ]; then
2322 cleanup_mount $MOUNT2
2323 export I_UMOUNTED2=yes
2326 # MOUNT2 is mounted, MOUNT_2 is set
2328 # FIXME: what to do if check_config failed?
2330 # 1) remote client has mounted other Lustre fs ?
2331 # 2) it has insane env ?
2332 # let's try umount MOUNT2 on all clients and mount it again:
2333 if ! check_config_clients $MOUNT2; then
2334 cleanup_mount $MOUNT2
2335 restore_mount $MOUNT2
2336 export I_MOUNTED2=yes
2341 # MOUNT is mounted MOUNT2 is not mounted
2342 elif [ "$MOUNT_2" ]; then
2343 restore_mount $MOUNT2
2344 export I_MOUNTED2=yes
2348 # FIXME: what to do if check_config failed?
2350 # 1) remote client has mounted other Lustre fs?
2351 # 2) lustre is mounted on remote_clients atall ?
2352 check_config_clients $MOUNT
2356 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=\\\"$PTLDEBUG\\\";
2357 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
2358 lctl set_param debug_mb=${DEBUG_SIZE};
2365 if [ "$ONLY" == "setup" ]; then
2371 local clients=${CLIENTS:-$HOSTNAME}
2374 zconf_mount_clients $clients $mntpt
2378 local clients=${CLIENTS:-$HOSTNAME}
2381 zconf_umount_clients $clients $mntpt
2384 cleanup_and_setup_lustre() {
2385 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
2386 lctl set_param debug=0 || true
2388 if [ "$ONLY" == "cleanup" ]; then
2392 check_and_setup_lustre
2395 # Get all of the server target devices from a given server node and type.
2404 mdt) obd_type="osd" ;;
2405 ost) obd_type="obdfilter" ;; # needs to be fixed when OST also uses an OSD
2406 *) echo "invalid server type" && return 1 ;;
2409 devs=$(do_node $node "lctl get_param -n $obd_type*.*.mntdev")
2410 for dev in $devs; do
2412 *loop*) do_node $node "losetup $dev" | \
2413 sed -e "s/.*(//" -e "s/).*//" ;;
2419 # Get all of the server target devices.
2424 MDTDEV=$(get_mnt_devs $(mdts_nodes) mdt)
2428 for node in $(osts_nodes); do
2429 OSTDEVS[i]=$(get_mnt_devs $node ost)
2434 # Run e2fsck on MDT or OST device.
2441 df > /dev/null # update statfs data on disk
2442 local cmd="$E2FSCK -d -v -f -n $MDSDB_OPT $ostdb_opt $target_dev"
2445 do_node $node $cmd || rc=$?
2446 [ $rc -le $FSCK_MAX_ERR ] || \
2447 error "$cmd returned $rc, should be <= $FSCK_MAX_ERR"
2451 # Run e2fsck on MDT and OST(s) to generate databases used for lfsck.
2458 [ $MDSCOUNT -eq 1 ] || error "CMD is not supported"
2459 tmp_file=$(mktemp -p $SHARED_DIRECTORY ||
2460 error "fail to create file in $SHARED_DIRECTORY")
2462 # make sure everything gets to the backing store
2463 local list=$(comma_list $CLIENTS $(facet_host $SINGLEMDS) $(osts_nodes))
2464 do_nodes $list "sync; sleep 2; sync"
2466 do_nodes $list ls $tmp_file || \
2467 error "$SHARED_DIRECTORY is not a shared directory"
2470 run_e2fsck $(mdts_nodes) $MDTDEV
2475 for node in $(osts_nodes); do
2476 for dev in ${OSTDEVS[i]}; do
2477 local ostdb_opt=`eval echo $OSTDB_OPT`
2478 run_e2fsck $node $dev $ostidx "$ostdb_opt"
2479 OSTDB_LIST="$OSTDB_LIST $OSTDB-$ostidx"
2480 ostidx=$((ostidx + 1))
2487 local cmd="$LFSCK_BIN -c -l --mdsdb $MDSDB --ostdb $OSTDB_LIST $MOUNT"
2491 [ $rc -le $FSCK_MAX_ERR ] || \
2492 error "$cmd returned $rc, should be <= $FSCK_MAX_ERR"
2493 echo "lfsck finished with rc=$rc"
2495 rm -rvf $MDSDB* $OSTDB* || true
2499 check_and_cleanup_lustre() {
2500 if [ "$LFSCK_ALWAYS" = "yes" ]; then
2503 if [ "$SKIP_LFSCK" == "no" ]; then
2510 if is_mounted $MOUNT; then
2511 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
2512 [ "$ENABLE_QUOTA" ] && restore_quota_type || true
2515 if [ "$I_UMOUNTED2" = "yes" ]; then
2516 restore_mount $MOUNT2 || error "restore $MOUNT2 failed"
2519 if [ "$I_MOUNTED2" = "yes" ]; then
2520 cleanup_mount $MOUNT2
2523 if [ "$I_MOUNTED" = "yes" ]; then
2524 cleanupall -f || error "cleanup failed"
2536 while [ $NETWORK -eq 0 ]; do
2537 if ping -c 1 -w 3 $1 > /dev/null; then
2541 echo "waiting for $1, $((MAX - WAIT)) secs left"
2544 if [ $WAIT -gt $MAX ]; then
2545 echo "Network not available"
2551 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
2562 # the sed converts spaces to commas, but leaves the last space
2563 # alone, so the line doesn't end with a comma.
2564 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
2570 echo $list | grep -qw $item
2573 # list, excluded are the comma separated lists
2574 exclude_items_from_list () {
2580 for item in ${excluded//,/ }; do
2581 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
2583 echo $(comma_list $list)
2586 # list, expand are the comma separated lists
2588 local list=${1//,/ }
2589 local expand=${2//,/ }
2592 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
2593 echo $(comma_list $expanded)
2596 testslist_filter () {
2597 local script=$LUSTRE/tests/${TESTSUITE}.sh
2599 [ -f $script ] || return 0
2601 local start_at=$START_AT
2602 local stop_at=$STOP_AT
2604 local var=${TESTSUITE//-/_}_START_AT
2605 [ x"${!var}" != x ] && start_at=${!var}
2606 var=${TESTSUITE//-/_}_STOP_AT
2607 [ x"${!var}" != x ] && stop_at=${!var}
2609 sed -n 's/^test_\([^ (]*\).*/\1/p' $script | \
2610 awk ' BEGIN { if ("'${start_at:-0}'" != 0) flag = 1 }
2611 /^'${start_at}'$/ {flag = 0}
2612 {if (flag == 1) print $0}
2613 /^'${stop_at}'$/ { flag = 1 }'
2617 (cd `dirname $1`; echo $PWD/`basename $1`)
2621 local types=${1:-"OST MDS MGS"}
2625 for entry in $types; do
2626 local name=$(echo $entry | tr "[:upper:]" "[:lower:]")
2627 local type=$(echo $entry | tr "[:lower:]" "[:upper:]")
2630 MGS ) list="$list $name";;
2631 MDS|OST ) local count=${type}COUNT
2632 for ((i=1; i<=${!count}; i++)) do
2633 list="$list ${name}$i"
2635 * ) error "Invalid facet type"
2639 echo $(comma_list $list)
2642 ##################################
2643 # Adaptive Timeouts funcs
2646 # only check mds, we assume at_max is the same on all nodes
2647 local at_max=$(do_facet $SINGLEMDS "lctl get_param -n at_max")
2648 if [ $at_max -eq 0 ]; then
2658 # suppose that all ost-s has the same at_max set
2659 if [ $facet == "ost" ]; then
2660 do_facet ost1 "lctl get_param -n at_max"
2662 do_facet $facet "lctl get_param -n at_max"
2672 if [ $facet == "ost" ]; then
2673 for i in `seq $OSTCOUNT`; do
2674 do_facet ost$i "lctl set_param at_max=$at_max"
2677 elif [ $facet == "mds" ]; then
2678 for i in `seq $MDSCOUNT`; do
2679 do_facet mds$i "lctl set_param at_max=$at_max"
2682 do_facet $facet "lctl set_param at_max=$at_max"
2687 ##################################
2691 # OBD_FAIL_MDS_ALL_REQUEST_NET
2693 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
2694 do_facet client "$1" || RC=$?
2695 do_facet $SINGLEMDS lctl set_param fail_loc=0
2700 # OBD_FAIL_MDS_ALL_REPLY_NET
2702 do_facet $SINGLEMDS lctl set_param fail_loc=0x122
2703 do_facet client "$@" || RC=$?
2704 do_facet $SINGLEMDS lctl set_param fail_loc=0
2708 drop_reint_reply() {
2709 # OBD_FAIL_MDS_REINT_NET_REP
2711 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
2712 do_facet client "$@" || RC=$?
2713 do_facet $SINGLEMDS lctl set_param fail_loc=0
2718 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2720 do_facet ost1 lctl set_param fail_loc=0x214
2721 do_facet client "$1" || RC=$?
2722 do_facet client "sync"
2723 do_facet ost1 lctl set_param fail_loc=0
2727 drop_ldlm_cancel() {
2728 #define OBD_FAIL_LDLM_CANCEL 0x304
2730 do_facet client lctl set_param fail_loc=0x304
2731 do_facet client "$@" || RC=$?
2732 do_facet client lctl set_param fail_loc=0
2736 drop_bl_callback() {
2737 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
2739 do_facet client lctl set_param fail_loc=0x305
2740 do_facet client "$@" || RC=$?
2741 do_facet client lctl set_param fail_loc=0
2746 #define OBD_FAIL_LDLM_REPLY 0x30c
2748 do_facet $SINGLEMDS lctl set_param fail_loc=0x30c
2749 do_facet client "$@" || RC=$?
2750 do_facet $SINGLEMDS lctl set_param fail_loc=0
2758 echo "clearing fail_loc on $facet"
2759 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
2762 set_nodes_failloc () {
2763 do_nodes $(comma_list $1) lctl set_param fail_loc=$2
2766 cancel_lru_locks() {
2767 $LCTL mark "cancel_lru_locks $1 start"
2768 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
2769 $LCTL set_param -n $d=clear
2771 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
2772 $LCTL mark "cancel_lru_locks $1 stop"
2777 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
2778 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
2779 echo "$DEFAULT_LRU_SIZE"
2784 lctl set_param ldlm.namespaces.*$1*.lru_size=0
2787 lru_resize_disable()
2789 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
2794 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
2795 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
2796 echo there is still data in page cache $FILE ?
2797 lctl get_param -n $FILE
2805 DEBUGSAVE="$(lctl get_param -n debug)"
2809 [ -n "$DEBUGSAVE" ] && \
2810 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=\\\"${DEBUGSAVE}\\\";"
2815 DEBUG_SIZE_SAVED="$(lctl get_param -n debug_mb)"
2818 debug_size_restore() {
2819 [ -n "$DEBUG_SIZE_SAVED" ] && \
2820 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE_SAVED"
2824 start_full_debug_logging() {
2829 local DEBUG_SIZE=150
2831 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE"
2832 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=$FULLDEBUG;"
2835 stop_full_debug_logging() {
2840 ##################################
2842 ##################################
2845 local TYPE=${TYPE:-"FAIL"}
2848 # do not dump logs if $1=false
2849 if [ "x$1" = "xfalse" ]; then
2854 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
2856 # We need to dump the logs on all nodes
2858 gather_logs $(comma_list $(nodes_list))
2862 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
2863 echo "$@" > $LOGDIR/err
2875 # use only if we are ignoring failures for this test, bugno required.
2876 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
2877 # e.g. error_ignore 5494 "your message"
2879 local TYPE="IGNORE (bz$1)"
2885 $FAIL_ON_SKIP_ENV && error false $@ || skip $@
2890 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
2891 [ "$TESTSUITELOG" ] && \
2892 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
2895 build_test_filter() {
2896 EXCEPT="$EXCEPT $(testslist_filter)"
2898 [ "$ONLY" ] && log "only running test `echo $ONLY`"
2902 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
2903 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
2904 [ "$EXCEPT_SLOW" ] && \
2905 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
2906 for E in $EXCEPT $ALWAYS_EXCEPT; do
2907 eval EXCEPT_${E}=true
2909 for E in $EXCEPT_SLOW; do
2910 eval EXCEPT_SLOW_${E}=true
2912 for G in $GRANT_CHECK_LIST; do
2913 eval GCHECK_ONLY_${G}=true
2918 if [[ $1 = [a-z]* ]]; then
2925 # print a newline if the last test was skipped
2926 export LAST_SKIPPED=
2928 # Main entry into test-framework. This is called with the name and
2929 # description of a test. The name is used to find the function to run
2930 # the test using "test_$name".
2932 # This supports a variety of methods of specifying specific test to
2933 # run or not run. These need to be documented...
2938 export base=`basetest $1`
2939 if [ ! -z "$ONLY" ]; then
2941 if [ ${!testname}x != x ]; then
2942 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2943 run_one_logged $1 "$2"
2947 if [ ${!testname}x != x ]; then
2948 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2949 run_one_logged $1 "$2"
2957 if [ ${!testname}x != x ]; then
2959 TESTNAME=test_$1 skip "skipping excluded test $1"
2962 testname=EXCEPT_$base
2963 if [ ${!testname}x != x ]; then
2965 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
2968 testname=EXCEPT_SLOW_$1
2969 if [ ${!testname}x != x ]; then
2971 TESTNAME=test_$1 skip "skipping SLOW test $1"
2974 testname=EXCEPT_SLOW_$base
2975 if [ ${!testname}x != x ]; then
2977 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
2982 run_one_logged $1 "$2"
2993 module_loaded lnet || load_modules
3005 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
3010 strace -o $TMP/$1.strace -ttt $*
3012 log "FINISHED: $*: rc $RC"
3017 # Set TEST_STATUS here; will be used for logging the result
3018 if [ -f $LOGDIR/err ]; then
3023 echo $TEST_STATUS " " $@
3027 FFREE=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filesfree | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
3028 FTOTAL=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filestotal | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
3029 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
3033 echo -n "Resetting fail_loc on all nodes..."
3034 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 2>/dev/null || true"
3040 # Log a message (on all nodes) padded with "=" before and after.
3041 # Also appends a timestamp and prepends the testsuite name.
3044 EQUALS="===================================================================================================="
3046 msg="== ${TESTSUITE} $*"
3048 [[ $last != "=" && $last != " " ]] && msg="$msg "
3049 msg=$(printf '%s%.*s' "$msg" $((${#EQUALS} - ${#msg})) $EQUALS )
3050 # always include at least == after the message
3051 log "$msg== $(date +"%H:%M:%S (%s)")"
3055 # Run a single test function and cleanup after it.
3057 # This function should be run in a subshell so the test func can
3058 # exit() without stopping the whole script.
3064 export tdir=d0.${TESTSUITE}/d${base}
3065 export TESTNAME=test_$testnum
3066 local SAVE_UMASK=`umask`
3069 banner "test $testnum: $message"
3070 test_${testnum} || error "test_$testnum failed with $?"
3073 check_grant ${testnum} || error "check_grant $testnum failed with $?"
3074 check_catastrophe || error "LBUG/LASSERT detected"
3075 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
3083 # Wrapper around run_one to ensure:
3084 # - test runs in subshell
3085 # - output of test is saved to separate log file for error reporting
3086 # - test result is saved to data file
3089 local BEFORE=`date +%s`
3091 local name=${TESTSUITE}.test_${1}.test_log.$(hostname).log
3092 local test_log=$LOGDIR/$name
3096 log_sub_test_begin test_${1}
3097 (run_one $1 "$2") 2>&1 | tee $test_log
3098 local RC=${PIPESTATUS[0]}
3100 [ $RC -ne 0 ] && [ ! -f $LOGDIR/err ] && \
3101 echo "test_$1 returned $RC" | tee $LOGDIR/err
3103 duration=$((`date +%s` - $BEFORE))
3104 pass "(${duration}s)"
3105 [ -f $LOGDIR/err ] && TEST_ERROR=$(cat $LOGDIR/err)
3106 log_sub_test_end $TEST_STATUS $duration "$RC" "$TEST_ERROR"
3108 if [ -f $LOGDIR/err ]; then
3109 $FAIL_ON_ERROR && exit $RC
3116 (cd `dirname $1`; echo $PWD/`basename $1`)
3120 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
3121 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
3126 export base=`basetest $1`
3127 [ "$CHECK_GRANT" == "no" ] && return 0
3129 testname=GCHECK_ONLY_${base}
3130 [ ${!testname}x == x ] && return 0
3132 echo -n "checking grant......"
3134 # write some data to sync client lost_grant
3135 rm -f $DIR1/${tfile}_check_grant_* 2>&1
3136 for i in `seq $OSTCOUNT`; do
3137 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
3138 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
3139 count=1 > /dev/null 2>&1
3141 # sync all the data and make sure no pending data on server
3144 #get client grant and server grant
3146 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
3147 client_grant=$((client_grant + $d))
3150 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
3151 server_grant=$((server_grant + $d))
3154 # cleanup the check_grant file
3155 for i in `seq $OSTCOUNT`; do
3156 rm $DIR1/${tfile}_check_grant_$i
3159 #check whether client grant == server grant
3160 if [ $client_grant != $server_grant ]; then
3161 echo "failed: client:${client_grant} server: ${server_grant}"
3168 ########################
3174 ost=`echo $1 | awk -F_ '{print $3}'`
3175 if [ -z $ost ]; then
3176 ost=`echo $1 | sed 's/-osc.*//'`
3181 ostuuid_from_index()
3183 $LFS osts $2 | awk '/^'$1'/ { print $2 }'
3188 [ "$node" != "$(hostname)" ]
3194 for node in $(mdts_nodes); do
3195 remote_node $node && return 0
3202 [ "$CLIENTONLY" ] && return 0 || true
3203 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
3208 remote_mds_nodsh && echo "SKIP: $TESTSUITE: remote MDS with nodsh" && \
3209 MSKIPPED=1 && return 1
3216 for node in $(osts_nodes) ; do
3217 remote_node $node && return 0
3224 [ "$CLIENTONLY" ] && return 0 || true
3225 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
3230 remote_ost_nodsh && echo "SKIP: $TESTSUITE: remote OST with nodsh" && \
3231 OSKIPPED=1 && return 1
3238 MGS=$(facet_host mgs)
3239 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
3244 remote_mds_nodsh || remote_ost_nodsh || \
3245 $(single_local_node $(comma_list $(nodes_list)))
3251 for num in `seq $MDSCOUNT`; do
3252 MDSNODES="$MDSNODES $(facet_host mds$num)"
3254 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
3260 remote_ost && remote_mds
3268 for facet in ${facets//,/ }; do
3269 if [ "$FAILURE_MODE" = HARD ]; then
3270 nodes="$nodes $(facet_active_host $facet)"
3272 nodes="$nodes $(facet_host $facet)"
3275 NODES_sort=$(for i in $nodes; do echo $i; done | sort -u)
3281 local facets=$(get_facets OST)
3282 local nodes=$(facets_nodes $facets)
3288 # FIXME. We need a list of clients
3289 local myNODES=$HOSTNAME
3292 # CLIENTS (if specified) contains the local client
3293 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
3295 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
3296 myNODES="$myNODES $(facets_nodes $(get_facets))"
3299 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
3304 remote_nodes_list () {
3305 local rnodes=$(nodes_list)
3306 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
3310 init_clients_lists () {
3311 # Sanity check: exclude the local client from RCLIENTS
3312 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
3314 # Sanity check: exclude the dup entries
3315 rclients=$(for i in $rclients; do echo $i; done | sort -u)
3317 local clients="$SINGLECLIENT $HOSTNAME $rclients"
3319 # Sanity check: exclude the dup entries from CLIENTS
3320 # for those configs which has SINGLCLIENT set to local client
3321 clients=$(for i in $clients; do echo $i; done | sort -u)
3323 CLIENTS=`comma_list $clients`
3324 local -a remoteclients=($rclients)
3325 for ((i=0; $i<${#remoteclients[@]}; i++)); do
3326 varname=CLIENT$((i + 2))
3327 eval $varname=${remoteclients[i]}
3330 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
3333 get_random_entry () {
3336 rnodes=${rnodes//,/ }
3338 local -a nodes=($rnodes)
3339 local num=${#nodes[@]}
3340 local i=$((RANDOM * num * 2 / 65536))
3346 [ "$CLIENTONLY" ] || [ "$CLIENTMODSONLY" = yes ]
3351 lctl get_param version | grep -q patchless
3355 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
3360 echo $nodes | wc -w || true
3364 local nodes=$(osts_nodes)
3365 local osscount=$(get_node_count "$nodes")
3366 [ ! "$OSTCOUNT" = "$osscount" ]
3370 local nodes=$(mdts_nodes)
3371 local mdtcount=$(get_node_count "$nodes")
3372 [ ! "$MDSCOUNT" = "$mdtcount" ]
3375 generate_machine_file() {
3376 local nodes=${1//,/ }
3377 local machinefile=$2
3379 for node in $nodes; do
3380 echo $node >>$machinefile || \
3381 { echo "can not generate machinefile $machinefile" && return 1; }
3386 local file=$1/stripe
3388 $LFS getstripe -v $file || error
3392 setstripe_nfsserver () {
3395 local nfsserver=$(awk '"'$dir'" ~ $2 && $3 ~ "nfs" && $2 != "/" \
3396 { print $1 }' /proc/mounts | cut -f 1 -d : | head -1)
3398 [ -z $nfsserver ] && echo "$dir is not nfs mounted" && return 1
3400 do_nodev $nfsserver lfs setstripe "$@"
3403 check_runas_id_ret() {
3405 local myRUNAS_UID=$1
3406 local myRUNAS_GID=$2
3409 if [ -z "$myRUNAS" ]; then
3410 error_exit "myRUNAS command must be specified for check_runas_id"
3413 $myRUNAS krb5_login.sh || \
3414 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
3416 mkdir $DIR/d0_runas_test
3418 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
3419 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
3420 rm -rf $DIR/d0_runas_test
3425 local myRUNAS_UID=$1
3426 local myRUNAS_GID=$2
3429 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
3430 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
3431 Please set RUNAS_ID to some UID which exists on MDS and client or
3432 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
3435 # obtain the UID/GID for MPI_USER
3439 MPI_USER_UID=$(do_facet client "getent passwd $mpi_user | cut -d: -f3;
3440 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the UID for $mpi_user"
3442 MPI_USER_GID=$(do_facet client "getent passwd $mpi_user | cut -d: -f4;
3443 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the GID for $mpi_user"
3446 # obtain and cache Kerberos ticket-granting ticket
3447 refresh_krb5_tgt() {
3448 local myRUNAS_UID=$1
3449 local myRUNAS_GID=$2
3452 if [ -z "$myRUNAS" ]; then
3453 error_exit "myRUNAS command must be specified for refresh_krb5_tgt"
3456 CLIENTS=${CLIENTS:-$HOSTNAME}
3457 do_nodes $CLIENTS "set -x
3458 if ! $myRUNAS krb5_login.sh; then
3459 echo "Failed to refresh Krb5 TGT for UID/GID $myRUNAS_UID/$myRUNAS_GID."
3464 # Run multiop in the background, but wait for it to print
3465 # "PAUSING" to its stdout before returning from this function.
3466 multiop_bg_pause() {
3467 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
3471 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
3474 echo "$MULTIOP_PROG $FILE v$ARGS"
3475 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
3477 echo "TMPPIPE=${TMPPIPE}"
3478 read -t 60 multiop_output < $TMPPIPE
3479 if [ $? -ne 0 ]; then
3484 if [ "$multiop_output" != "PAUSING" ]; then
3485 echo "Incorrect multiop output: $multiop_output"
3500 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
3506 inodes_available () {
3507 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
3511 mdsrate_inodes_available () {
3512 echo $(($(inodes_available) - 1))
3515 # reset llite stat counters
3516 clear_llite_stats(){
3517 lctl set_param -n llite.*.stats 0
3520 # sum llite stat items
3521 calc_llite_stats() {
3522 local res=$(lctl get_param -n llite.*.stats |
3523 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
3527 # reset osc stat counters
3529 lctl set_param -n osc.*.osc_stats 0
3532 # sum osc stat items
3534 local res=$(lctl get_param -n osc.*.osc_stats |
3535 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
3540 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
3543 calc_osc_kbytes () {
3544 df $MOUNT > /dev/null
3545 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
3548 # save_lustre_params(node, parameter_mask)
3549 # generate a stream of formatted strings (<node> <param name>=<param value>)
3550 save_lustre_params() {
3552 do_nodesv $1 "lctl get_param $2 | while read s; do echo \\\$s; done"
3555 # restore lustre parameters from input stream, produces by save_lustre_params
3556 restore_lustre_params() {
3560 while IFS=" =" read node name val; do
3561 do_node ${node//:/} "lctl set_param -n $name $val"
3565 check_catastrophe() {
3566 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
3567 local C=$CATASTROPHE
3568 [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
3570 if [ $rnodes ]; then
3571 do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
3572 if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
3588 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
3590 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
3591 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
3592 stripe_index=`awk '$1 ~ /stripe_offset/ {print $2}' $tmp_file`
3596 # CMD: determine mds index where directory inode presents
3599 local file=$dir/f0.get_mds_dir_tmpfile
3604 local iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3605 local -a oldused=($iused)
3607 openfile -f O_CREAT:O_LOV_DELAY_CREATE -m 0644 $file > /dev/null
3609 iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3610 local -a newused=($iused)
3613 for ((i=0; i<${#newused[@]}; i++)); do
3614 if [ ${oldused[$i]} -lt ${newused[$i]} ]; then
3620 error "mdt-s : inodes count OLD ${oldused[@]} NEW ${newused[@]}"
3623 mdsrate_cleanup () {
3625 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
3630 delayed_recovery_enabled () {
3631 local var=${SINGLEMDS}_svc
3632 do_facet $SINGLEMDS lctl get_param -n mdd.${!var}.stale_export_age > /dev/null 2>&1
3635 ########################
3637 convert_facet2label() {
3640 if [ x$facet = xost ]; then
3644 local varsvc=${facet}_svc
3646 if [ -n ${!varsvc} ]; then
3649 error "No lablel for $facet!"
3653 get_clientosc_proc_path() {
3659 get_lustre_version () {
3660 local facet=${1:-"$SINGLEMDS"}
3661 do_facet $facet $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
3664 get_mds_version_major () {
3665 local facet=${1:-"$SINGLEMDS"}
3666 local version=$(get_lustre_version $facet)
3667 echo $version | awk -F. '{print $1}'
3670 get_mds_version_minor () {
3671 local facet=${1:-"$SINGLEMDS"}
3672 local version=$(get_lustre_version $facet)
3673 echo $version | awk -F. '{print $2}'
3676 # If the 2.0 MDS was mounted on 1.8 device, then the OSC and LOV names
3677 # used by MDT would not be changed.
3678 # mdt lov: fsname-mdtlov
3679 # mdt osc: fsname-OSTXXXX-osc
3680 mds_on_old_device() {
3681 local mds=${1:-"$SINGLEMDS"}
3682 local major=$(get_mds_version_major $mds)
3683 local minor=$(get_mds_version_minor $mds)
3685 if [ $major -ge 2 ] || [ $major -eq 1 -a $minor -gt 8 ]; then
3686 do_facet $mds "lctl list_param osc.$FSNAME-OST*-osc \
3687 > /dev/null 2>&1" && return 0
3692 get_mdtosc_proc_path() {
3694 local ost_label=${2:-"*OST*"}
3696 [ "$mds_facet" = "mds" ] && mds_facet=$SINGLEMDS
3697 local mdt_label=$(convert_facet2label $mds_facet)
3698 local mdt_index=$(echo $mdt_label | sed -e 's/^.*-//')
3700 local major=$(get_mds_version_major $mds_facet)
3701 local minor=$(get_mds_version_minor $mds_facet)
3702 if [ $major -le 1 -a $minor -le 8 ] || mds_on_old_device $mds_facet; then
3703 echo "${ost_label}-osc"
3705 echo "${ost_label}-osc-${mdt_index}"
3709 get_osc_import_name() {
3712 local label=$(convert_facet2label $ost)
3714 if [ "${facet:0:3}" = "mds" ]; then
3715 get_mdtosc_proc_path $facet $label
3719 get_clientosc_proc_path $label
3723 _wait_import_state () {
3726 local maxtime=${3:-max_recovery_time}
3730 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3731 while [ "${CONN_STATE}" != "${expected}" ]; do
3732 [ $i -ge $maxtime ] && \
3733 error "can't put import for $CONN_PROC into ${expected} state after $i sec, have ${CONN_STATE}" && \
3736 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3740 log "$CONN_PROC in ${CONN_STATE} state after $i sec"
3744 wait_import_state() {
3747 local maxtime=${3:-max_recovery_time}
3750 for param in ${params//,/ }; do
3751 _wait_import_state $state $param $maxtime || return
3754 wait_osc_import_state() {
3758 local ost=$(get_osc_import_name $facet $ost_facet)
3763 CONN_PROC="osc.${ost}.ost_server_uuid"
3764 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3765 while [ "${CONN_STATE}" != "${expected}" ]; do
3766 if [ "${expected}" == "DISCONN" ]; then
3767 # for disconn we can check after proc entry is removed
3768 [ "x${CONN_STATE}" == "x" ] && return 0
3769 # with AT we can have connect request timeout ~ reconnect timeout
3770 # and test can't see real disconnect
3771 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
3773 # disconnect rpc should be wait not more obd_timeout
3774 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
3775 error "can't put import for ${ost}(${ost_facet}) into ${expected} state" && return 1
3777 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3781 log "${ost_facet} now in ${CONN_STATE} state"
3784 get_clientmdc_proc_path() {
3792 # Add paths to lustre tests for 32 and 64 bit systems.
3793 local RPATH="PATH=$RLUSTRE/tests:/usr/lib/lustre/tests:/usr/lib64/lustre/tests:$PATH"
3794 do_nodesv $list "${RPATH} NAME=${NAME} sh rpc.sh $@ "
3797 wait_clients_import_state () {
3804 if [ "$FAILURE_MODE" = HARD ]; then
3805 facets=$(facets_on_host $(facet_active_host $facet))
3808 for facet in ${facets//,/ }; do
3809 local label=$(convert_facet2label $facet)
3812 ost* ) proc_path="osc.$(get_clientosc_proc_path $label).ost_server_uuid" ;;
3813 mds* ) proc_path="mdc.$(get_clientmdc_proc_path $label).mds_server_uuid" ;;
3814 *) error "unknown facet!" ;;
3816 local params=$(expand_list $params $proc_path)
3819 if ! do_rpc_nodes $list wait_import_state $expected $params; then
3820 error "import is not in ${expected} state"
3829 AVAILA=($(do_nodes $(comma_list $(osts_nodes)) \
3830 $LCTL get_param obdfilter.*.kbytesavail))
3831 GRANTA=($(do_nodes $(comma_list $(osts_nodes)) \
3832 $LCTL get_param -n obdfilter.*.tot_granted))
3833 for ((i=0; i<${#AVAILA[@]}; i++)); do
3834 local -a AVAIL1=(${AVAILA[$i]//=/ })
3835 GRANT=$((${GRANTA[$i]}/1024))
3836 echo -n $(echo ${AVAIL1[0]} | cut -d"." -f2) avl=${AVAIL1[1]} grnt=$GRANT diff=$((AVAIL1[1] - GRANT))
3837 [ $((AVAIL1[1] - GRANT)) -lt 400 ] && OSCFULL=0 && echo " FULL" || echo
3843 do_facet mgs lctl pool_list $1
3847 local fsname=${1%%.*}
3848 local poolname=${1##$fsname.}
3850 do_facet mgs lctl pool_new $1
3852 # get param should return err unless pool is created
3853 [[ $RC -ne 0 ]] && return $RC
3855 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
3856 2>/dev/null || echo foo" "" || RC=1
3857 if [[ $RC -eq 0 ]]; then
3860 error "pool_new failed $1"
3865 add_pool_to_list () {
3866 local fsname=${1%%.*}
3867 local poolname=${1##$fsname.}
3869 local listvar=${fsname}_CREATED_POOLS
3870 eval export ${listvar}=$(expand_list ${!listvar} $poolname)
3873 remove_pool_from_list () {
3874 local fsname=${1%%.*}
3875 local poolname=${1##$fsname.}
3877 local listvar=${fsname}_CREATED_POOLS
3878 eval export ${listvar}=$(exclude_items_from_list ${!listvar} $poolname)
3881 destroy_pool_int() {
3883 local OSTS=$(do_facet $SINGLEMDS lctl pool_list $1 | \
3884 awk '$1 !~ /^Pool:/ {print $1}')
3885 for ost in $OSTS; do
3886 do_facet mgs lctl pool_remove $1 $ost
3888 do_facet mgs lctl pool_destroy $1
3891 # <fsname>.<poolname> or <poolname>
3893 local fsname=${1%%.*}
3894 local poolname=${1##$fsname.}
3896 [[ x$fsname = x$poolname ]] && fsname=$FSNAME
3900 pool_list $fsname.$poolname || return $?
3902 destroy_pool_int $fsname.$poolname
3904 [[ $RC -ne 0 ]] && return $RC
3906 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
3907 2>/dev/null || echo foo" "foo" || RC=1
3909 if [[ $RC -eq 0 ]]; then
3910 remove_pool_from_list $fsname.$poolname
3912 error "destroy pool failed $1"
3918 local fsname=${1:-$FSNAME}
3920 local listvar=${fsname}_CREATED_POOLS
3924 [ x${!listvar} = x ] && return 0
3926 echo destroy the created pools: ${!listvar}
3927 for poolname in ${!listvar//,/ }; do
3928 destroy_pool $fsname.$poolname
3933 local fsname=${1:-$FSNAME}
3935 destroy_pools $fsname
3941 local ts=$(date +%s)
3943 [ -f $LOGDIR/shared ] && docp=false
3945 # dump lustre logs, dmesg
3947 prefix="$LOGDIR/${TESTSUITE}.${TESTNAME}"
3949 echo "Dumping lctl log to ${prefix}.*.${suffix}"
3951 if [ "$CLIENTONLY" -o "$PDSH" == "no_dsh" ]; then
3952 echo "Dumping logs only on local client."
3953 $LCTL dk > ${prefix}.debug_log.$(hostname).${suffix}
3954 dmesg > ${prefix}.dmesg.$(hostname).${suffix}
3959 "$LCTL dk > ${prefix}.debug_log.\\\$(hostname).${suffix};
3960 dmesg > ${prefix}.dmesg.\\\$(hostname).${suffix}"
3961 if [ ! -f $LOGDIR/shared ]; then
3962 do_nodes $list rsync -az "${prefix}.*.${suffix}" $HOSTNAME:$LOGDIR
3965 local archive=$LOGDIR/${TESTSUITE}-$ts.tar.bz2
3966 tar -jcf $archive $LOGDIR/*$ts* $LOGDIR/*${TESTSUITE}*
3972 local list=${1:-$(comma_list $(nodes_list))}
3974 [ -n ${TESTSUITE} ] && do_nodes $list "rm -f $TMP/*${TESTSUITE}*" || true
3986 for i in $(seq 0 $num_mntpts); do
3987 cmd="ls -laf ${mntpt_root}$i/$dir"
3993 for pid in $pids; do
4000 # target_start_and_reset_recovery_timer()
4001 # service_time = at_est2timeout(service_time);
4002 # service_time += 2 * (CONNECTION_SWITCH_MAX + CONNECTION_SWITCH_INC +
4003 # INITIAL_CONNECT_TIMEOUT);
4004 # CONNECTION_SWITCH_MAX : min(25U, max(CONNECTION_SWITCH_MIN,obd_timeout))
4005 #define CONNECTION_SWITCH_INC 1
4006 #define INITIAL_CONNECT_TIMEOUT max(CONNECTION_SWITCH_MIN,obd_timeout/20)
4007 #define CONNECTION_SWITCH_MIN 5U
4009 max_recovery_time () {
4010 local init_connect_timeout=$(( TIMEOUT / 20 ))
4011 [[ $init_connect_timeout > 5 ]] || init_connect_timeout=5
4013 local service_time=$(( $(at_max_get client) + $(( 2 * $(( 25 + 1 + init_connect_timeout)) )) ))
4018 get_clients_mount_count () {
4019 local clients=${CLIENTS:-`hostname`}
4021 # we need to take into account the clients mounts and
4022 # exclude mds/ost mounts if any;
4023 do_nodes $clients cat /proc/mounts | grep lustre | grep $MOUNT | wc -l
4027 PROC_CLI="srpc_info"
4035 if [ $M -lt $N ]; then
4039 while [ $N -lt $M ]; do
4049 calc_connection_cnt() {
4052 # MDT->MDT = 2 * C(M, 2)
4056 comb_m2=$(combination $MDSCOUNT 2)
4058 local num_clients=$(get_clients_mount_count)
4060 local cnt_mdt2mdt=$((comb_m2 * 2))
4061 local cnt_mdt2ost=$((MDSCOUNT * OSTCOUNT))
4062 local cnt_cli2ost=$((num_clients * OSTCOUNT))
4063 local cnt_cli2mdt=$((num_clients * MDSCOUNT))
4064 local cnt_all2ost=$((cnt_mdt2ost + cnt_cli2ost))
4065 local cnt_all2mdt=$((cnt_mdt2mdt + cnt_cli2mdt))
4066 local cnt_all2all=$((cnt_mdt2ost + cnt_mdt2mdt + cnt_cli2ost + cnt_cli2mdt))
4080 local cmd="$tgt.srpc.flavor"
4082 if [ $net == "any" ]; then
4087 if [ $dir != "any" ]; then
4092 log "Setting sptlrpc rule: $cmd"
4093 do_facet mgs "$LCTL conf_param $cmd"
4102 rpc_flvr=`echo $flavor | awk -F - '{ print $1 }'`
4103 bulkspec=`echo $flavor | awk -F - '{ print $2 }'`
4105 count=`echo "$output" | grep "rpc flavor" | grep $rpc_flvr | wc -l`
4107 if [ "x$bulkspec" != "x" ]; then
4108 algs=`echo $bulkspec | awk -F : '{ print $2 }'`
4110 if [ "x$algs" != "x" ]; then
4111 bulk_count=`echo "$output" | grep "bulk flavor" | grep $algs | wc -l`
4113 bulk=`echo $bulkspec | awk -F : '{ print $1 }'`
4114 if [ $bulk == "bulkn" ]; then
4115 bulk_count=`echo "$output" | grep "bulk flavor" \
4116 | grep "null/null" | wc -l`
4117 elif [ $bulk == "bulki" ]; then
4118 bulk_count=`echo "$output" | grep "bulk flavor" \
4119 | grep "/null" | grep -v "null/" | wc -l`
4121 bulk_count=`echo "$output" | grep "bulk flavor" \
4122 | grep -v "/null" | grep -v "null/" | wc -l`
4126 [ $bulk_count -lt $count ] && count=$bulk_count
4137 local clients=${CLIENTS:-`hostname`}
4139 for c in ${clients//,/ }; do
4140 output=`do_node $c lctl get_param -n mdc.*-MDT*-mdc-*.$PROC_CLI 2>/dev/null`
4141 tmpcnt=`count_flvr "$output" $flavor`
4142 cnt=$((cnt + tmpcnt))
4152 local clients=${CLIENTS:-`hostname`}
4154 for c in ${clients//,/ }; do
4155 output=`do_node $c lctl get_param -n osc.*OST*-osc-[^M][^D][^T]*.$PROC_CLI 2>/dev/null`
4156 tmpcnt=`count_flvr "$output" $flavor`
4157 cnt=$((cnt + tmpcnt))
4167 if [ $MDSCOUNT -le 1 ]; then
4172 for num in `seq $MDSCOUNT`; do
4173 output=`do_facet mds$num lctl get_param -n mdc.*-MDT*-mdc[0-9]*.$PROC_CLI 2>/dev/null`
4174 tmpcnt=`count_flvr "$output" $flavor`
4175 cnt=$((cnt + tmpcnt))
4186 for num in `seq $MDSCOUNT`; do
4187 mdtosc=$(get_mdtosc_proc_path mds$num)
4188 mdtosc=${mdtosc/-MDT*/-MDT\*}
4189 output=$(do_facet mds$num lctl get_param -n \
4190 osc.$mdtosc.$PROC_CLI 2>/dev/null)
4191 tmpcnt=`count_flvr "$output" $flavor`
4192 cnt=$((cnt + tmpcnt))
4201 output=`do_facet client lctl get_param -n mgc.*.$PROC_CLI 2>/dev/null`
4202 count_flvr "$output" $flavor
4207 local dir=$1 # from to
4208 local flavor=$2 # flavor expected
4211 if [ $dir == "cli2mdt" ]; then
4212 res=`flvr_cnt_cli2mdt $flavor`
4213 elif [ $dir == "cli2ost" ]; then
4214 res=`flvr_cnt_cli2ost $flavor`
4215 elif [ $dir == "mdt2mdt" ]; then
4216 res=`flvr_cnt_mdt2mdt $flavor`
4217 elif [ $dir == "mdt2ost" ]; then
4218 res=`flvr_cnt_mdt2ost $flavor`
4219 elif [ $dir == "all2ost" ]; then
4220 res1=`flvr_cnt_mdt2ost $flavor`
4221 res2=`flvr_cnt_cli2ost $flavor`
4222 res=$((res1 + res2))
4223 elif [ $dir == "all2mdt" ]; then
4224 res1=`flvr_cnt_mdt2mdt $flavor`
4225 res2=`flvr_cnt_cli2mdt $flavor`
4226 res=$((res1 + res2))
4227 elif [ $dir == "all2all" ]; then
4228 res1=`flvr_cnt_mdt2ost $flavor`
4229 res2=`flvr_cnt_cli2ost $flavor`
4230 res3=`flvr_cnt_mdt2mdt $flavor`
4231 res4=`flvr_cnt_cli2mdt $flavor`
4232 res=$((res1 + res2 + res3 + res4))
4240 local dir=$1 # from to
4241 local flavor=$2 # flavor expected
4242 local expect=${3:-$(calc_connection_cnt $dir)} # number expected
4246 for ((i=0;i<20;i++)); do
4247 echo -n "checking $dir..."
4248 res=$(do_check_flavor $dir $flavor)
4249 echo "found $res/$expect $flavor connections"
4250 [ $res -eq $expect ] && return 0
4254 echo "Error checking $flavor of $dir: expect $expect, actual $res"
4258 restore_to_default_flavor()
4260 local proc="mgs.MGS.live.$FSNAME"
4262 echo "restoring to default flavor..."
4264 nrule=`do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor." | wc -l`
4266 # remove all existing rules if any
4267 if [ $nrule -ne 0 ]; then
4268 echo "$nrule existing rules"
4269 for rule in `do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor."`; do
4270 echo "remove rule: $rule"
4271 spec=`echo $rule | awk -F = '{print $1}'`
4272 do_facet mgs "$LCTL conf_param -d $spec"
4276 # verify no rules left
4277 nrule=`do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor." | wc -l`
4278 [ $nrule -ne 0 ] && error "still $nrule rules left"
4280 # wait for default flavor to be applied
4281 # currently default flavor for all connections are 'null'
4282 wait_flavor all2all null
4283 echo "now at default flavor settings"
4288 local flavor=${1:-null}
4290 echo "setting all flavor to $flavor"
4292 # FIXME need parameter to this fn
4293 # and remove global vars
4294 local cnt_all2all=$(calc_connection_cnt all2all)
4296 local res=$(do_check_flavor all2all $flavor)
4297 if [ $res -eq $cnt_all2all ]; then
4298 echo "already have total $res $flavor connections"
4302 echo "found $res $flavor out of total $cnt_all2all connections"
4303 restore_to_default_flavor
4305 [[ $flavor = null ]] && return 0
4307 set_rule $FSNAME any any $flavor
4308 wait_flavor all2all $flavor
4314 # Checking for shared logdir
4315 if [ ! -d $dir ]; then
4316 # Not found. Create local logdir
4319 touch $dir/node.$(hostname).yml
4324 check_write_access() {
4326 for node in $(nodes_list); do
4327 if [ ! -f "$dir/node.${node}.yml" ]; then
4328 # Logdir not accessible/writable from this node.
4336 if [[ -n $YAML_LOG ]]; then
4339 export YAML_LOG=${LOGDIR}/results.yml
4343 do_rpc_nodes $(comma_list $(nodes_list)) check_logdir $LOGDIR
4344 if check_write_access $LOGDIR; then
4345 touch $LOGDIR/shared
4346 echo "Logging to shared log directory: $LOGDIR"
4348 echo "Logging to local directory: $LOGDIR"
4351 yml_nodes_file $LOGDIR
4352 yml_results_file >> $YAML_LOG
4356 yml_log_test $1 >> $YAML_LOG
4360 yml_log_test_status $@ >> $YAML_LOG
4363 log_sub_test_begin() {
4364 yml_log_sub_test_begin $@ >> $YAML_LOG
4367 log_sub_test_end() {
4368 yml_log_sub_test_end $@ >> $YAML_LOG
4374 local devname=$(basename $1)
4375 local size=$(grep "$devname"$ /proc/partitions | awk '{print $3}')
4376 # loop devices aren't in /proc/partitions
4377 [ "x$size" == "x" ] && local size=$(ls -l $dev | awk '{print $5}')
4379 size=$(($size / 1024 / 1024)) # Gb
4381 local partial_arg=""
4382 # Run in partial (fast) mode if the size
4383 # of a partition > 10 GB
4384 [ $size -gt 10 ] && partial_arg="-p"
4386 llverdev --force $partial_arg $dev
4389 remove_mdt_files() {
4394 local mntpt=${MOUNT%/*}/$facet
4396 echo "removing files from $mdtdev on $facet: $files"
4397 mount -t $FSTYPE $MDS_MOUNT_OPTS $mdtdev $mntpt || return $?
4400 rm $mntpt/ROOT/$f || { rc=$?; break; }
4402 umount -f $mntpt || return $?
4406 duplicate_mdt_files() {
4411 local mntpt=${MOUNT%/*}/$facet
4413 echo "duplicating files on $mdtdev on $facet: $files"
4414 mkdir -p $mntpt || return $?
4415 mount -t $FSTYPE $MDS_MOUNT_OPTS $mdtdev $mntpt || return $?
4425 tmp=$(mktemp $TMP/setfattr.XXXXXXXXXX)
4426 pushd $mntpt/ROOT > /dev/null || return $?
4429 touch $f.bad || return $?
4430 getfattr -n trusted.lov $f | sed "s#$f#&.bad#" > $tmp
4432 [ $rc -eq 0 ] || return $rc
4433 setfattr --restore $tmp || return $?
4439 local devs=${1//,/ }
4442 local rslt=$TMP/sgpdd_survey
4444 # sgpdd-survey cleanups ${rslt}.* files
4446 local cmd="rslt=$rslt $params scsidevs=\"$devs\" $SGPDDSURVEY"
4452 # returns the canonical name for an ldiskfs device
4457 do_facet $facet "dv=\\\$(lctl get_param -n $dev);
4458 if foo=\\\$(lvdisplay -c \\\$dv 2>/dev/null); then
4459 echo dm-\\\${foo##*:};
4461 echo \\\$(basename \\\$dv);