2 export PATH=$PATH:/sbin:/usr/sbin
6 PORTALS=$SRCDIR../../portals
7 LUSTRE=$SRCDIR../../obd
9 PTLCTL=$PORTALS/linux/utils/ptlctl
10 DBGCTL=$PORTALS/linux/utils/debugctl
11 ACCEPTOR=$PORTALS/linux/utils/acceptor
13 OBDCTL=$LUSTRE/utils/obdctl
15 LOOPNUM=0; export LOOPNUM
16 if [ -b /dev/loop0 ]; then
18 elif [ -b /dev/loop/0 ]; then
21 echo "Cannot find /dev/loop0 or /dev/loop/0" 1>&2 && exit -1
26 BASE=`echo $MODULE | sed -e "s^.*/^^" -e "s/\.o$//"`
28 [ "$MODULE" ] || fail "usage: $0 <module>"
29 [ -f $MODULE ] || fail "$0: module '$MODULE' not found"
30 lsmod | grep -q "\<$BASE\>" && return 1
31 insmod $MODULE || exit -1
34 # Return the next unused loop device on stdout and in the $LOOPDEV
35 # environment variable.
38 while [ -b ${LOOP}${LOOPNUM} ]; do
39 LOOPDEV=${LOOP}${LOOPNUM}
40 losetup ${LOOPDEV} > /dev/null 2>&1 || NEXT=${LOOPDEV}
41 LOOPNUM=`expr ${LOOPNUM} + 1`
42 [ "$NEXT" ] && echo ${NEXT} && break
46 # Create a new filesystem. If we are using a loopback device, we check
47 # for existing "template" filesystems instead of creating a new one,
48 # because it is _much_ faster to gunzip the empty filesystem instead of
49 # creating a new one from scratch. Conversely, if we are creating a
50 # filesystem on a device we use mkfs, because that only writes sparsely
51 # to the device. The empty filesystems are also highly compressed (1000:1)
52 # so they don't take too much space.
58 [ "$1" = "ext3" ] && MKFS="mkfs.ext2 -j"
59 if [ "$1" = "extN" ]; then
62 do_insmod $LUSTRE/extN/extN.o
66 [ $# -lt 2 -o $# -gt 3 ] && \
67 echo "usage: $0 <fstype> <file> [size]" 1>&2 && exit -1
70 [ -r "$PM" ] || PM="/etc/mtab"
72 grep "$2 " $PM 1>&2 && echo "$0: $2 is in $PM!" 1>&2 && exit -1
74 $MKFS $MKFSOPT $2 $3 || exit -1
75 LOOPDEV=$2 # Not really a loop device
78 echo "usage: $0 <fstype> <file> <size>" 1>&2 && exit -1
80 if [ -r "$EFILE" ]; then
81 echo "using prepared filesystem $EFILE for $2"
82 zcat "$EFILE" > $2 || exit -1
85 echo "creating new sparse filesystem on $2"
86 dd if=/dev/zero of=$2 bs=1k seek=$3 count=1 1>&2 || exit -1
87 $MKFS $MKFSOPT -F $2 1>&2 || exit -1
89 LOOPDEV=`next_loop_dev`
90 losetup ${LOOPDEV} $2 1>&2 || exit -1
94 # Set up to use an existing filesystem. We take the same parameters as
95 # new_fs, even though we only use the <fstype> and <file> parameters, to
96 # make it easy to convert between new_fs and old_fs in testing scripts.
100 [ "$1" = "extN" ] && do_insmod $LUSTRE/extN/extN.o
103 LOOPDEV=$2 # Not really a loop device
105 LOOPDEV=`next_loop_dev`
106 losetup ${LOOPDEV} $2 1>&2 || exit -1
111 $DBGCTL modules > $R/tmp/ogdb
112 echo "The GDB module script is in $R/tmp/ogdb"
113 [ "$DEBUG_WAIT" = "yes" ] && echo -n "Press ENTER to continue" && read
116 # We need at least one setup file to be given. It can be passed on
117 # the command-line, or it can be found in the home directory, or it
118 # can even be sourced into the current shell environment.
120 DEF=$HOME/.lustretestrc
121 [ -r $DEF ] && . $DEF && SETUP=y
125 *.cfg) [ -r "$CFG" ] && . $CFG && SETUP=y ;;
126 *) echo "unknown option '$CFG'" 1>&2
130 if [ "$SETUP" != "y" ]; then
131 echo "error: no config file on command-line and no $DEF" 1>&2
135 [ -z "$MDS_RSH" ] && MDS_RSH="eval"
136 [ -z "$OST_RSH" ] && OST_RSH="eval"
137 [ -z "$OSC_RSH" ] && OSC_RSH="eval"
141 if grep -q portals /proc/modules; then
142 echo "$0: portals already appears to be set up, skipping"
146 if [ -z "$NETWORK" -o -z "$LOCALHOST" -o -z "$SERVER" ]; then
147 echo "$0: NETWORK or LOCALHOST or SERVER is not set" 1>&2
151 [ -z "$OSTNODE" ] && OSTNODE=$SERVER
153 if [ -z "$DLM" ]; then
154 if [ "$LOCALHOST" == "$SERVER" ]; then
161 [ -c /dev/portals ] || mknod /dev/portals c 10 240
163 do_insmod $PORTALS/linux/oslib/portals.o
166 elan) [ "$PORT" ] && fail "$0: NETWORK is elan but PORT is set"
167 do_insmod $PORTALS/linux/qswnal/kqswnal.o
169 tcp) [ "$PORT" ] || fail "$0: NETWORK is tcp but PORT is not set"
170 do_insmod $PORTALS/linux/socknal/ksocknal.o
173 *) fail "$0: unknown NETWORK '$NETWORK'" ;;
179 connect $SERVER $PORT
182 connect $OSTNODE $PORT
191 [ -c /dev/obd ] || mknod /dev/obd c 10 241
193 do_insmod $LUSTRE/class/obdclass.o
194 do_insmod $LUSTRE/rpc/ptlrpc.o
195 do_insmod $LUSTRE/ldlm/ldlm.o
196 do_insmod $LUSTRE/extN/extN.o
197 do_insmod $LUSTRE/mds/mds.o
198 do_insmod $LUSTRE/obdecho/obdecho.o
199 do_insmod $LUSTRE/ext2obd/obdext2.o
200 do_insmod $LUSTRE/filterobd/obdfilter.o
201 do_insmod $LUSTRE/ost/ost.o
202 do_insmod $LUSTRE/osc/osc.o
203 do_insmod $LUSTRE/mdc/mdc.o
204 do_insmod $LUSTRE/llight/llite.o
208 if $OBDCTL name2dev RPCDEV > /dev/null 2>&1; then
209 echo "$0: RPCDEV is already configured, skipping"
213 $OBDCTL <<- EOF || return $rc
220 [ -d /mnt/lustre ] || mkdir /mnt/lustre
224 [ "$SETUP_LDLM" = "y" ] || return 0
226 [ -c /dev/portals ] || mknod /dev/portals c 10 240
228 $OBDCTL <<- EOF || return $rc
239 echo "usage: $0 <devname>" 1>&2
247 [ "$SETUP_MDS" = "y" ] || return 0
249 if [ -z "$MDSFS" -o -z "$MDSDEV" ]; then
250 echo "error: setup_mds: MDSFS or MDSDEV unset" 1>&2
255 if [ "$DO_FS" != "new_fs" -a "$DO_FS" != "old_fs" ]; then
256 echo "usage: setup_mds {new_fs|old_fs}" 1>&2
260 if $OBDCTL name2dev MDSDEV > /dev/null 2>&1; then
261 echo "$0: MDSDEV is already configured"
265 $DO_FS ${MDSFS} ${MDSDEV} ${MDSSIZE}
268 $OBDCTL <<- EOF || return $rc
271 setup ${MDS} ${MDSFS}
277 [ "$SETUP_OST" = "y" ] || return 0
279 if [ -z "$OSTTYPE" ]; then
280 echo "error: setup_ost: OSTTYPE unset" 1>&2
292 obdfilter) OBDARG=$OSTFS
295 *) echo "error: setup_ost: unknown OSTTYPE '$OSTTYPE'" 1>&2
300 if $OBDCTL name2dev OBDDEV > /dev/null 2>&1; then
301 echo "$0: OBDDEV is already configured"
305 if [ "$NEED_FS" = "y" ]; then
307 if [ -z "$OSTFS" -o -z "$OSTDEV" ]; then
308 echo "error: setup_ost: OSTFS or OSTDEV unset" 1>&2
312 if [ "$DO_FS" != "new_fs" -a "$DO_FS" != "old_fs" ]; then
313 echo "usage: setup_ost {new_fs|old_fs}" 1>&2
317 $DO_FS ${OSTFS} ${OSTDEV} ${OSTSIZE}
321 $OBDCTL <<- EOF || return $rc
323 attach ${OSTTYPE} OBDDEV
324 setup ${OBD} ${OBDARG}
333 setup_mds $1 && setup_ost $1
337 [ "$SETUP_OSC" != "y" ] && return 0
339 if $OBDCTL name2dev OSCDEV > /dev/null 2>&1; then
340 echo "$0: OSCDEV is already configured"
344 $OBDCTL <<- EOF || return $rc
353 [ "$SETUP_MOUNT" != "y" ] && return 0
355 [ "$OSCMT" ] || fail "error: $0: OSCMT unset"
357 if mount | grep -q $OSCMT; then
358 echo "$0: $OSCMT is already mounted"
362 [ ! -d $OSCMT ] && mkdir $OSCMT
363 mount -t lustre_lite -o device=`find_devno OSCDEV` none $OSCMT
367 setup_osc && setup_mount
370 DEBUG_ON="echo 0xffffffff > /proc/sys/portals/debug"
371 DEBUG_OFF="echo 0 > /proc/sys/portals/debug"
374 [ "$MDS_RSH" ] && echo "Turn OFF debug on MDS" && $MDS_RSH "$DEBUG_OFF"
375 [ "$OST_RSH" ] && echo "Turn OFF debug on OST" && $OST_RSH "$DEBUG_OFF"
379 [ "$MDS_RSH" ] && echo "Turn ON debug on MDS" && $MDS_RSH "$DEBUG_ON"
380 [ "$OST_RSH" ] && echo "Turn ON debug on OST" && $OST_RSH "$DEBUG_ON"
384 echo "Turning OFF debug on client" && $OSC_RSH "$DEBUG_OFF"
388 echo "Turning ON debug on client" && $OSC_RSH "$DEBUG_ON"
431 [ "$SETUP" -a -z "$SETUP_LDLM" ] && return 0
433 LDLMDEVNO=`find_devno LDLMDEV`
434 if [ "$LDLMDEVNO" ]; then
445 [ "$SETUP" -a -z "$SETUP_MDS" ] && return 0
447 MDSDEVNO=`find_devno MDSDEV`
448 if [ "$MDSDEVNO" ]; then
459 [ "$SETUP" -a -z "$SETUP_OST" ] && return 0
461 OSTDEVNO=`find_devno OSTDEV`
462 if [ "$OSTDEVNO" ]; then
471 OBDDEVNO=`find_devno OBDDEV`
472 if [ "$OBDDEVNO" ]; then
483 cleanup_ost && cleanup_mds
487 [ "$SETUP" -a -z "$SETUP_MOUNT" ] && return 0
489 [ "$OSCMT" ] || OSCMT=/mnt/lustre
490 if [ "`mount | grep $OSCMT`" ]; then
491 umount $OSCMT || fail "unable to unmount $OSCMT"
496 [ "$SETUP" -a -z "$SETUP_OSC" ] && return 0
498 OSCDEVNO=`find_devno OSCDEV`
499 if [ "$OSCDEVNO" ]; then
510 RPCDEVNO=`find_devno RPCDEV`
511 if [ "$RPCDEVNO" ]; then
522 cleanup_mount && cleanup_osc && cleanup_rpc
526 echo "ERROR: $1" 1>&2
527 [ $2 ] && RC=$2 || RC=1