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 if [ "$LOCALHOST" == "$SERVER" ]; then
129 [ -c /dev/portals ] || mknod /dev/portals c 10 240
131 insmod $PORTALS/linux/oslib/portals.o || exit -1
134 elan) if [ "$PORT" ]; then
135 echo "$0: NETWORK is elan but PORT is set" 1>&2
138 insmod $PORTALS/linux/qswnal/kqswnal.o
140 tcp) if [ -z "$PORT" ]; then
141 echo "$0: NETWORK is tcp but PORT is not set" 1>&2
144 insmod $PORTALS/linux/socknal/ksocknal.o || exit -1
147 *) echo "$0: unknown NETWORK '$NETWORK'" 1>&2
155 connect $SERVER $PORT
166 [ -c /dev/obd ] || mknod /dev/obd c 10 241
168 insmod $LUSTRE/class/obdclass.o || exit -1
169 insmod $LUSTRE/rpc/ptlrpc.o || exit -1
170 insmod $LUSTRE/ldlm/ldlm.o || exit -1
171 insmod $LUSTRE/ext2obd/obdext2.o || exit -1
172 insmod $LUSTRE/filterobd/obdfilter.o || exit -1
173 insmod $LUSTRE/ost/ost.o || exit -1
174 insmod $LUSTRE/osc/osc.o || exit -1
175 insmod $LUSTRE/obdecho/obdecho.o || exit -1
176 insmod $LUSTRE/mds/mds.o || exit -1
177 insmod $LUSTRE/mdc/mdc.o || exit -1
178 insmod $LUSTRE/llight/llite.o || exit -1
182 [ -d /mnt/lustre ] || mkdir /mnt/lustre
186 [ -c /dev/portals ] || mknod /dev/portals c 10 240
188 insmod $PORTALS/linux/oslib/portals.o || exit -1
190 insmod $LUSTRE/class/obdclass.o || exit -1
191 insmod $LUSTRE/ldlm/ldlm.o || exit -1
194 echo "Press Enter to continue"
198 DEVNO=0; export DEVNO
201 [ "$SETUP_MDS" = "y" ] || return 0
203 if [ -z "$MDSFS" -o -z "$MDSDEV" ]; then
204 echo "error: setup_mds: MDSFS or MDSDEV unset" 1>&2
208 if [ "$1" != "new_fs" -a "$1" != "old_fs" ]; then
209 echo "usage: setup_mds {new_fs|old_fs}" 1>&2
213 $1 ${MDSFS} ${MDSDEV} ${MDSSIZE}
216 MDS_DEVNO=$DEVNO; DEVNO=`expr $DEVNO + 1`
221 setup ${MDS} ${MDSFS}
227 [ "$SETUP_OST" = "y" ] || return 0
229 if [ -z "$OSTTYPE" ]; then
230 echo "error: setup_ost: OSTTYPE unset" 1>&2
242 obdfilter) OBDARG=$OSTFS
245 *) echo "error: setup_ost: unknown OSTTYPE '$OSTTYPE'" 1>&2
250 if [ "$NEED_FS" = "y" ]; then
252 if [ -z "$OSTFS" -o -z "$OSTDEV" ]; then
253 echo "error: setup_ost: OSTFS or OSTDEV unset" 1>&2
257 if [ "$DO_FS" != "new_fs" -a "$DO_FS" != "old_fs" ]; then
258 echo "usage: setup_ost {new_fs|old_fs}" 1>&2
262 $DO_FS ${OSTFS} ${OSTDEV} ${OSTSIZE}
266 OBD_DEVNO=$DEVNO; DEVNO=`expr $DEVNO + 1`
267 OST_DEVNO=$DEVNO; DEVNO=`expr $DEVNO + 1`
271 attach ${OSTTYPE} OSTDEV
272 setup ${OBD} ${OBDARG}
281 setup_mds $1 && setup_ost $1
285 [ "$SETUP_OSC" != "y" ] && return 0
287 OSC_DEVNO=$DEVNO; DEVNO=`expr $DEVNO + 1`
288 $OBDCTL <<- EOF || return $rc
297 [ "$SETUP_MOUNT" != "y" ] && return 0
299 if [ -z "$OSCMT" ]; then
300 echo "error: setup_mount: OSCMT unset" 1>&2
304 [ ! -d $OSCMT ] && mkdir $OSCMT
305 mount -t lustre_lite -o device=$OSC_DEVNO none $OSCMT
309 setup_osc && setup_mount
312 DEBUG_ON="echo 0xffffffff > /proc/sys/portals/debug"
313 DEBUG_OFF="echo 0 > /proc/sys/portals/debug"
316 if [ "$SERVER" != "$LOCALHOST" ]; then
317 $RSH $SERVER "$DEBUG_OFF"
324 if [ "$SERVER" != "$LOCALHOST" ]; then
325 $RSH $SERVER "$DEBUG_ON"
395 [ "$SETUP" -a -z "$SETUP_MDS" ] && return 0
397 [ "$SETUP" ] || MDS_DEVNO=0
408 [ "$SETUP" -a -z "$SETUP_OST" ] && return 0
410 if [ -z "$SETUP" ]; then
427 cleanup_mds && cleanup_ost
432 [ "$SETUP" -a -z "$SETUP_MOUNT" ] && return 0
434 [ "$OSCMT" ] || OSCMT=/mnt/lustre
439 [ "$SETUP" -a -z "$SETUP_OSC" ] && return 0
441 [ "$SETUP" ] || OSC_DEVNO=3
452 cleanup_mount && cleanup_osc