Whamcloud - gitweb
Split out the various common configurations into simple config files.
authoradilger <adilger>
Thu, 11 Apr 2002 10:00:24 +0000 (10:00 +0000)
committeradilger <adilger>
Thu, 11 Apr 2002 10:00:24 +0000 (10:00 +0000)
These will be used by various scripts for configuration, and can be
copied, combined, edited for each user as desired.

The llsetup.sh script will do the appropriate configuration based on
the config scripts that are passed.  For example:

llmount.sh == llsetup.sh local.cfg client-mount.cfg mds.cfg obdext2.cfg
llecho.sh  == llsetup.sh local.cfg client-echo.cfg echo.cfg
llmount-server.sh = llsetup.sh server-net.cfg mds.cfg obdext2.cfg
llmount-client.sh = llsetup.sh client-net.cfg client-mount.cfg

It is of course possible to combine several of the config files into a
single file for ease of typing, these ones are just the basics, e.g.

llsetup.sh peter.cfg
llsetup.sh adilger.cfg

By default it will also check in $HOME/.lustrerc for configuration before
parsing the specified config files.

None of the other scripts have been moved over to this config setup yet.

Still TODO: remote server setup

12 files changed:
lustre/tests/client-echo.cfg [new file with mode: 0644]
lustre/tests/client-mount.cfg [new file with mode: 0644]
lustre/tests/client-net.cfg [new file with mode: 0644]
lustre/tests/common.sh
lustre/tests/echo.cfg [new file with mode: 0644]
lustre/tests/llsetup.sh [new file with mode: 0644]
lustre/tests/local.cfg [new file with mode: 0644]
lustre/tests/mds.cfg [new file with mode: 0644]
lustre/tests/obddisk.cfg [new file with mode: 0644]
lustre/tests/obdext2.cfg [new file with mode: 0644]
lustre/tests/obdfilter.cfg [new file with mode: 0644]
lustre/tests/server-net.cfg [new file with mode: 0644]

diff --git a/lustre/tests/client-echo.cfg b/lustre/tests/client-echo.cfg
new file mode 100644 (file)
index 0000000..83856ec
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+# Config file for setting up a client to talk to an echo OST
+SETUP_OSC=y
diff --git a/lustre/tests/client-mount.cfg b/lustre/tests/client-mount.cfg
new file mode 100644 (file)
index 0000000..644ae14
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/sh
+# Config file for mounting a client Lustre filesystem
+SETUP_OSC=y
+OSCMT=/mnt/lustre
+SETUP_MOUNT=y
diff --git a/lustre/tests/client-net.cfg b/lustre/tests/client-net.cfg
new file mode 100644 (file)
index 0000000..64986ca
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+# Config file for setting up a remote server with a real OST
+NETWORK=tcp
+LOCALHOST=dev5
+SERVER=dev4
+PORT=1234
index fd4a529..33e1992 100644 (file)
@@ -1,8 +1,7 @@
+#!/bin/sh
 export PATH=$PATH:/sbin:/usr/sbin
 
-if [ -d /r ]; then
-       R=/r
-fi
+[ -d /r ] && R=/r
 
 PORTALS=$SRCDIR/../../portals
 LUSTRE=$SRCDIR/../../obd
@@ -16,12 +15,10 @@ OBDCTL=$LUSTRE/utils/obdctl
 LOOPNUM=0; export LOOPNUM
 if [ -b /dev/loop0 ]; then
        LOOP=/dev/loop
+elif [ -b /dev/loop/0 ]; then
+       LOOP=/dev/loop/
 else
-       if [ -b /dev/loop/0 ]; then
-               LOOP=/dev/loop/
-       else
-               echo "Cannot find /dev/loop0 or /dev/loop/0" 1>&2 && exit -1
-       fi
+       echo "Cannot find /dev/loop0 or /dev/loop/0" 1>&2 && exit -1
 fi
 
 # Return the next unused loop device on stdout and in the $LOOPDEV
@@ -55,7 +52,7 @@ new_fs () {
                        echo "usage: $0 <fstype> <file> [size]" 1>&2 && exit -1
 
                PM="/proc/mounts"
-               [ -f "$PM" ] || PM="/etc/mtab"
+               [ -r "$PM" ] || PM="/etc/mtab"
 
                grep "$2 " $PM 1>&2 && echo "$0: $2 is in $PM!" 1>&2 && exit -1
 
@@ -65,7 +62,7 @@ new_fs () {
                [ $# -ne 3 ] && \
                        echo "usage: $0 <fstype> <file> <size>" 1>&2 && exit -1
 
-               if [ -f "$EFILE" ]; then
+               if [ -r "$EFILE" ]; then
                        echo "using existing filesystem $EFILE for $2"
                        zcat "$EFILE" > $2 || exit -1
                        sync
@@ -98,6 +95,25 @@ list_mods() {
        echo "The GDB module script is in /tmp/ogdb"
 }
 
+# We need at least one setup file to be given.  It can be passed on
+# the command-line, or it can be found in the home directory, or it
+# can even be sourced into the current shell environment.
+setup_opts() {
+       DEF=$HOME/.lustretestrc
+       [ -r $DEF ] && . $DEF && SETUP=y
+
+       for CFG in "$@" ; do
+               case $CFG  in
+               *.cfg) [ -r "$CFG" ] && . $CFG && SETUP=y ;;
+               esac
+       done
+
+       if [ "$SETUP" != "y" ]; then
+               echo "error: no config file on command-line and no $DEF" 1>&2
+               exit -1
+       fi
+}
+
 setup_portals() {
        if [ -z "$NETWORK" -o -z "$LOCALHOST" -o -z "$SERVER" ]; then
                echo "$0: NETWORK or LOCALHOST or SERVER is not set" 1>&2
@@ -122,7 +138,7 @@ setup_portals() {
                insmod $PORTALS/linux/socknal/ksocknal.o || exit -1
                $ACCEPTOR $PORT
                ;;
-       *)      echo "$0: unknown NETWORK \'$NETWORK\'" 1>&2
+       *)      echo "$0: unknown NETWORK '$NETWORK'" 1>&2
                exit -1
                ;;
        esac
@@ -171,3 +187,261 @@ setup_ldlm() {
         echo "Press Enter to continue"
         read
 }
+
+DEVNO=0; export DEVNO
+
+setup_mds() {
+       [ "$SETUP_MDS" = "y" ] || return 0
+
+       if [ -z "$MDSFS" -o -z "$MDSDEV" ]; then
+               echo "error: setup_mds: MDSFS or MDSDEV unset" 1>&2
+               return -1
+       fi
+
+       if [ "$1" != "new_fs" -a "$1" != "old_fs" ]; then
+               echo "usage: setup_mds {new_fs|old_fs}" 1>&2
+               return -1
+       fi
+
+       $1 ${MDSFS} ${MDSDEV} ${MDSSIZE}
+       MDS=${LOOPDEV}
+
+       MDS_DEVNO=$DEVNO; DEVNO=`expr $DEVNO + 1`
+       
+       $OBDCTL <<- EOF
+       device ${MDS_DEVNO}
+       attach mds
+       setup ${MDS} ${MDSFS}
+       quit
+       EOF
+}
+
+setup_ost() {
+       [ "$SETUP_OST" = "y" ] || return 0
+
+       if [ -z "$OSTTYPE" ]; then
+               echo "error: setup_ost: OSTTYPE unset" 1>&2
+               return -1
+       fi
+
+       case $OSTTYPE in
+       obdecho)        OBD=
+                       OBDARG=
+                       NEED_FS=n
+               ;;
+       obdext2)        OBDARG=
+                       NEED_FS=y
+               ;;
+       obdfilter)      OBDARG=$OSTFS
+                       NEED_FS=y
+               ;;
+       *)      echo "error: setup_ost: unknown OSTTYPE '$OSTTYPE'" 1>&2
+               return -1
+               ;;
+       esac
+
+       if [ "$NEED_FS" = "y" ]; then
+               [ "$1" ] && DO_FS=$1
+               if [ -z "$OSTFS" -o -z "$OSTDEV" ]; then
+                       echo "error: setup_ost: OSTFS or OSTDEV unset" 1>&2
+                       return -1
+               fi
+
+               if [ "$DO_FS" != "new_fs" -a "$DO_FS" != "old_fs" ]; then
+                       echo "usage: setup_ost {new_fs|old_fs}" 1>&2
+                       return -1
+               fi
+
+               $DO_FS ${OSTFS} ${OSTDEV} ${OSTSIZE}
+               OBD=${LOOPDEV}
+       fi
+
+       OBD_DEVNO=$DEVNO; DEVNO=`expr $DEVNO + 1`
+       OST_DEVNO=$DEVNO; DEVNO=`expr $DEVNO + 1`
+
+       $OBDCTL <<- EOF
+       device ${OBD_DEVNO}
+       attach ${OSTTYPE}
+       setup ${OBD} ${OBDARG}
+       device ${OST_DEVNO}
+       attach ost
+       setup ${OBD_DEVNO}
+       quit
+       EOF
+}
+
+setup_server() {
+       setup_mds $1 && setup_ost $1
+}
+
+setup_osc() {
+       [ "$SETUP_OSC" != "y" ] && return 0
+
+       OSC_DEVNO=$DEVNO; DEVNO=`expr $DEVNO + 1`
+       $OBDCTL <<- EOF || return $rc
+       device ${OSC_DEVNO}
+       attach osc
+       setup -1
+       quit
+       EOF
+}
+
+setup_mount() {
+       [ "$SETUP_MOUNT" != "y" ] && return 0
+
+       if [ -z "$OSCMT" ]; then
+               echo "error: setup_mount: OSCMT unset" 1>&2
+               return -1
+       fi
+
+       [ ! -d $OSCMT ] && mkdir $OSCMT
+       mount -t lustre_lite -o device=$OSC_DEVNO none $OSCMT
+}
+
+setup_client() {
+       setup_osc && setup_mount
+}
+
+DEBUG_ON="echo 0xffffffff > /proc/sys/portals/debug"
+DEBUG_OFF="echo 0 > /proc/sys/portals/debug"
+
+debug_server_off() {
+       if [ "$SERVER" != "$LOCALHOST" ]; then
+               $RSH $SERVER "$DEBUG_OFF"
+       else
+               $DEBUG_OFF
+       fi
+}
+
+debug_server_on() {
+       if [ "$SERVER" != "$LOCALHOST" ]; then
+               $RSH $SERVER "$DEBUG_ON"
+       else
+               $DEBUG_ON
+       fi
+}
+
+debug_client_off() {
+       $DEBUG_OFF
+}
+
+debug_client_on() {
+       $DEBUG_ON
+}
+
+cleanup_portals() {
+       $PTLCTL <<- EOF
+       setup tcp
+       disconnect
+       del_uuid self
+       del_uuid mds
+       del_uuid ost
+       del_uuid ldlm
+       quit
+       EOF
+
+       rmmod kqswnal
+       rmmod ksocknal
+       rmmod portals
+}
+
+cleanup_lustre() {
+       killall acceptor
+
+       $OBDCTL <<- EOF
+       device 3
+       cleanup
+       detach
+       device 2
+       cleanup
+       detach
+       device 1
+       cleanup
+       detach
+       device 0
+       cleanup
+       detach
+       quit
+       EOF
+
+
+       losetup -d ${LOOP}0
+       losetup -d ${LOOP}1
+       losetup -d ${LOOP}2
+
+       rmmod llite
+       rmmod mdc
+
+       rmmod mds
+       rmmod ost
+       rmmod osc
+       rmmod obdecho
+       rmmod obdfilter
+       rmmod obdext2
+
+       rmmod ldlm
+       rmmod ptlrpc
+       rmmod obdclass
+}
+
+cleanup_mds() {
+       [ "$SETUP" -a -z "$SETUP_MDS" ] && return 0
+
+       [ "$SETUP" ] || MDS_DEVNO=0
+
+       $OBDCTL <<- EOF
+       device ${MDS_DEVNO}
+       cleanup
+       detach
+       quit
+       EOF
+}
+
+cleanup_ost() {
+       [ "$SETUP" -a -z "$SETUP_OST" ] && return 0
+
+       if [ -z "$SETUP" ]; then
+               OST_DEVNO=2
+               OBD_DEVNO=1
+       fi
+
+       $OBDCTL <<- EOF
+       device ${OST_DEVNO}
+       cleanup
+       detach
+       device ${OBD_DEVNO}
+       cleanup
+       detach
+       quit
+       EOF
+}
+
+cleanup_server() {
+       cleanup_mds && cleanup_ost
+       DEVNO=0
+}
+
+cleanup_mount() {
+       [ "$SETUP" -a -z "$SETUP_MOUNT" ] && return 0
+
+       [ "$OSCMT" ] || OSCMT=/mnt/lustre
+       umount $OSCMT
+}
+
+cleanup_osc() {
+       [ "$SETUP" -a -z "$SETUP_OSC" ] && return 0
+
+       [ "$SETUP" ] || OSC_DEVNO=3
+
+       $OBDCTL <<- EOF
+       device ${OSC_DEVNO}
+       cleanup
+       detach
+       quit
+       EOF
+}
+
+cleanup_client() {
+       cleanup_mount && cleanup_osc
+       DEVNO=0
+}
diff --git a/lustre/tests/echo.cfg b/lustre/tests/echo.cfg
new file mode 100644 (file)
index 0000000..2c2b40f
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+# Config file for setting up a test (echo) OST
+OSTTYPE=obdecho
+SETUP_OST=y
diff --git a/lustre/tests/llsetup.sh b/lustre/tests/llsetup.sh
new file mode 100644 (file)
index 0000000..7a2a5ae
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+SRCDIR="`dirname $0`"
+. $SRCDIR/common.sh
+
+setup_opts "$@"
+
+setup_portals
+setup_lustre
+
+setup_server
+setup_client
diff --git a/lustre/tests/local.cfg b/lustre/tests/local.cfg
new file mode 100644 (file)
index 0000000..6120f39
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+# Config file for running tests on a single host over loopback TCP
+NETWORK=tcp
+LOCALHOST=localhost
+SERVER=localhost
+PORT=1234
diff --git a/lustre/tests/mds.cfg b/lustre/tests/mds.cfg
new file mode 100644 (file)
index 0000000..104e586
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+# Config file for setting up a metadata server
+MDSFS=ext2
+MDSDEV=/tmp/mds
+MDSSIZE=10000
+SETUP_MDS=y
diff --git a/lustre/tests/obddisk.cfg b/lustre/tests/obddisk.cfg
new file mode 100644 (file)
index 0000000..1bafe0a
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+# Config file for setting up an object storage target with obdext2
+OSTDEV=/dev/hda7
+OSTFS=ext2
+OSTTYPE=obdext2
+SETUP_OST=y
diff --git a/lustre/tests/obdext2.cfg b/lustre/tests/obdext2.cfg
new file mode 100644 (file)
index 0000000..5d127d3
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+# Config file for setting up an object storage target with obdext2
+OSTDEV=/tmp/ost
+OSTSIZE=10000
+OSTFS=ext2
+OSTTYPE=obdext2
+SETUP_OST=y
diff --git a/lustre/tests/obdfilter.cfg b/lustre/tests/obdfilter.cfg
new file mode 100644 (file)
index 0000000..ee1504e
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+# Config file for setting up an object storage target with obdext2
+OSTDEV=/tmp/ost
+OSTSIZE=10000
+OSTFS=ext2
+OSTTYPE=obdfilter
+SETUP_OST=y
diff --git a/lustre/tests/server-net.cfg b/lustre/tests/server-net.cfg
new file mode 100644 (file)
index 0000000..225999a
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+# Config file for setting up a remote server with a real OST
+NETWORK=tcp
+LOCALHOST=dev4
+SERVER=dev4
+PORT=1234