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 0
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.
55 echo "new_fs <fstype> {device | file} [size]" 1>&2
63 [ "$1" = "ext3" ] && MKFS="mkfs.ext2 -j"
64 if [ "$1" = "extN" ]; then
70 [ $# -lt 2 -o $# -gt 3 ] && new_fs_usage
73 [ -r "$PM" ] || PM="/etc/mtab"
75 grep "$2 " $PM 1>&2 && echo "$0: $2 is in $PM!" 1>&2 && exit -1
77 $MKFS $MKFSOPT $2 $3 || exit -1
78 LOOPDEV=$2 # Not really a loop device
80 [ $# -ne 3 ] && new_fs_usage
82 if [ -r "$EFILE" ]; then
83 echo "using prepared filesystem $EFILE for $2"
84 zcat "$EFILE" > $2 || exit -1
87 echo "creating new sparse filesystem on $2"
88 dd if=/dev/zero of=$2 bs=1k seek=$3 count=1 1>&2 || exit -1
89 $MKFS $MKFSOPT -F $2 1>&2 || exit -1
91 LOOPDEV=`next_loop_dev`
92 losetup ${LOOPDEV} $2 1>&2 || exit -1
96 # Set up to use an existing filesystem. We take the same parameters as
97 # new_fs, even though we only use the <fstype> and <file> parameters, to
98 # make it easy to convert between new_fs and old_fs in testing scripts.
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 || exit -1
166 elan) [ "$PORT" ] && fail "$0: NETWORK is elan but PORT is set"
167 do_insmod $PORTALS/linux/qswnal/kqswnal.o || exit -1
169 tcp) [ "$PORT" ] || fail "$0: NETWORK is tcp but PORT is not set"
170 do_insmod $PORTALS/linux/socknal/ksocknal.o || exit -1
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 || exit -1
194 do_insmod $LUSTRE/rpc/ptlrpc.o || exit -1
195 do_insmod $LUSTRE/ldlm/ldlm.o || exit -1
196 do_insmod $LUSTRE/extN/extN.o
197 do_insmod $LUSTRE/mds/mds.o || exit -1
198 do_insmod $LUSTRE/mds/mds_ext2.o || exit -1
199 do_insmod $LUSTRE/mds/mds_ext3.o || exit -1
200 do_insmod $LUSTRE/mds/mds_extN.o
201 do_insmod $LUSTRE/obdecho/obdecho.o || exit -1
202 do_insmod $LUSTRE/ext2obd/obdext2.o || exit -1
203 do_insmod $LUSTRE/filterobd/obdfilter.o || exit -1
204 do_insmod $LUSTRE/ost/ost.o || exit -1
205 do_insmod $LUSTRE/osc/osc.o || exit -1
206 do_insmod $LUSTRE/mdc/mdc.o || exit -1
207 do_insmod $LUSTRE/llight/llite.o || exit -1
211 if $OBDCTL name2dev RPCDEV > /dev/null 2>&1; then
212 echo "$0: RPCDEV is already configured, skipping"
216 $OBDCTL <<- EOF || return $rc
223 [ -d /mnt/lustre ] || mkdir /mnt/lustre
227 [ "$SETUP_LDLM" = "y" ] || return 0
229 [ -c /dev/portals ] || mknod /dev/portals c 10 240
231 $OBDCTL <<- EOF || return $rc
242 echo "usage: $0 <devname>" 1>&2
250 [ "$SETUP_MDS" = "y" ] || return 0
252 if [ -z "$MDSFS" -o -z "$MDSDEV" ]; then
253 echo "error: setup_mds: MDSFS or MDSDEV unset" 1>&2
258 if [ "$DO_FS" != "new_fs" -a "$DO_FS" != "old_fs" ]; then
259 echo "usage: setup_mds {new_fs|old_fs}" 1>&2
263 if $OBDCTL name2dev MDSDEV > /dev/null 2>&1; then
264 echo "$0: MDSDEV is already configured"
268 $DO_FS ${MDSFS} ${MDSDEV} ${MDSSIZE}
271 $OBDCTL <<- EOF || return $rc
274 setup ${MDS} ${MDSFS}
280 [ "$SETUP_OST" = "y" ] || return 0
282 if [ -z "$OSTTYPE" ]; then
283 echo "error: setup_ost: OSTTYPE unset" 1>&2
295 obdfilter) OBDARG=$OSTFS
298 *) echo "error: setup_ost: unknown OSTTYPE '$OSTTYPE'" 1>&2
303 if $OBDCTL name2dev OBDDEV > /dev/null 2>&1; then
304 echo "$0: OBDDEV is already configured"
308 if [ "$NEED_FS" = "y" ]; then
310 if [ -z "$OSTFS" -o -z "$OSTDEV" ]; then
311 echo "error: setup_ost: OSTFS or OSTDEV unset" 1>&2
315 if [ "$DO_FS" != "new_fs" -a "$DO_FS" != "old_fs" ]; then
316 echo "usage: setup_ost {new_fs|old_fs}" 1>&2
320 $DO_FS ${OSTFS} ${OSTDEV} ${OSTSIZE}
324 $OBDCTL <<- EOF || return $rc
326 attach ${OSTTYPE} OBDDEV
327 setup ${OBD} ${OBDARG}
336 setup_mds $1 && setup_ost $1
340 [ "$SETUP_OSC" != "y" ] && return 0
342 if $OBDCTL name2dev OSCDEV > /dev/null 2>&1; then
343 echo "$0: OSCDEV is already configured"
347 $OBDCTL <<- EOF || return $rc
356 [ "$SETUP_MOUNT" != "y" ] && return 0
358 [ "$OSCMT" ] || fail "error: $0: OSCMT unset"
360 if mount | grep -q $OSCMT; then
361 echo "$0: $OSCMT is already mounted"
365 [ ! -d $OSCMT ] && mkdir $OSCMT
366 mount -t lustre_lite -o device=`find_devno OSCDEV` none $OSCMT
370 setup_osc && setup_mount
373 DEBUG_ON="echo 0xffffffff > /proc/sys/portals/debug"
374 DEBUG_OFF="echo 0 > /proc/sys/portals/debug"
377 [ "$MDS_RSH" ] && echo "Turn OFF debug on MDS" && $MDS_RSH "$DEBUG_OFF"
378 [ "$OST_RSH" ] && echo "Turn OFF debug on OST" && $OST_RSH "$DEBUG_OFF"
382 [ "$MDS_RSH" ] && echo "Turn ON debug on MDS" && $MDS_RSH "$DEBUG_ON"
383 [ "$OST_RSH" ] && echo "Turn ON debug on OST" && $OST_RSH "$DEBUG_ON"
387 echo "Turning OFF debug on client" && $OSC_RSH "$DEBUG_OFF"
391 echo "Turning ON debug on client" && $OSC_RSH "$DEBUG_ON"
437 [ "$SETUP" -a -z "$SETUP_LDLM" ] && return 0
439 LDLMDEVNO=`find_devno LDLMDEV`
440 if [ "$LDLMDEVNO" ]; then
451 [ "$SETUP" -a -z "$SETUP_MDS" ] && return 0
453 MDSDEVNO=`find_devno MDSDEV`
454 if [ "$MDSDEVNO" ]; then
465 [ "$SETUP" -a -z "$SETUP_OST" ] && return 0
467 OSTDEVNO=`find_devno OSTDEV`
468 if [ "$OSTDEVNO" ]; then
477 OBDDEVNO=`find_devno OBDDEV`
478 if [ "$OBDDEVNO" ]; then
489 cleanup_ost && cleanup_mds
493 [ "$SETUP" -a -z "$SETUP_MOUNT" ] && return 0
495 [ "$OSCMT" ] || OSCMT=/mnt/lustre
496 if [ "`mount | grep $OSCMT`" ]; then
497 umount $OSCMT || fail "unable to unmount $OSCMT"
502 [ "$SETUP" -a -z "$SETUP_OSC" ] && return 0
504 OSCDEVNO=`find_devno OSCDEV`
505 if [ "$OSCDEVNO" ]; then
516 RPCDEVNO=`find_devno RPCDEV`
517 if [ "$RPCDEVNO" ]; then
528 cleanup_mount && cleanup_osc && cleanup_rpc
532 echo "ERROR: $1" 1>&2
533 [ $2 ] && RC=$2 || RC=1