2 #* Copyright (C) 2002 Cluster File Systems, Inc.
3 #* Author: Jitendra Pawar <jitendra@clusterfs.com>
5 #* Lustre-iokit is free software; you can redistribute it and/or
6 #* modify it under the terms of version 2 of the GNU General Public
7 #* License as published by the Free Software Foundation.
9 #* Lustre-iokit is distributed in the hope that it will be useful,
10 #* but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 #* GNU General Public License for more details.
14 #* You should have received a copy of the GNU General Public License
15 #* along with Lustre; if not, write to the Free Software
16 #* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 modprobe="/sbin/modprobe"
27 declare -a unique_hosts
30 declare -a do_unload_echo
43 command="cd $here; export PATH=/sbin:/usr/sbin:\$PATH; $command"
47 if [ -n "$user" ]; then
50 $DSH $user$node "$command"
53 if [ -n "$user" ]; then
56 $DSH $user $node "$command"
61 # how to run commands on other nodes
62 # You need to make this work on your cluster if you have specified
63 # non-local obd instances above
68 if [ "$host" = "localhost" -o "$host" = `uname -n` ]; then
71 # split $host into $host and $user
73 if [[ $host == *@* ]]; then
77 dsh $host "$user" "$cmds"
81 # checks whether obdecho module is loded on given host.
82 # parameter: 1. hostname
85 remote_shell $host $lsmod | grep obdecho > /dev/null 2>&1
88 # load obdecho.ko or obdecho.o module on host kernel.
91 local host=${unique_hosts[$index]}
92 do_unload_echo[$index]=0
93 if obdecho_loaded $host; then
96 if [ -z "$lustre_root" ]; then
97 remote_shell $host $modprobe obdecho
98 elif [ -f ${lustre_root}/obdecho/obdecho.ko ]; then
99 remote_shell $host $insmod ${lustre_root}/obdecho/obdecho.ko
101 remote_shell $host $insmod ${lustre_root}/obdecho/obdecho.o
103 if obdecho_loaded $host; then
104 do_unload_echo[$index]=1
106 echo Could not install obdecho on $host
113 for ((i = 0; i < ${#unique_hosts[@]}; i++)); do
114 load_obdecho $i || cleanup 1
118 # unload obdecho module from host kernel.
121 local host=${unique_hosts[$index]}
122 if ((${do_unload_echo[$index]})); then
123 remote_shell $host $rmmod obdecho
124 do_unload_echo[$index]=0
128 # returns the device number which is displayed in "lctl device_list"
130 # parameter: 1. hostname
131 # 2. type of device ex: echo_client
132 # 3. name of device ex: ECHO_matrix.linsyssoft.com
137 remote_shell $host $lctl device_list | \
138 awk "{if (\$2 == \"UP\" && \$3 == \"$type\" && \$4 == \"$name\") {\
145 for ((i = 0; i < $count; i++)); do
147 host=${host_list[$i]}
148 dev=$(get_devno $host obdfilter $ost)
150 if [ -z "$dev" ]; then
151 echo Cant find device for $ost on $host
158 # do cleanup and exit.
160 local clean_srv_OSS=$2
161 for ((i = 0; i < ndevs; i++)); do
162 host=${host_names[$i]}
163 if [ -n ${do_teardown_ec[$i]} ]; then
164 teardown_ec_devno $host ${client_names[$i]}
168 for host in ${unique_hosts[@]}; do
169 remote_shell $host "killall -q vmstat >/dev/null 2>&1" &
171 kill -term ${vmstatpids[$pidcount]} 2>/dev/null
172 kill -kill ${vmstatpids[$pidcount]} 2>/dev/null
174 pidcount=$((pidcount+1))
175 if ((${do_unload_obdecho[$host]})); then
179 if [ $case == "network" ]; then
181 cfg_device osc_testfs
185 remote_shell "root@$server_nid" "lctl << EOF
191 if [ $clean_srv_OSS ]; then
192 remote_shell "root@$server_nid" "lctl << EOF
199 if [ $1 -ne 0 ]; then
200 echo "program exited with error "
209 trap cleanup SIGHUP SIGINT SIGTERM
211 # gets echoclient device number and attch it to the client UUID
213 # parameter: 1. hostname
214 # 2. client name, ex:- ns8:ECHO_ns8
215 # 3. name of ost instances, ex:- lustre-OST0001
218 local client_name="$2"
220 if [ -z "$client_name" ]; then
221 if [ -z "$ost_name" ]; then
222 echo "client and ost name both null" 1>&2
225 client_name=${ost_name}_echo_client
227 ec=`get_devno $host echo_client $client_name`
228 if [ -n "$ec" ]; then
229 echo $ec $client_name $client_name
232 if [ -z "$ost_name" ]; then
233 echo "no echo client and ost_name not set, client: $client_name, host: $host" 1>&2
236 ost=`get_devno $host obdfilter $ost_name`
237 if [ -z "$ost" ]; then
238 echo "OST $ost_name not setup" 1>&2
241 remote_shell $host "$lctl <<EOF
242 attach echo_client $client_name ${client_name}_UUID
245 ec=`get_devno $host echo_client $client_name`
246 if [ -z "$ec" ]; then
247 echo "Can't setup echo client" 1>&2
250 echo $ec $client_name 1
253 # Create echo-clients using osc_names and osc_uuid
254 # It creates echoclients for all osc listed using #lctl device_list command
259 attach echo_client ECHO_$osc_name $osc_uuid
260 cfg_device ECHO_$osc_name
266 # create echo client using server nid.
267 ec_using_srv_nid () {
271 $lctl add_uuid testfs_UUID $server_nid@tcp >/dev/null 2>&1
273 attach osc $ocsname $oscuuid
275 setup echo_srv_UUID testfs_UUID
278 attach echo_client ECHO_$ocsname $oscuuid
283 # setup obdecho on server
286 local test_ostfsnm=$2
287 remote_shell "root@$server_nid" "$lctl << EOF
288 attach obdecho $test_ostfsnm ${test_ostfsnm}_UUID
289 cfg_device $test_ostfsnm
294 # setup OSS on server
297 remote_shell "root@$server_nid" "$lctl << EOF
298 attach ost OSS OSS_UUID
304 # cleanup and detach the echo-clients that we have created during the test.
305 # parameter: 1. hostname
306 # 2. client name, ex:- ns8:ECHO_ns8
307 teardown_ec_devno () {
310 remote_shell $host "$lctl <<EOF
318 echo "$@" | xargs -n1 echo | sort -u
324 *:*) host=`echo $name | sed 's/:.*$//'`
325 name=`echo $name | sed 's/[^:]*://'`
335 osc_names_str=$(lctl dl | grep $type_obj)
337 for name in $osc_names_str; do
341 if [ $count != 0 ]; then
342 echo "$type_obj could not be cleanup";
350 osc_names_str=$(lctl dl | grep $type_obj)
352 for name in $osc_names_str; do
356 if [ $count == 0 ]; then
357 echo "$type_obj could not be setup";
363 # added from bugzill req.
365 if [ -z "$ost_names" ]; then
366 OSTS=$($lctl device_list | awk "{if (\$2 == \"UP\" && \
367 \$3 == \"obdfilter\") {print \$4} }")
369 if [ -z "$OSTS" ]; then
370 echo "Can't find any OSTs to test. Please set ost_names=..."
374 for name in $OSTS; do
375 ost_names[$count]=$name
381 # split out hostnames from ost names
382 for ((i = 0; i < count; i++)); do
383 str=(`split_hostname ${OSTS[$i]}`)
384 host_list[$i]=${str[0]}
385 ost_names[$i]=${str[1]}