2 export PATH=$PATH:/sbin:/usr/sbin
6 PORTALS=$SRCDIR../../portals
7 LUSTRE=$SRCDIR../../lustre
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 ] || echo "$0: module '$MODULE' not found" 1>&2
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
95 # Enable hash-indexed directories for extN filesystems
96 [ "$1" = "extN" ] && echo "feature FEATURE_C5" | debugfs -w $2
99 # Set up to use an existing filesystem. We take the same parameters as
100 # new_fs, even though we only use the <fstype> and <file> parameters, to
101 # make it easy to convert between new_fs and old_fs in testing scripts.
106 LOOPDEV=$2 # Not really a loop device
108 LOOPDEV=`next_loop_dev`
109 losetup ${LOOPDEV} $2 1>&2 || exit -1
114 $DBGCTL modules > $R/tmp/ogdb
115 echo "The GDB module script is in $R/tmp/ogdb"
116 [ "$DEBUG_WAIT" = "yes" ] && echo -n "Press ENTER to continue" && read
119 # We need at least one setup file to be given. It can be passed on
120 # the command-line, or it can be found in the home directory, or it
121 # can even be sourced into the current shell environment.
123 DEF=$HOME/.lustretestrc
124 [ -r $DEF ] && . $DEF && SETUP=y
128 *.cfg) [ -r "$CFG" ] && . $CFG && SETUP=y ;;
129 *) echo "unknown option '$CFG'" 1>&2
133 if [ "$SETUP" != "y" ]; then
134 echo "error: no config file on command-line and no $DEF" 1>&2
138 [ -z "$MDS_RSH" ] && MDS_RSH="eval"
139 [ -z "$OST_RSH" ] && OST_RSH="eval"
140 [ -z "$OSC_RSH" ] && OSC_RSH="eval"
144 if grep -q portals /proc/modules; then
145 echo "$0: portals already appears to be set up, skipping"
149 if [ -z "$NETWORK" -o -z "$LOCALHOST" -o -z "$SERVER" ]; then
150 echo "$0: NETWORK or LOCALHOST or SERVER is not set" 1>&2
154 [ -z "$OSTNODE" ] && OSTNODE=$SERVER
156 if [ -z "$DLM" ]; then
157 if [ "$LOCALHOST" == "$SERVER" ]; then
164 [ -c /dev/portals ] || mknod /dev/portals c 10 240
166 do_insmod $PORTALS/linux/oslib/portals.o || exit -1
169 elan) [ "$PORT" ] && fail "$0: NETWORK is elan but PORT is set"
170 do_insmod $PORTALS/linux/qswnal/kqswnal.o || exit -1
172 tcp) [ "$PORT" ] || fail "$0: NETWORK is tcp but PORT is not set"
173 do_insmod $PORTALS/linux/socknal/ksocknal.o || exit -1
176 *) fail "$0: unknown NETWORK '$NETWORK'" ;;
182 connect $SERVER $PORT
185 connect $OSTNODE $PORT
194 [ -c /dev/obd ] || mknod /dev/obd c 10 241
196 do_insmod $LUSTRE/obdclass/obdclass.o || exit -1
197 do_insmod $LUSTRE/ptlrpc/ptlrpc.o || exit -1
198 do_insmod $LUSTRE/ldlm/ldlm.o || exit -1
199 do_insmod $LUSTRE/extN/extN.o || \
200 echo "info: can't load extN.o module, not fatal if using ext3"
201 do_insmod $LUSTRE/mds/mds.o || exit -1
202 #do_insmod $LUSTRE/mds/mds_ext2.o || exit -1
203 #do_insmod $LUSTRE/mds/mds_ext3.o || exit -1
204 do_insmod $LUSTRE/mds/mds_extN.o || \
205 echo "info: can't load mds_extN.o module, needs extN.o"
206 do_insmod $LUSTRE/obdecho/obdecho.o || exit -1
207 do_insmod $LUSTRE/obdext2/obdext2.o || exit -1
208 do_insmod $LUSTRE/obdfilter/obdfilter.o || exit -1
209 do_insmod $LUSTRE/ost/ost.o || exit -1
210 do_insmod $LUSTRE/osc/osc.o || exit -1
211 do_insmod $LUSTRE/mdc/mdc.o || exit -1
212 do_insmod $LUSTRE/llite/llite.o || exit -1
216 if $OBDCTL name2dev RPCDEV > /dev/null 2>&1; then
217 echo "$0: RPCDEV is already configured, skipping"
221 $OBDCTL <<- EOF || return $?
228 [ -d /mnt/lustre ] || mkdir /mnt/lustre
232 [ "$SETUP_LDLM" = "y" ] || return 0
234 [ -c /dev/portals ] || mknod /dev/portals c 10 240
236 $OBDCTL <<- EOF || return $?
247 echo "usage: $0 <devname>" 1>&2
255 [ "$SETUP_MDS" = "y" ] || return 0
257 if [ -z "$MDSFS" -o -z "$MDSDEV" ]; then
258 echo "error: setup_mds: MDSFS or MDSDEV unset" 1>&2
263 if [ "$DO_FS" != "new_fs" -a "$DO_FS" != "old_fs" ]; then
264 echo "usage: setup_mds {new_fs|old_fs}" 1>&2
268 if $OBDCTL name2dev MDSDEV > /dev/null 2>&1; then
269 echo "$0: MDSDEV is already configured"
273 $DO_FS ${MDSFS} ${MDSDEV} ${MDSSIZE}
276 $OBDCTL <<- EOF || return $?
279 setup ${MDS} ${MDSFS}
285 [ "$SETUP_OST" = "y" ] || return 0
287 if [ -z "$OSTTYPE" ]; then
288 echo "error: setup_ost: OSTTYPE unset" 1>&2
300 obdfilter) OBDARG=$OSTFS
303 *) echo "error: setup_ost: unknown OSTTYPE '$OSTTYPE'" 1>&2
308 if $OBDCTL name2dev OBDDEV > /dev/null 2>&1; then
309 echo "$0: OBDDEV is already configured"
313 if [ "$NEED_FS" = "y" ]; then
315 if [ -z "$OSTFS" -o -z "$OSTDEV" ]; then
316 echo "error: setup_ost: OSTFS or OSTDEV unset" 1>&2
320 if [ "$DO_FS" != "new_fs" -a "$DO_FS" != "old_fs" ]; then
321 echo "usage: setup_ost {new_fs|old_fs}" 1>&2
325 $DO_FS ${OSTFS} ${OSTDEV} ${OSTSIZE}
329 $OBDCTL <<- EOF || return $?
331 attach ${OSTTYPE} OBDDEV
332 setup ${OBD} ${OBDARG}
335 $OBDCTL <<- EOF || return $?
344 setup_mds $1 && setup_ost $1
348 [ "$SETUP_OSC" != "y" ] && return 0
350 if $OBDCTL name2dev OSCDEV > /dev/null 2>&1; then
351 echo "$0: OSCDEV is already configured"
355 $OBDCTL <<- EOF || return $?
364 [ "$SETUP_MOUNT" != "y" ] && return 0
366 [ "$OSCMT" ] || fail "error: $0: OSCMT unset"
368 if mount | grep -q $OSCMT; then
369 echo "$0: $OSCMT is already mounted"
373 [ ! -d $OSCMT ] && mkdir $OSCMT
374 echo "$0: mounting \$OSCDEV on $OSCMT"
375 mount -t lustre_lite -o device=`find_devno OSCDEV` none $OSCMT
379 setup_osc && setup_mount
382 DEBUG_ON="echo 0xffffffff > /proc/sys/portals/debug"
383 DEBUG_OFF="echo 0 > /proc/sys/portals/debug"
386 [ "$MDS_RSH" ] && echo "Turn OFF debug on MDS" && $MDS_RSH "$DEBUG_OFF"
387 [ "$OST_RSH" ] && echo "Turn OFF debug on OST" && $OST_RSH "$DEBUG_OFF"
391 [ "$MDS_RSH" ] && echo "Turn ON debug on MDS" && $MDS_RSH "$DEBUG_ON"
392 [ "$OST_RSH" ] && echo "Turn ON debug on OST" && $OST_RSH "$DEBUG_ON"
396 echo "Turning OFF debug on client" && $OSC_RSH "$DEBUG_OFF"
400 echo "Turning ON debug on client" && $OSC_RSH "$DEBUG_ON"
404 [ -z "$NETWORK" ] && NETWORK=tcp
447 [ "$SETUP" -a -z "$SETUP_LDLM" ] && return 0
449 LDLMDEVNO=`find_devno LDLMDEV`
450 if [ "$LDLMDEVNO" ]; then
461 [ "$SETUP" -a -z "$SETUP_MDS" ] && return 0
463 MDSDEVNO=`find_devno MDSDEV`
464 if [ "$MDSDEVNO" ]; then
475 [ "$SETUP" -a -z "$SETUP_OST" ] && return 0
477 OSTDEVNO=`find_devno OSTDEV`
478 if [ "$OSTDEVNO" ]; then
487 OBDDEVNO=`find_devno OBDDEV`
488 if [ "$OBDDEVNO" ]; then
499 cleanup_ost && cleanup_mds
503 [ "$SETUP" -a -z "$SETUP_MOUNT" ] && return 0
505 [ "$OSCMT" ] || OSCMT=/mnt/lustre
506 if [ "`mount | grep $OSCMT`" ]; then
507 umount $OSCMT || fail "unable to unmount $OSCMT"
512 [ "$SETUP" -a -z "$SETUP_OSC" ] && return 0
514 OSCDEVNO=`find_devno OSCDEV`
515 if [ "$OSCDEVNO" ]; then
526 RPCDEVNO=`find_devno RPCDEV`
527 if [ "$RPCDEVNO" ]; then
538 cleanup_mount && cleanup_osc && cleanup_rpc
542 echo "ERROR: $1" 1>&2
543 [ $2 ] && RC=$2 || RC=1