2 export PATH=$PATH:/sbin:/usr/sbin
6 PORTALS=$SRCDIR/../../portals
7 LUSTRE=$SRCDIR/../../obd
9 PTLCTL=$PORTALS/linux/utils/ptlctl
10 DEBCTL=$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 existing filesystem $EFILE for $2"
67 zcat "$EFILE" > $2 || exit -1
70 echo "creating new filesystem on $2"
71 dd if=/dev/zero of=$2 bs=1k count=$3 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 $DEBCTL modules > $R/tmp/ogdb
95 echo "The GDB module script is in /tmp/ogdb"
98 # We need at least one setup file to be given. It can be passed on
99 # the command-line, or it can be found in the home directory, or it
100 # can even be sourced into the current shell environment.
102 DEF=$HOME/.lustretestrc
103 [ -r $DEF ] && . $DEF && SETUP=y
107 *.cfg) [ -r "$CFG" ] && . $CFG && SETUP=y ;;
111 if [ "$SETUP" != "y" ]; then
112 echo "error: no config file on command-line and no $DEF" 1>&2
118 if [ -z "$NETWORK" -o -z "$LOCALHOST" -o -z "$SERVER" ]; then
119 echo "$0: NETWORK or LOCALHOST or SERVER is not set" 1>&2
123 [ -c /dev/portals ] || mknod /dev/portals c 10 240
125 insmod $PORTALS/linux/oslib/portals.o || exit -1
128 elan) if [ "$PORT" ]; then
129 echo "$0: NETWORK is elan but PORT is set" 1>&2
132 insmod $PORTALS/linux/qswnal/kqswnal.o
134 tcp) if [ -z "$PORT" ]; then
135 echo "$0: NETWORK is tcp but PORT is not set" 1>&2
138 insmod $PORTALS/linux/socknal/ksocknal.o || exit -1
141 *) echo "$0: unknown NETWORK '$NETWORK'" 1>&2
149 connect $SERVER $PORT
159 [ -c /dev/obd ] || mknod /dev/obd c 10 241
161 insmod $LUSTRE/class/obdclass.o || exit -1
162 insmod $LUSTRE/rpc/ptlrpc.o || exit -1
163 insmod $LUSTRE/ldlm/ldlm.o || exit -1
164 insmod $LUSTRE/ext2obd/obdext2.o || exit -1
165 insmod $LUSTRE/filterobd/obdfilter.o || exit -1
166 insmod $LUSTRE/ost/ost.o || exit -1
167 insmod $LUSTRE/osc/osc.o || exit -1
168 insmod $LUSTRE/obdecho/obdecho.o || exit -1
169 insmod $LUSTRE/mds/mds.o || exit -1
170 insmod $LUSTRE/mdc/mdc.o || exit -1
171 insmod $LUSTRE/llight/llite.o || exit -1
175 [ -d /mnt/lustre ] || mkdir /mnt/lustre
179 [ -c /dev/portals ] || mknod /dev/portals c 10 240
181 insmod $PORTALS/linux/oslib/portals.o || exit -1
183 insmod $LUSTRE/class/obdclass.o || exit -1
184 insmod $LUSTRE/ldlm/ldlm.o || exit -1
187 echo "Press Enter to continue"
191 DEVNO=0; export DEVNO
194 [ "$SETUP_MDS" = "y" ] || return 0
196 if [ -z "$MDSFS" -o -z "$MDSDEV" ]; then
197 echo "error: setup_mds: MDSFS or MDSDEV unset" 1>&2
201 if [ "$1" != "new_fs" -a "$1" != "old_fs" ]; then
202 echo "usage: setup_mds {new_fs|old_fs}" 1>&2
206 $1 ${MDSFS} ${MDSDEV} ${MDSSIZE}
209 MDS_DEVNO=$DEVNO; DEVNO=`expr $DEVNO + 1`
214 setup ${MDS} ${MDSFS}
220 [ "$SETUP_OST" = "y" ] || return 0
222 if [ -z "$OSTTYPE" ]; then
223 echo "error: setup_ost: OSTTYPE unset" 1>&2
235 obdfilter) OBDARG=$OSTFS
238 *) echo "error: setup_ost: unknown OSTTYPE '$OSTTYPE'" 1>&2
243 if [ "$NEED_FS" = "y" ]; then
245 if [ -z "$OSTFS" -o -z "$OSTDEV" ]; then
246 echo "error: setup_ost: OSTFS or OSTDEV unset" 1>&2
250 if [ "$DO_FS" != "new_fs" -a "$DO_FS" != "old_fs" ]; then
251 echo "usage: setup_ost {new_fs|old_fs}" 1>&2
255 $DO_FS ${OSTFS} ${OSTDEV} ${OSTSIZE}
259 OBD_DEVNO=$DEVNO; DEVNO=`expr $DEVNO + 1`
260 OST_DEVNO=$DEVNO; DEVNO=`expr $DEVNO + 1`
265 setup ${OBD} ${OBDARG}
274 setup_mds $1 && setup_ost $1
278 [ "$SETUP_OSC" != "y" ] && return 0
280 OSC_DEVNO=$DEVNO; DEVNO=`expr $DEVNO + 1`
281 $OBDCTL <<- EOF || return $rc
290 [ "$SETUP_MOUNT" != "y" ] && return 0
292 if [ -z "$OSCMT" ]; then
293 echo "error: setup_mount: OSCMT unset" 1>&2
297 [ ! -d $OSCMT ] && mkdir $OSCMT
298 mount -t lustre_lite -o device=$OSC_DEVNO none $OSCMT
302 setup_osc && setup_mount
305 DEBUG_ON="echo 0xffffffff > /proc/sys/portals/debug"
306 DEBUG_OFF="echo 0 > /proc/sys/portals/debug"
309 if [ "$SERVER" != "$LOCALHOST" ]; then
310 $RSH $SERVER "$DEBUG_OFF"
317 if [ "$SERVER" != "$LOCALHOST" ]; then
318 $RSH $SERVER "$DEBUG_ON"
388 [ "$SETUP" -a -z "$SETUP_MDS" ] && return 0
390 [ "$SETUP" ] || MDS_DEVNO=0
401 [ "$SETUP" -a -z "$SETUP_OST" ] && return 0
403 if [ -z "$SETUP" ]; then
420 cleanup_mds && cleanup_ost
425 [ "$SETUP" -a -z "$SETUP_MOUNT" ] && return 0
427 [ "$OSCMT" ] || OSCMT=/mnt/lustre
432 [ "$SETUP" -a -z "$SETUP_OSC" ] && return 0
434 [ "$SETUP" ] || OSC_DEVNO=3
445 cleanup_mount && cleanup_osc