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"
25 declare -a client_names
28 declare -a unique_hosts
31 declare -a do_unload_echo
44 command="cd $here; export PATH=/sbin:/usr/sbin:\$PATH; $command"
48 if [ -n "$user" ]; then
51 $DSH $user$node "$command"
54 if [ -n "$user" ]; then
57 $DSH $user $node "$command"
62 # how to run commands on other nodes
63 # You need to make this work on your cluster if you have specified
64 # non-local obd instances above
69 if [ "$host" = "localhost" -o "$host" = `uname -n` ]; then
72 # split $host into $host and $user
74 if [[ $host == *@* ]]; then
78 dsh $host "$user" "$cmds"
82 # checks whether obdecho module is loded on given host.
83 # parameter: 1. hostname
86 remote_shell $host $lsmod | grep obdecho > /dev/null 2>&1
89 # load obdecho.ko or obdecho.o module on host kernel.
92 local host=${unique_hosts[$index]}
93 do_unload_echo[$index]=0
94 if obdecho_loaded $host; then
97 if [ -z "$lustre_root" ]; then
98 remote_shell $host $modprobe obdecho
99 elif [ -f ${lustre_root}/obdecho/obdecho.ko ]; then
100 remote_shell $host $insmod ${lustre_root}/obdecho/obdecho.ko
102 remote_shell $host $insmod ${lustre_root}/obdecho/obdecho.o
104 if obdecho_loaded $host; then
105 do_unload_echo[$index]=1
107 echo Could not install obdecho on $host
114 for ((i = 0; i < ${#unique_hosts[@]}; i++)); do
115 load_obdecho $i || cleanup 1
119 # unload obdecho module from host kernel.
122 local host=${unique_hosts[$index]}
123 if ((${do_unload_echo[$index]})); then
124 remote_shell $host $rmmod obdecho
125 do_unload_echo[$index]=0
129 # returns the device number which is displayed in "lctl device_list"
131 # parameter: 1. hostname
132 # 2. type of device ex: echo_client
133 # 3. name of device ex: ECHO_matrix.linsyssoft.com
138 remote_shell $host $lctl device_list | \
139 awk "{if (\$2 == \"UP\" && \$3 == \"$type\" && \$4 == \"$name\") {\
146 for ((i = 0; i < $count; i++)); do
148 host=${host_list[$i]}
149 dev=$(get_devno $host obdfilter $ost)
151 if [ -z "$dev" ]; then
152 echo Cant find device for $ost on $host
159 # do cleanup for netdisk case.
170 # do cleanup for network case.
172 local clean_srv_OSS=$1
178 remote_shell "root@$server_nid" "lctl << EOF
183 if [ $clean_srv_OSS ]; then
184 remote_shell "root@$server_nid" "lctl << EOF
192 # do cleanup and exit.
196 for ((i = 0; i < $ndevs; i++)); do
197 host=${host_names[$i]}
198 if [ -n ${do_teardown_ec[$i]} ]; then
199 teardown_ec_devno $host ${client_names[$i]}
203 for host in ${unique_hosts[@]}; do
204 remote_shell $host "killall -q vmstat >/dev/null 2>&1" &
206 kill -term ${vmstatpids[$pidcount]} 2>/dev/null
207 kill -kill ${vmstatpids[$pidcount]} 2>/dev/null
209 pidcount=$((pidcount+1))
210 if ((${do_unload_obdecho[$host]})); then
214 if [ $case == "network" ]; then
217 if [ $case == "netdisk" ]; then
221 if [ $exit_status ]; then
222 if [ $exit_status -ne 0 ]; then
223 echo "program exited with error "
232 trap cleanup SIGHUP SIGINT SIGTERM
234 # gets echoclient device number and attch it to the client UUID
236 # parameter: 1. hostname
237 # 2. client name, ex:- ns8:ECHO_ns8
238 # 3. name of ost instances, ex:- lustre-OST0001
241 local client_name="$2"
243 if [ -z "$client_name" ]; then
244 if [ -z "$ost_name" ]; then
245 echo "client and ost name both null" 1>&2
248 client_name=${ost_name}_ecc
250 ec=`get_devno $host echo_client $client_name`
251 if [ -n "$ec" ]; then
252 echo $ec $client_name $client_name
255 if [ -z "$ost_name" ]; then
256 echo "no echo client and ost_name not set, client: $client_name, host: $host" 1>&2
259 ost=`get_devno $host obdfilter $ost_name`
260 if [ -z "$ost" ]; then
261 echo "OST $ost_name not setup" 1>&2
264 client_name=${ost_name}_ecc
265 remote_shell $host "$lctl <<EOF
266 attach echo_client $client_name ${client_name}_UUID
269 ec=`get_devno $host echo_client $client_name`
270 if [ -z "$ec" ]; then
271 echo "Can't setup echo-client" 1>&2
274 echo $ec $client_name 1
277 # Create echo-clients using osc_names and osc_uuid
278 # It creates echoclients for all osc listed using #lctl device_list command
282 attach echo_client ${osc_name}_ecc ${osc_name}_ecc_UUID
283 cfg_device ${osc_name}_ecc
289 # create echo client using server nid.
290 ec_using_srv_nid () {
294 $lctl add_uuid echo_UUID $server_nid@tcp >/dev/null 2>&1
296 attach osc $ocsname $oscuuid
298 setup echo_srv_UUID echo_UUID
301 attach echo_client ${ocsname}_ecc $oscuuid
306 setup_osc_for_remote_ost () {
308 local obdfilter_name=$2
309 local host_name=host_$3
310 $lctl add_uuid ${host_name}_UUID $ost_nid@tcp >/dev/null 2>&1
312 attach osc ${obdfilter_name}_osc ${obdfilter_name}_osc_UUID
313 cfg_device ${obdfilter_name}_osc
314 setup ${obdfilter_name}_UUID ${host_name}_UUID
318 # setup obdecho on server
321 local test_ostfsnm=$2
322 remote_shell "root@$server_nid" "$lctl << EOF
323 attach obdecho $test_ostfsnm ${test_ostfsnm}_UUID
324 cfg_device $test_ostfsnm
329 # setup OSS on server
332 remote_shell "root@$server_nid" "$lctl << EOF
333 attach ost OSS OSS_UUID
339 # cleanup and detach the echo-clients that we have created during the test.
340 # parameter: 1. hostname
341 # 2. client name, ex:- ns8:ECHO_ns8
342 teardown_ec_devno () {
345 remote_shell $host "$lctl <<EOF
353 echo "$@" | xargs -n1 echo | sort -u
359 *:*) host=`echo $name | sed 's/:.*$//'`
360 name=`echo $name | sed 's/[^:]*://'`
370 osc_names_str=$(lctl dl | grep $type_obj)
372 for name in $osc_names_str; do
376 if [ $count != 0 ]; then
377 echo "$type_obj could not be cleanup";
385 osc_names_str=$(lctl dl | grep $type_obj)
387 for name in $osc_names_str; do
391 if [ $count == 0 ]; then
392 echo "$type_obj could not be setup";
398 # added from bugzill req.
400 if [ -z "$ost_names" ]; then
401 targets=$($lctl device_list | awk "{if (\$2 == \"UP\" && \
402 \$3 == \"obdfilter\") {print \$4} }")
404 if [ -z "$targets" ]; then
405 echo "Can't find any OSTs to test. Please set targets=..."
409 for name in $targets; do
410 ost_names[$count]=$name
411 str=(`split_hostname $name`)
412 host_names[$count]=${str[0]}
418 # split out hostnames from ost names
419 for ((i = 0; i < count; i++)); do
420 str=(`split_hostname ${targets[$i]}`)
421 host_list[$i]=${str[0]}
422 ost_names[$i]=${str[1]}