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
24 # Return the next unused loop device on stdout and in the $LOOPDEV
25 # environment variable.
28 while [ -b ${LOOP}${LOOPNUM} ]; do
29 LOOPDEV=${LOOP}${LOOPNUM}
30 losetup ${LOOPDEV} > /dev/null 2>&1 || NEXT=${LOOPDEV}
31 LOOPNUM=`expr ${LOOPNUM} + 1`
32 [ "$NEXT" ] && echo ${NEXT} && break
36 # Create a new filesystem. If we are using a loopback device, we check
37 # for existing "template" filesystems instead of creating a new one,
38 # because it is _much_ faster to gunzip the empty filesystem instead of
39 # creating a new one from scratch. Conversely, if we are creating a
40 # filesystem on a device we use mkfs, because that only writes sparsely
41 # to the device. The empty filesystems are also highly compressed (1000:1)
42 # so they don't take too much space.
48 [ "$1" = "ext3" ] && MKFS="mkfs.ext2 -j"
51 [ $# -lt 2 -o $# -gt 3 ] && \
52 echo "usage: $0 <fstype> <file> [size]" 1>&2 && exit -1
55 [ -r "$PM" ] || PM="/etc/mtab"
57 grep "$2 " $PM 1>&2 && echo "$0: $2 is in $PM!" 1>&2 && exit -1
59 $MKFS $MKFSOPT $2 $3 || exit -1
60 LOOPDEV=$2 # Not really a loop device
63 echo "usage: $0 <fstype> <file> <size>" 1>&2 && exit -1
65 if [ -r "$EFILE" ]; then
66 echo "using prepared filesystem $EFILE for $2"
67 zcat "$EFILE" > $2 || exit -1
70 echo "creating new sparse filesystem on $2"
71 dd if=/dev/zero of=$2 bs=1k seek=$3 count=1 1>&2 || exit -1
72 $MKFS $MKFSOPT -F $2 1>&2 || exit -1
74 LOOPDEV=`next_loop_dev`
75 losetup ${LOOPDEV} $2 1>&2 || exit -1
79 # Set up to use an existing filesystem. We take the same parameters as
80 # new_fs, even though we only use the <file> parameter, to make it easy
81 # to convert between new_fs and old_fs in testing scripts.
86 LOOPDEV=$2 # Not really a loop device
88 LOOPDEV=`next_loop_dev`
89 losetup ${LOOPDEV} $2 1>&2 || exit -1
94 $DBGCTL modules > $R/tmp/ogdb
95 echo "The GDB module script is in /tmp/ogdb"
96 [ "$DEBUG_WAIT" = "yes" ] && echo -n "Press ENTER to continue" && read
99 # We need at least one setup file to be given. It can be passed on
100 # the command-line, or it can be found in the home directory, or it
101 # can even be sourced into the current shell environment.
103 DEF=$HOME/.lustretestrc
104 [ -r $DEF ] && . $DEF && SETUP=y
108 *.cfg) [ -r "$CFG" ] && . $CFG && SETUP=y ;;
109 *) echo "unknown option '$CFG'" 1>&2
113 if [ "$SETUP" != "y" ]; then
114 echo "error: no config file on command-line and no $DEF" 1>&2
118 [ -z "$MDS_RSH" ] && MDS_RSH="eval"
119 [ -z "$OST_RSH" ] && OST_RSH="eval"
120 [ -z "$OSC_RSH" ] && OSC_RSH="eval"
126 [ "$MODULE" ] || fail "usage: $0 <module>"
127 [ -f $MODULE ] || fail "$0: module '$MODULE' not found"
129 lsmod | grep -q `basename $MODULE` || insmod $MODULE || exit -1
133 if [ -z "$NETWORK" -o -z "$LOCALHOST" -o -z "$SERVER" ]; then
134 echo "$0: NETWORK or LOCALHOST or SERVER is not set" 1>&2
138 if [ "$LOCALHOST" == "$SERVER" ]; then
144 [ -c /dev/portals ] || mknod /dev/portals c 10 240
146 insmod $PORTALS/linux/oslib/portals.o || exit -1
149 elan) [ "$PORT" ] && fail "$0: NETWORK is elan but PORT is set"
150 insmod $PORTALS/linux/qswnal/kqswnal.o
152 tcp) [ "$PORT" ] || fail "$0: NETWORK is tcp but PORT is not set"
153 insmod $PORTALS/linux/socknal/ksocknal.o || exit -1
156 *) fail "$0: unknown NETWORK '$NETWORK'" ;;
162 connect $SERVER $PORT
173 [ -c /dev/obd ] || mknod /dev/obd c 10 241
175 do_insmod class/obdclass.o
176 do_insmod rpc/ptlrpc.o
177 do_insmod ldlm/ldlm.o
179 do_insmod obdecho/obdecho.o
180 do_insmod ext2obd/obdext2.o
181 do_insmod filterobd/obdfilter.o
185 do_insmod llight/llite.o
189 $OBDCTL <<- EOF || return $rc
196 [ -d /mnt/lustre ] || mkdir /mnt/lustre
200 [ -c /dev/portals ] || mknod /dev/portals c 10 240
202 insmod $PORTALS/linux/oslib/portals.o || exit -1
204 do_insmod class/obdclass.o
205 do_insmod rpc/ptlrpc.o
206 do_insmod ldlm/ldlm.o
214 echo "usage: $0 <devname>" 1>&2
222 [ "$SETUP_MDS" = "y" ] || return 0
224 if [ -z "$MDSFS" -o -z "$MDSDEV" ]; then
225 echo "error: setup_mds: MDSFS or MDSDEV unset" 1>&2
230 if [ "$DO_FS" != "new_fs" -a "$DO_FS" != "old_fs" ]; then
231 echo "usage: setup_mds {new_fs|old_fs}" 1>&2
235 $DO_FS ${MDSFS} ${MDSDEV} ${MDSSIZE}
241 setup ${MDS} ${MDSFS}
247 [ "$SETUP_OST" = "y" ] || return 0
249 if [ -z "$OSTTYPE" ]; then
250 echo "error: setup_ost: OSTTYPE unset" 1>&2
262 obdfilter) OBDARG=$OSTFS
265 *) echo "error: setup_ost: unknown OSTTYPE '$OSTTYPE'" 1>&2
270 if [ "$NEED_FS" = "y" ]; then
272 if [ -z "$OSTFS" -o -z "$OSTDEV" ]; then
273 echo "error: setup_ost: OSTFS or OSTDEV unset" 1>&2
277 if [ "$DO_FS" != "new_fs" -a "$DO_FS" != "old_fs" ]; then
278 echo "usage: setup_ost {new_fs|old_fs}" 1>&2
282 $DO_FS ${OSTFS} ${OSTDEV} ${OSTSIZE}
288 attach ${OSTTYPE} OBDDEV
289 setup ${OBD} ${OBDARG}
298 setup_mds $1 && setup_ost $1
302 [ "$SETUP_OSC" != "y" ] && return 0
304 $OBDCTL <<- EOF || return $rc
313 [ "$SETUP_MOUNT" != "y" ] && return 0
315 [ "$OSCMT" ] || fail "error: $0: OSCMT unset"
317 [ ! -d $OSCMT ] && mkdir $OSCMT
318 mount -t lustre_lite -o device=`find_devno OSCDEV` none $OSCMT
322 setup_osc && setup_mount
325 DEBUG_ON="echo 0xffffffff > /proc/sys/portals/debug"
326 DEBUG_OFF="echo 0 > /proc/sys/portals/debug"
329 [ "$MDS_RSH" ] && echo "Turn OFF debug on MDS" && $MDS_RSH "$DEBUG_OFF"
330 [ "$OST_RSH" ] && echo "Turn OFF debug on OST" && $OST_RSH "$DEBUG_OFF"
334 [ "$MDS_RSH" ] && echo "Turn ON debug on MDS" && $MDS_RSH "$DEBUG_ON"
335 [ "$OST_RSH" ] && echo "Turn ON debug on OST" && $OST_RSH "$DEBUG_ON"
339 echo "Turning OFF debug on client" && $OSC_RSH "$DEBUG_OFF"
343 echo "Turning ON debug on client" && $OSC_RSH "$DEBUG_ON"
385 [ "$SETUP" -a -z "$SETUP_MDS" ] && return 0
387 MDSDEVNO=`find_devno MDSDEV`
388 if [ "$MDSDEVNO" ]; then
399 [ "$SETUP" -a -z "$SETUP_OST" ] && return 0
401 OSTDEVNO=`find_devno OSTDEV`
402 if [ "$OSTDEVNO" ]; then
411 OBDDEVNO=`find_devno OBDDEV`
412 if [ "$OBDDEVNO" ]; then
423 cleanup_ost && cleanup_mds
427 [ "$SETUP" -a -z "$SETUP_MOUNT" ] && return 0
429 [ "$OSCMT" ] || OSCMT=/mnt/lustre
430 if [ "`mount | grep $OSCMT`" ]; then
431 umount $OSCMT || fail "unable to unmount $OSCMT"
436 [ "$SETUP" -a -z "$SETUP_OSC" ] && return 0
438 OSCDEVNO=`find_devno OSCDEV`
439 if [ "$OSCDEVNO" ]; then
450 RPCDEVNO=`find_devno RPCDEV`
451 if [ "$RPCDEVNO" ]; then
462 cleanup_mount && cleanup_osc && cleanup_rpc
466 echo "ERROR: $1" 1>&2
467 [ $2 ] && RC=$2 || RC=1