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"
132 # hide a little trick to unset this from the command line
133 if [ "$lustre_root" == " " ]; then
137 if [ -z "$lustre_root" ]; then
140 lctl=${lustre_root}/utils/lctl
147 if [ "$host" = "localhost" -o "$host" = `uname -n` ]; then
150 custom_remote_shell $host "$cmds"
156 remote_shell $host $lsmod | grep obdecho > /dev/null 2>&1
161 if [ -z "$lustre_root" ]; then
162 remote_shell $host $modprobe obdecho
163 elif [ -f ${lustre_root}/obdecho/obdecho.ko ]; then
164 remote_shell $host $insmod ${lustre_root}/obdecho/obdecho.ko
166 remote_shell $host $insmod ${lustre_root}/obdecho/obdecho.o
172 remote_shell $host $rmmod obdecho
179 remote_shell $host $lctl device_list | \
180 awk "{if (\$2 == \"UP\" && \$3 == \"$type\" && \$4 == \"$name\") {\
186 local client_name="$2"
188 if [ -z "$client_name" ]; then
189 if [ -z "$ost_name" ]; then
190 echo "client and ost name both null" 1>&2
193 client_name=${ost_name}_echo_client
195 ec=`get_devno $host echo_client $client_name`
196 if [ -n "$ec" ]; then
197 echo $ec $client_name 0
200 if [ -z "$ost_name" ]; then
201 echo "no echo client and ost_name not set" 1>&2
204 ost=`get_devno $host obdfilter $ost_name`
205 if [ -z "$ost" ]; then
206 echo "OST $ost_name not setup" 1>&2
209 remote_shell $host "$lctl <<EOF
210 attach echo_client $client_name ${client_name}_UUID
213 ec=`get_devno $host echo_client $client_name`
214 if [ -z "$ec" ]; then
215 echo "Can't setup echo client" 1>&2
218 echo $ec $client_name 1
221 teardown_ec_devno () {
224 remote_shell $host "$lctl <<EOF
232 # create a set of objects, check there are 'n' contiguous ones and
233 # return the first or 'ERROR'
238 remote_shell $host $lctl --device $devno create $nobj > $rfile 2>&1
244 echo "$line" | grep -q 'is object id'
245 if [ $? -ne 0 ]; then
248 if [ $first -eq 0 ]; then
249 first=$(echo $line | awk '{print $6}')
250 first=$(printf "%d" $first)
254 obj=$(echo $line | awk '{print $6}')
255 obj=$(printf "%d" $obj)
256 diff=$((obj - (prev+1)))
257 if [ $diff -ne 0 ]; then
264 if [ $nobj -ne $count ]; then
265 echo "ERROR: $nobj != $count" >&2
268 elif [ $error -ne 0 ]; then
269 echo "ERROR: non contiguous objs found" >&2
282 remote_shell $host $lctl --device $devno destroy $obj0 $nobj > $rfile 2>&1
288 '/^Selected device [0-9]+$/ {n = 0; next}\
289 /error/ {n = -1; exit}\
290 /^[0-9]+\/[0-9]+ Total: [0-9]+\.[0-9]+\/second$/ {n++; v=strtonum($3); \
291 if (n == 1 || v < min) min = v;\
292 if (n == 1 || v > max) max = v;\
294 {if (n != 0) {n = -1; exit}}\
295 END {printf "%d %f %f\n", n, min, max}'
298 get_global_stats () {
300 awk < $rfile 'BEGIN {n = 0;}\
301 {n++; if (n == 1) {err = $1; min = $2; max = $3} else\
302 {if ($1 < err) err = $1;\
303 if ($2 < min) min = $2;\
304 if ($3 > max) max = $3}}\
305 END {if (n == 0) err = 0;\
306 printf "%d %f %f\n", err, min, max}'
310 # 'x' disables data check
317 *write*) echo "w$x";;
323 if [ "$1" = "-n" ]; then
328 echo $minusn "$*" >> $rsltf
333 echo "$@" | xargs -n1 echo | sort -u
339 *:*) host=`echo $name | sed 's/:.*$//'`
340 name=`echo $name | sed 's/[^:]*://'`
348 # split out hostnames from client/ost names
349 ndevs=${#client_names[@]}
350 if ((ndevs != 0)); then
351 if ((${#ost_names[@]} != 0)); then
352 echo "Please specify client_names or ost_names, but not both" 1>&2
355 for ((i=0; i<ndevs;i++)); do
356 str=(`split_hostname ${client_names[$i]}`)
357 host_names[$i]=${str[0]}
358 client_names[$i]=${str[1]}
361 ndevs=${#ost_names[@]}
362 if ((ndevs == 0)); then
363 echo "Please specify either client_names or ost_names" 1>&2
366 for ((i=0; i<ndevs;i++)); do
367 str=(`split_hostname ${ost_names[$i]}`)
368 host_names[$i]=${str[0]}
369 ost_names[$i]=${str[1]}
373 # disable portals debug and get obdecho loaded on all relevant hosts
374 unique_hosts=(`unique ${host_names[@]}`)
375 for host in ${unique_hosts[@]}; do
376 remote_shell $host "echo 0 > /proc/sys/portals/debug"
377 do_unload_obdecho[$host]=0
378 if obdecho_loaded $host; then
382 if obdecho_loaded $host; then
383 do_unload_obdecho[$host]=1
386 echo "Can't load obdecho on $host" 1>&2
390 # get all the echo_client device numbers and names
391 for ((i=0; i<ndevs; i++)); do
392 host=${host_names[$i]}
393 devno=(`get_ec_devno $host "${client_names[$i]}" "${ost_names[$i]}"`)
394 if ((${#devno[@]} != 3)); then
397 devnos[$i]=${devno[0]}
398 client_names[$i]=${devno[1]}
399 do_teardown_ec[$i]=${devno[2]}
402 for ((rsz=$rszlo;rsz<=$rszhi;rsz*=2)); do
403 for ((nobj=$nobjlo;nobj<=$nobjhi;nobj*=2)); do
404 for ((thr=$thrlo;thr<=$thrhi;thr*=2)); do
405 if ((thr < nobj)); then
409 if [ -n "$restart_rsz" -a\
410 -n "$restart_nobj" -a\
411 -n "$restart_thr" ]; then
412 if ((rsz < restart_rsz ||\
413 (rsz == restart_rsz &&\
414 (nobj < restart_nobj ||\
415 (nobj == restart_nobj &&\
416 thr < restart_thr))))); then
421 total_thr=$((ndevs*thr))
422 total_nobj=$((ndevs*nobj))
423 pages=$((rsz/PAGE_SIZE))
424 actual_rsz=$((pages*PAGE_SIZE))
425 count=$((size*1024/(actual_rsz*thr)))
426 actual_size=$((actual_rsz*count*thr))
427 total_size=$((actual_size*ndevs))
428 # show computed parameters
429 str=`printf 'ost %2d sz %8dK rsz %4d obj %4d thr %4d ' \
430 $ndevs $total_size $actual_rsz $total_nobj $total_thr`
431 echo "=======================> $str" >> $workf
432 print_summary -n "$str"
433 if ((total_thr * actual_rsz > max_buffer_mem)); then
434 print_summary "Too much buffer space"
439 for ((idx=0; idx < ndevs; idx++)); do
440 host=${host_names[$idx]}
441 devno=${devnos[$idx]}
442 client_name="${host}:${client_names[$idx]}"
443 echo "=============> Create $nobj on $client_name" >> $workf
444 first_obj=`create_objects $host $devno $nobj $tmpf`
447 if [ $first_obj = "ERROR" ]; then
448 print_summary "created object #s on $client_name not contiguous"
451 first_objs[$idx]=$first_obj
454 for test in ${tests[@]}; do
455 print_summary -n "$test "
456 # create per-host script files
457 for host in ${unique_hosts[@]}; do
458 echo -n > ${cmdsf}_${host}
460 for ((idx=0; idx < ndevs; idx++)); do
461 host=${host_names[$idx]}
462 devno=${devnos[$idx]}
464 first_obj=${first_objs[$idx]}
465 echo >> ${cmdsf}_${host} \
466 "$lctl > $tmpfi 2>&1 \\
467 --threads $thr -$snap $devno \\
468 test_brw $count `testname2type $test` q $pages ${thr}t${first_obj} &"
470 for host in ${unique_hosts[@]}; do
471 echo "wait" >> ${cmdsf}_${host}
473 # timed run of all the per-host script files
475 for host in ${unique_hosts[@]}; do
476 remote_shell $host bash ${cmdsf}_${host}&
480 # clean up per-host script files
481 for host in ${unique_hosts[@]}; do
484 # compute bandwidth from total data / elapsed time
485 str=`awk "BEGIN {printf \"%7.2f \",\
486 $total_size / (( $t1 - $t0 ) * 1024)}"`
487 print_summary -n "$str"
488 # collect/check individual OST stats
490 for ((idx=0; idx < ndevs; idx++)); do
491 client_name="${host_names[$idx]}:${client_names[$idx]}"
493 echo "=============> $test $client_name" >> $workf
495 get_stats $tmpfi >> $tmpf
498 # compute/display global min/max stats
499 echo "=============> $test global" >> $workf
501 stats=(`get_global_stats $tmpf`)
503 if ((stats[0] <= 0)); then
504 if ((stats[0] < 0)); then
505 str=`printf "%17s " ERROR`
507 str=`printf "%17s " SHORT`
510 str=`awk "BEGIN {printf \"[%7.2f,%7.2f] \",\
511 (${stats[1]} * $actual_rsz)/1024,\
512 (${stats[2]} * $actual_rsz)/1024; exit}"`
514 print_summary -n "$str"
517 # destroy objects we created
518 for ((idx=0; idx < ndevs; idx++)); do
519 host=${host_names[$idx]}
520 devno=${devnos[$idx]}
521 client_name="${host}:${client_names[$idx]}"
522 first_obj=${first_objs[$idx]}
523 echo "=============> Destroy $nobj on $client_name" >> $workf
524 destroy_objects $host $devno $first_obj $nobj $tmpf
532 # tear down any echo clients we created
533 for ((i=0; i<ndevs; i++)); do
534 host=${host_names[$i]}
535 if ((${do_teardown_ec[$i]})); then
536 teardown_ec_devno $host ${client_names[$i]}
540 # unload any obdecho modules we loaded
541 for host in ${unique_hosts[@]}; do
542 if ((${do_unload_obdecho[$host]})); then