3 ######################################################################
6 # specify obd instances to exercise
7 # these can be either...
8 # obdfilter instances (set 'ost_names')
10 # echo_client instances (set 'client_names')
11 # ... use 'host:name' for obd instances on other nodes.
13 # allow these to be passed in via string...
14 ost_names_str=${ost_names_str:-""}
15 if [ -n "$ost_names_str" ]; then
18 for name in $ost_names_str; do
19 ost_names[$count]=$name
23 ost_names=(ost{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16})
26 #client_names=(ns8:ECHO_ns8 ns9:ECHO_ns9)
27 client_names_str=${client_names_str:-""}
28 if [ -n "$client_names_str" ]; then
29 # make sure we unset ost_names so that our client_names get noticed...
31 declare -a client_names
33 for name in $client_names_str; do
34 client_names[$count]=$name
39 # result file prefix (date/time + hostname makes unique)
40 # NB ensure path to it exists
41 rslt=${rslt:-"/home_nfs/eeb/obdfilter_survey_`date +%F@%R`_`uname -n`"}
43 # lustre root (if running with own source tree)
44 lustre_root=${lustre_root:-"/home_nfs/eeb/lustre"}
46 # what tests to run (first must be write)
47 tests_str=${tests_str:-""}
48 if [ -n "$tests_str" ]; then
51 for name in $tests_str; do
56 #tests=(write rewrite read reread rewrite_again)
57 tests=(write rewrite read)
60 # total size (MBytes) per obd instance
61 # large enough to avoid cache effects
62 # and to make test startup/shutdown overhead insignificant
65 # record size (KBytes)
69 # number of objects per OST
73 # threads per OST (1024 max)
77 # restart from here iff all are defined
82 # machine's page size (K)
83 PAGE_SIZE=${PAGE_SIZE:-16}
85 # max buffer_mem (total_threads * buffer size)
86 # (to avoid lctl ENOMEM problems)
87 max_buffer_mem=$((1024*1024))
89 # how to run commands on other nodes
90 # You need to make this work on your cluster if you have specified
91 # non-local obd instances above
92 custom_remote_shell () {
97 # Hop on to the remote node, chdir to 'here' and run the given
98 # commands. One of the following will probably work.
99 #ssh $host "cd $here; $cmds"
100 #rsh $host "cd $here; $cmds"
101 # we have to remove the leading `uname -n`: from pdsh output lines
102 pdsh -w $host "cd $here; $cmds" | sed 's/^[^:]*://'
105 #####################################################################
106 # leave the rest of this alone unless you know what you're doing...
110 modprobe="/sbin/modprobe"
111 insmod="/sbin/insmod"
114 # lctl::test_brw bandwidth snapshot interval (seconds)
116 # check file contents?
119 if [ ${#tests[@]} -eq 0 -o "${tests[0]}" != "write" ]; then
120 echo "tests: ${tests[@]}"
121 echo "First test must be 'write'" 1>&2
125 rsltf="${rslt}.summary"
126 workf="${rslt}.detail"
127 cmdsf="${rslt}.script"
128 vmstatf="${rslt}.vmstat"
132 declare -a vmstatpids
134 # hide a little trick to unset this from the command line
135 if [ "$lustre_root" == " " ]; then
139 if [ -z "$lustre_root" ]; then
142 lctl=${lustre_root}/utils/lctl
149 if [ "$host" = "localhost" -o "$host" = `uname -n` ]; then
152 custom_remote_shell $host "$cmds"
158 remote_shell $host $lsmod | grep obdecho > /dev/null 2>&1
163 if [ -z "$lustre_root" ]; then
164 remote_shell $host $modprobe obdecho
165 elif [ -f ${lustre_root}/obdecho/obdecho.ko ]; then
166 remote_shell $host $insmod ${lustre_root}/obdecho/obdecho.ko
168 remote_shell $host $insmod ${lustre_root}/obdecho/obdecho.o
174 remote_shell $host $rmmod obdecho
181 remote_shell $host $lctl device_list | \
182 awk "{if (\$2 == \"UP\" && \$3 == \"$type\" && \$4 == \"$name\") {\
188 local client_name="$2"
190 if [ -z "$client_name" ]; then
191 if [ -z "$ost_name" ]; then
192 echo "client and ost name both null" 1>&2
195 client_name=${ost_name}_echo_client
197 ec=`get_devno $host echo_client $client_name`
198 if [ -n "$ec" ]; then
199 echo $ec $client_name 0
202 if [ -z "$ost_name" ]; then
203 echo "no echo client and ost_name not set" 1>&2
206 ost=`get_devno $host obdfilter $ost_name`
207 if [ -z "$ost" ]; then
208 echo "OST $ost_name not setup" 1>&2
211 remote_shell $host "$lctl <<EOF
212 attach echo_client $client_name ${client_name}_UUID
215 ec=`get_devno $host echo_client $client_name`
216 if [ -z "$ec" ]; then
217 echo "Can't setup echo client" 1>&2
220 echo $ec $client_name 1
223 teardown_ec_devno () {
226 remote_shell $host "$lctl <<EOF
234 # create a set of objects, check there are 'n' contiguous ones and
235 # return the first or 'ERROR'
240 remote_shell $host $lctl --device $devno create $nobj > $rfile 2>&1
246 echo "$line" | grep -q 'is object id'
247 if [ $? -ne 0 ]; then
250 if [ $first -eq 0 ]; then
251 first=$(echo $line | awk '{print $6}')
252 first=$(printf "%d" $first)
256 obj=$(echo $line | awk '{print $6}')
257 obj=$(printf "%d" $obj)
258 diff=$((obj - (prev+1)))
259 if [ $diff -ne 0 ]; then
266 if [ $nobj -ne $count ]; then
267 echo "ERROR: $nobj != $count" >&2
270 elif [ $error -ne 0 ]; then
271 echo "ERROR: non contiguous objs found" >&2
284 remote_shell $host $lctl --device $devno destroy $obj0 $nobj > $rfile 2>&1
290 '/^Selected device [0-9]+$/ {n = 0; next}\
291 /error/ {n = -1; exit}\
292 /^[0-9]+\/[0-9]+ Total: [0-9]+\.[0-9]+\/second$/ {n++; v=strtonum($3); \
293 if (n == 1 || v < min) min = v;\
294 if (n == 1 || v > max) max = v;\
296 {if (n != 0) {n = -1; exit}}\
297 END {printf "%d %f %f\n", n, min, max}'
300 get_global_stats () {
302 awk < $rfile 'BEGIN {n = 0;}\
303 {n++; if (n == 1) {err = $1; min = $2; max = $3} else\
304 {if ($1 < err) err = $1;\
305 if ($2 < min) min = $2;\
306 if ($3 > max) max = $3}}\
307 END {if (n == 0) err = 0;\
308 printf "%d %f %f\n", err, min, max}'
312 # 'x' disables data check
319 *write*) echo "w$x";;
325 if [ "$1" = "-n" ]; then
330 echo $minusn "$*" >> $rsltf
335 echo "$@" | xargs -n1 echo | sort -u
341 *:*) host=`echo $name | sed 's/:.*$//'`
342 name=`echo $name | sed 's/[^:]*://'`
350 # split out hostnames from client/ost names
351 ndevs=${#client_names[@]}
352 if ((ndevs != 0)); then
353 if ((${#ost_names[@]} != 0)); then
354 echo "Please specify client_names or ost_names, but not both" 1>&2
357 for ((i=0; i<ndevs;i++)); do
358 str=(`split_hostname ${client_names[$i]}`)
359 host_names[$i]=${str[0]}
360 client_names[$i]=${str[1]}
363 ndevs=${#ost_names[@]}
364 if ((ndevs == 0)); then
365 echo "Please specify either client_names or ost_names" 1>&2
368 for ((i=0; i<ndevs;i++)); do
369 str=(`split_hostname ${ost_names[$i]}`)
370 host_names[$i]=${str[0]}
371 ost_names[$i]=${str[1]}
376 # disable portals debug and get obdecho loaded on all relevant hosts
377 unique_hosts=(`unique ${host_names[@]}`)
379 for host in ${unique_hosts[@]}; do
380 remote_shell $host "echo 0 > /proc/sys/portals/debug"
381 host_vmstatf=${vmstatf}_${host}
382 echo -n > $host_vmstatf
383 remote_shell $host "vmstat 5 >> $host_vmstatf" &
385 vmstatpids[$pidcount]=$pid
386 pidcount=$((pidcount+1))
387 do_unload_obdecho[$host]=0
388 if obdecho_loaded $host; then
392 if obdecho_loaded $host; then
393 do_unload_obdecho[$host]=1
396 echo "Can't load obdecho on $host" 1>&2
400 # get all the echo_client device numbers and names
401 for ((i=0; i<ndevs; i++)); do
402 host=${host_names[$i]}
403 devno=(`get_ec_devno $host "${client_names[$i]}" "${ost_names[$i]}"`)
404 if ((${#devno[@]} != 3)); then
407 devnos[$i]=${devno[0]}
408 client_names[$i]=${devno[1]}
409 do_teardown_ec[$i]=${devno[2]}
412 for ((rsz=$rszlo;rsz<=$rszhi;rsz*=2)); do
413 for ((nobj=$nobjlo;nobj<=$nobjhi;nobj*=2)); do
414 for ((thr=$thrlo;thr<=$thrhi;thr*=2)); do
415 if ((thr < nobj)); then
419 if [ -n "$restart_rsz" -a\
420 -n "$restart_nobj" -a\
421 -n "$restart_thr" ]; then
422 if ((rsz < restart_rsz ||\
423 (rsz == restart_rsz &&\
424 (nobj < restart_nobj ||\
425 (nobj == restart_nobj &&\
426 thr < restart_thr))))); then
431 total_thr=$((ndevs*thr))
432 total_nobj=$((ndevs*nobj))
433 pages=$((rsz/PAGE_SIZE))
434 actual_rsz=$((pages*PAGE_SIZE))
435 count=$((size*1024/(actual_rsz*thr)))
436 actual_size=$((actual_rsz*count*thr))
437 total_size=$((actual_size*ndevs))
438 # show computed parameters
439 str=`printf 'ost %2d sz %8dK rsz %4d obj %4d thr %4d ' \
440 $ndevs $total_size $actual_rsz $total_nobj $total_thr`
441 echo "=======================> $str" >> $workf
442 print_summary -n "$str"
443 if ((total_thr * actual_rsz > max_buffer_mem)); then
444 print_summary "Too much buffer space"
449 for ((idx=0; idx < ndevs; idx++)); do
450 host=${host_names[$idx]}
451 devno=${devnos[$idx]}
452 client_name="${host}:${client_names[$idx]}"
453 echo "=============> Create $nobj on $client_name" >> $workf
454 first_obj=`create_objects $host $devno $nobj $tmpf`
457 if [ $first_obj = "ERROR" ]; then
458 print_summary "created object #s on $client_name not contiguous"
461 first_objs[$idx]=$first_obj
464 for test in ${tests[@]}; do
466 for host in ${unique_hosts[@]}; do
467 echo "starting run for test: $test rsz: $rsz threads: $thr objects: $nobj" >> ${vmstatf}_${host}
469 print_summary -n "$test "
470 # create per-host script files
471 for host in ${unique_hosts[@]}; do
472 echo -n > ${cmdsf}_${host}
474 for ((idx=0; idx < ndevs; idx++)); do
475 host=${host_names[$idx]}
476 devno=${devnos[$idx]}
478 first_obj=${first_objs[$idx]}
479 echo >> ${cmdsf}_${host} \
480 "$lctl > $tmpfi 2>&1 \\
481 --threads $thr -$snap $devno \\
482 test_brw $count `testname2type $test` q $pages ${thr}t${first_obj} &"
486 for host in ${unique_hosts[@]}; do
487 echo "wait" >> ${cmdsf}_${host}
488 pidarray[$pidcount]=0
489 pidcount=$((pidcount+1))
491 # timed run of all the per-host script files
494 for host in ${unique_hosts[@]}; do
495 remote_shell $host bash ${cmdsf}_${host} &
496 pidarray[$pidcount]=$!
497 pidcount=$((pidcount+1))
500 for host in ${unique_hosts[@]}; do
501 wait ${pidarray[$pidcount]}
502 pidcount=$((pidcount+1))
506 # clean up per-host script files
507 for host in ${unique_hosts[@]}; do
510 # compute bandwidth from total data / elapsed time
511 str=`awk "BEGIN {printf \"%7.2f \",\
512 $total_size / (( $t1 - $t0 ) * 1024)}"`
513 print_summary -n "$str"
514 # collect/check individual OST stats
516 for ((idx=0; idx < ndevs; idx++)); do
517 client_name="${host_names[$idx]}:${client_names[$idx]}"
519 echo "=============> $test $client_name" >> $workf
521 get_stats $tmpfi >> $tmpf
524 # compute/display global min/max stats
525 echo "=============> $test global" >> $workf
527 stats=(`get_global_stats $tmpf`)
529 if ((stats[0] <= 0)); then
530 if ((stats[0] < 0)); then
531 str=`printf "%17s " ERROR`
533 str=`printf "%17s " SHORT`
536 str=`awk "BEGIN {printf \"[%7.2f,%7.2f] \",\
537 (${stats[1]} * $actual_rsz)/1024,\
538 (${stats[2]} * $actual_rsz)/1024; exit}"`
540 print_summary -n "$str"
543 # destroy objects we created
544 for ((idx=0; idx < ndevs; idx++)); do
545 host=${host_names[$idx]}
546 devno=${devnos[$idx]}
547 client_name="${host}:${client_names[$idx]}"
548 first_obj=${first_objs[$idx]}
549 echo "=============> Destroy $nobj on $client_name" >> $workf
550 destroy_objects $host $devno $first_obj $nobj $tmpf
558 # tear down any echo clients we created
559 for ((i=0; i<ndevs; i++)); do
560 host=${host_names[$i]}
561 if ((${do_teardown_ec[$i]})); then
562 teardown_ec_devno $host ${client_names[$i]}
566 # unload any obdecho modules we loaded
568 for host in ${unique_hosts[@]}; do
569 remote_shell $host "killall vmstat" &
571 kill -term ${vmstatpids[$pidcount]}
572 kill -kill ${vmstatpids[$pidcount]} 2>/dev/null
574 pidcount=$((pidcount+1))
575 if ((${do_unload_obdecho[$host]})); then