LUSTRE=$SRCDIR/../../obd
PTLCTL=$PORTALS/linux/utils/ptlctl
-DEBCTL=$PORTALS/linux/utils/debugctl
+DBGCTL=$PORTALS/linux/utils/debugctl
ACCEPTOR=$PORTALS/linux/utils/acceptor
OBDCTL=$LUSTRE/utils/obdctl
echo "usage: $0 <fstype> <file> <size>" 1>&2 && exit -1
if [ -r "$EFILE" ]; then
- echo "using existing filesystem $EFILE for $2"
+ echo "using prepared filesystem $EFILE for $2"
zcat "$EFILE" > $2 || exit -1
sync
else
}
list_mods() {
- $DEBCTL modules > $R/tmp/ogdb
+ $DBGCTL modules > $R/tmp/ogdb
echo "The GDB module script is in /tmp/ogdb"
}
read
}
-DEVNO=0; export DEVNO
+find_devno() {
+ if [ -z "$1" ]; then
+ echo "usage: $0 <devname>" 1>&2
+ return -1
+ fi
+
+ $OBDCTL name2dev $1
+}
setup_mds() {
[ "$SETUP_MDS" = "y" ] || return 0
return -1
fi
- $1 ${MDSFS} ${MDSDEV} ${MDSSIZE}
+ $DO_FS ${MDSFS} ${MDSDEV} ${MDSSIZE}
MDS=${LOOPDEV}
- MDS_DEVNO=$DEVNO; DEVNO=`expr $DEVNO + 1`
-
$OBDCTL <<- EOF
- device ${MDS_DEVNO}
+ newdev
attach mds MDSDEV
setup ${MDS} ${MDSFS}
quit
OBD=${LOOPDEV}
fi
- OBD_DEVNO=$DEVNO; DEVNO=`expr $DEVNO + 1`
- OST_DEVNO=$DEVNO; DEVNO=`expr $DEVNO + 1`
-
$OBDCTL <<- EOF
- device ${OBD_DEVNO}
+ newdev
attach ${OSTTYPE} OBDDEV
setup ${OBD} ${OBDARG}
- device ${OST_DEVNO}
+ newdev
attach ost OSTDEV
- setup ${OBD_DEVNO}
+ setup \$OBDDEV
quit
EOF
}
setup_mds $1 && setup_ost $1
}
+setup_rpc() {
+ $OBDCTL <<- EOF || return $rc
+ newdev
+ attach ptlrpc RPCDEV
+ setup
+ quit
+ EOF
+}
+
setup_osc() {
[ "$SETUP_OSC" != "y" ] && return 0
- RPC_DEVNO=$DEVNO; DEVNO=`expr $DEVNO + 1`
- OSC_DEVNO=$DEVNO; DEVNO=`expr $DEVNO + 1`
$OBDCTL <<- EOF || return $rc
- device ${RPC_DEVNO}
- attach ptlrpc RPCDEV
- setup
- device ${OSC_DEVNO}
+ newdev
attach osc OSCDEV
setup -1
quit
fi
[ ! -d $OSCMT ] && mkdir $OSCMT
- mount -t lustre_lite -o device=$OSC_DEVNO none $OSCMT
+ mount -t lustre_lite -o device=`find_devno OSCDEV` none $OSCMT
}
setup_client() {
- setup_osc && setup_mount
+ setup_rpc && setup_osc && setup_mount
}
DEBUG_ON="echo 0xffffffff > /proc/sys/portals/debug"
cleanup_mds() {
[ "$SETUP" -a -z "$SETUP_MDS" ] && return 0
- [ "$SETUP" ] || MDS_DEVNO=0
-
- $OBDCTL <<- EOF
- name2dev MDSDEV
- cleanup
- detach
- quit
- EOF
+ MDSDEVNO=`find_devno MDSDEV`
+ if [ "$MDSDEVNO" ]; then
+ $OBDCTL <<- EOF
+ device $MDSDEVNO
+ cleanup
+ detach
+ quit
+ EOF
+ fi
}
cleanup_ost() {
[ "$SETUP" -a -z "$SETUP_OST" ] && return 0
- $OBDCTL <<- EOF
- name2dev OSTDEV
- cleanup
- detach
- name2dev OBDDEV
- cleanup
- detach
- quit
- EOF
+ OSTDEVNO=`find_devno OSTDEV`
+ if [ "$OSTDEVNO" ]; then
+ $OBDCTL <<- EOF
+ device $OSTDEVNO
+ cleanup
+ detach
+ quit
+ EOF
+ fi
+
+ OBDDEVNO=`find_devno OBDDEV`
+ if [ "$OBDDEVNO" ]; then
+ $OBDCTL <<- EOF
+ device $OBDDEVNO
+ cleanup
+ detach
+ quit
+ EOF
+ fi
}
cleanup_server() {
cleanup_ost && cleanup_mds
- DEVNO=0
}
cleanup_mount() {
[ "$SETUP" -a -z "$SETUP_MOUNT" ] && return 0
[ "$OSCMT" ] || OSCMT=/mnt/lustre
- umount $OSCMT || fail "unable to unmount $OSCMT"
+ if [ "`mount | grep $OSCMT`" ]; then
+ umount $OSCMT || fail "unable to unmount $OSCMT"
+ fi
}
cleanup_osc() {
[ "$SETUP" -a -z "$SETUP_OSC" ] && return 0
- [ "$SETUP" ] || OSC_DEVNO=3
+ OSCDEVNO=`find_devno OSCDEV`
+ if [ "$OSCDEVNO" ]; then
+ $OBDCTL <<- EOF
+ device $OSCDEVNO
+ cleanup
+ detach
+ quit
+ EOF
+ fi
+}
- $OBDCTL <<- EOF
- name2dev OSCDEV
- cleanup
- detach
- quit
- EOF
+cleanup_rpc() {
+ RPCDEVNO=`find_devno RPCDEV`
+ if [ "$RPCDEVNO" ]; then
+ $OBDCTL <<- EOF
+ device $RPCDEVNO
+ cleanup
+ detach
+ quit
+ EOF
+ fi
}
cleanup_client() {
- cleanup_mount && cleanup_osc
- DEVNO=0
+ cleanup_mount && cleanup_osc && cleanup_rpc
}
fail() {
# Probably a good idea to run this before doing any checkins.
# In the future this can become more fancy, but it's OK for now.
-RUNDIR=`dirname $0`
+SRCDIR="`dirname $0`"
-PATH=$PATH:$RUNDIR
+export PATH=/sbin:/usr/sbin:$SRCDIR:$PATH
+
+. $SRCDIR/common.sh
ERROR=
-[ "`mount | grep /mnt/lustre`" ] || echo | sh llmount.sh || exit 1
+[ "`mount | grep /mnt/lustre`" ] || echo | sh llsetup.sh $@ || exit 1
# let's start slowly here...
-touch /mnt/lustre || exit 2
-cp /etc/hosts /mnt/lustre || exit 3
-diff -u /etc/hosts /mnt/lustre/hosts || exit 4
+touch /mnt/lustre || fail "can't touch /mnt/lustre" 2
+cp /etc/hosts /mnt/lustre || fail "can't cp /etc/hosts" 3
+diff -u /etc/hosts /mnt/lustre/hosts || fail "/etc/hosts copy different" 4
# ok, that hopefully worked, so let's do a little more
FILES=`find /etc -type f`
echo "copying files from /etc to /mnt/lustre"
-tar cf - $FILES | tar xf - -C /mnt/lustre || exit 10
+tar cf - $FILES | tar xf - -C /mnt/lustre || fail "copying /etc" 10
echo "comparing newly copied files"
for f in $FILES; do
diff -q $f /mnt/lustre/$f || ERROR=11
done
-[ "$ERROR" ] && exit $ERROR
+[ "$ERROR" ] && fail "old and new files are different" 11
-sh llmountcleanup.sh
+sh llcleanup.sh $@
-echo | sh llrmount.sh || exit 20
+echo | sh llrsetup.sh $@ || exit 20
echo "comparing previously copied files"
-diff -u /etc/hosts /mnt/lustre/hosts || exit 21
+diff -u /etc/hosts /mnt/lustre/hosts || fail "/etc/hosts is now different" 21
for f in $FILES; do
diff -q $f /mnt/lustre/$f || ERROR=22
done
-[ "$ERROR" ] && exit $ERROR
+[ "$ERROR" ] && fail "old and new files are different on second diff" 23
-sh llmountcleanup.sh
-echo | sh llrmount.sh || exit 24
+sh llcleanup.sh $@
+echo | sh llrsetup.sh $@ || exit 24
echo "removing files from /mnt/lustre/etc"
-rm /mnt/lustre/hosts || exit 25
+rm /mnt/lustre/hosts || fail "can't remove /mnt/lustre/hosts" 25
-rm -r /mnt/lustre/etc || exit 26
+rm -r /mnt/lustre/etc || fail "can't remove /mnt/lustre/etc" 26
-sh llmountcleanup.sh
+sh llcleanup.sh $@