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.
12 ost_names=(ost{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16})
13 #client_names=(ns8:ECHO_ns8 ns9:ECHO_ns9)
15 # result file prefix (date/time + hostname makes unique)
16 # NB ensure path to it exists
17 rslt=/home_nfs/eeb/obdfilter_survey_`date +%F@%R`_`uname -n`
19 # lustre root (if running with own source tree)
20 lustre_root=/home_nfs/eeb/lustre
22 # what tests to run (first must be write)
23 #tests=(write rewrite read reread rewrite_again)
24 tests=(write rewrite read)
26 # total size (MBytes) per obd instance
27 # large enough to avoid cache effects
28 # and to make test startup/shutdown overhead insignificant
31 # record size (KBytes)
35 # number of objects per OST
39 # threads per OST (1024 max)
43 # restart from here iff all are defined
48 # machine's page size (K)
51 # max buffer_mem (total_threads * buffer size)
52 # (to avoid lctl ENOMEM problems)
53 max_buffer_mem=$((1024*1024))
55 # how to run commands on other nodes
56 # You need to make this work on your cluster if you have specified
57 # non-local obd instances above
58 custom_remote_shell () {
63 # Hop on to the remote node, chdir to 'here' and run the given
64 # commands. One of the following will probably work.
65 ssh $host "cd $here; $cmds"
66 #rsh $host "cd $here; $cmds"
67 # we have to remove the leading `uname -n`: from pdsh output lines
68 #pdsh -w $host "cd $here; $cmds" | sed 's/^[^:]*://'
71 #####################################################################
72 # leave the rest of this alone unless you know what you're doing...
76 modprobe="/sbin/modprobe"
80 # lctl::test_brw bandwidth snapshot interval (seconds)
82 # check file contents?
85 if [ ${#tests[@]} -eq 0 -o "${tests[0]}" != "write" ]; then
86 echo "First test must be 'write'" 1>&2
90 rsltf="${rslt}.summary"
91 workf="${rslt}.detail"
92 cmdsf="${rslt}.script"
96 if [ -z "$lustre_root" ]; then
99 lctl=${lustre_root}/utils/lctl
106 if [ "$host" = "localhost" -o "$host" = `uname -n` ]; then
109 custom_remote_shell $host "$cmds"
115 remote_shell $host $lsmod | grep obdecho > /dev/null 2>&1
120 if [ -z "$lustre_root" ]; then
121 remote_shell $host $modprobe obdecho
122 elif [ -f ${lustre_root}/obdecho/obdecho.ko ]; then
123 remote_shell $host $insmod ${lustre_root}/obdecho/obdecho.ko
125 remote_shell $host $insmod ${lustre_root}/obdecho/obdecho.o
131 remote_shell $host $rmmod obdecho
138 remote_shell $host $lctl device_list | \
139 awk "{if (\$2 == \"UP\" && \$3 == \"$type\" && \$4 == \"$name\") {\
145 local client_name="$2"
147 if [ -z "$client_name" ]; then
148 if [ -z "$ost_name" ]; then
149 echo "client and ost name both null" 1>&2
152 client_name=${ost_name}_echo_client
154 ec=`get_devno $host echo_client $client_name`
155 if [ -n "$ec" ]; then
156 echo $ec $client_name 0
159 if [ -z "$ost_name" ]; then
160 echo "no echo client and ost_name not set" 1>&2
163 ost=`get_devno $host obdfilter $ost_name`
164 if [ -z "$ost" ]; then
165 echo "OST $ost_name not setup" 1>&2
168 remote_shell $host "$lctl <<EOF
169 attach echo_client $client_name ${client_name}_UUID
172 ec=`get_devno $host echo_client $client_name`
173 if [ -z "$ec" ]; then
174 echo "Can't setup echo client" 1>&2
177 echo $ec $client_name 1
180 teardown_ec_devno () {
183 remote_shell $host "$lctl <<EOF
191 # create a set of objects, check there are 'n' contiguous ones and
192 # return the first or 'ERROR'
197 remote_shell $host $lctl --device $devno create $nobj > $rfile 2>&1
203 echo "$line" | grep -q 'is object id'
204 if [ $? -ne 0 ]; then
207 if [ $first -eq 0 ]; then
208 first=$(echo $line | awk '{print $6}')
209 first=$(printf "%d" $first)
213 obj=$(echo $line | awk '{print $6}')
214 obj=$(printf "%d" $obj)
215 diff=$((obj - (prev+1)))
216 if [ $diff -ne 0 ]; then
223 if [ $nobj -ne $count ]; then
224 echo "ERROR: $nobj != $count" >&2
227 elif [ $error -ne 0 ]; then
228 echo "ERROR: non contiguous objs found" >&2
241 remote_shell $host $lctl --device $devno destroy $obj0 $nobj > $rfile 2>&1
247 '/^Selected device [0-9]+$/ {n = 0; next}\
248 /error/ {n = -1; exit}\
249 /^[0-9]+\/[0-9]+ Total: [0-9]+\.[0-9]+\/second$/ {n++; v=strtonum($3); \
250 if (n == 1 || v < min) min = v;\
251 if (n == 1 || v > max) max = v;\
253 {if (n != 0) {n = -1; exit}}\
254 END {printf "%d %f %f\n", n, min, max}'
257 get_global_stats () {
259 awk < $rfile 'BEGIN {n = 0;}\
260 {n++; if (n == 1) {err = $1; min = $2; max = $3} else\
261 {if ($1 < err) err = $1;\
262 if ($2 < min) min = $2;\
263 if ($3 > max) max = $3}}\
264 END {if (n == 0) err = 0;\
265 printf "%d %f %f\n", err, min, max}'
269 # 'x' disables data check
276 *write*) echo "w$x";;
282 if [ "$1" = "-n" ]; then
287 echo $minusn "$*" >> $rsltf
292 echo "$@" | xargs -n1 echo | sort -u
298 *:*) host=`echo $name | sed 's/:.*$//'`
299 name=`echo $name | sed 's/[^:]*://'`
307 # split out hostnames from client/ost names
308 ndevs=${#client_names[@]}
309 if ((ndevs != 0)); then
310 if ((${#ost_names[@]} != 0)); then
311 echo "Please specify client_names or ost_names, but not both" 1>&2
314 for ((i=0; i<ndevs;i++)); do
315 str=(`split_hostname ${client_names[$i]}`)
316 host_names[$i]=${str[0]}
317 client_names[$i]=${str[1]}
320 ndevs=${#ost_names[@]}
321 if ((ndevs == 0)); then
322 echo "Please specify either client_names or ost_names" 1>&2
325 for ((i=0; i<ndevs;i++)); do
326 str=(`split_hostname ${ost_names[$i]}`)
327 host_names[$i]=${str[0]}
328 ost_names[$i]=${str[1]}
332 # disable portals debug and get obdecho loaded on all relevant hosts
333 unique_hosts=(`unique ${host_names[@]}`)
334 for host in ${unique_hosts[@]}; do
335 remote_shell $host "echo 0 > /proc/sys/portals/debug"
336 do_unload_obdecho[$host]=0
337 if obdecho_loaded $host; then
341 if obdecho_loaded $host; then
342 do_unload_obdecho[$host]=1
345 echo "Can't load obdecho on $host" 1>&2
349 # get all the echo_client device numbers and names
350 for ((i=0; i<ndevs; i++)); do
351 host=${host_names[$i]}
352 devno=(`get_ec_devno $host "${client_names[$i]}" "${ost_names[$i]}"`)
353 if ((${#devno[@]} != 3)); then
356 devnos[$i]=${devno[0]}
357 client_names[$i]=${devno[1]}
358 do_teardown_ec[$i]=${devno[2]}
361 for ((rsz=$rszlo;rsz<=$rszhi;rsz*=2)); do
362 for ((nobj=$nobjlo;nobj<=$nobjhi;nobj*=2)); do
363 for ((thr=$thrlo;thr<=$thrhi;thr*=2)); do
364 if ((thr < nobj)); then
368 if [ -n "$restart_rsz" -a\
369 -n "$restart_nobj" -a\
370 -n "$restart_thr" ]; then
371 if ((rsz < restart_rsz ||\
372 (rsz == restart_rsz &&\
373 (nobj < restart_nobj ||\
374 (nobj == restart_nobj &&\
375 thr < restart_thr))))); then
380 total_thr=$((ndevs*thr))
381 total_nobj=$((ndevs*nobj))
382 pages=$((rsz/PAGE_SIZE))
383 actual_rsz=$((pages*PAGE_SIZE))
384 count=$((size*1024/(actual_rsz*thr)))
385 actual_size=$((actual_rsz*count*thr))
386 total_size=$((actual_size*ndevs))
387 # show computed parameters
388 str=`printf 'ost %2d sz %8dK rsz %4d obj %4d thr %4d ' \
389 $ndevs $total_size $actual_rsz $total_nobj $total_thr`
390 echo "=======================> $str" >> $workf
391 print_summary -n "$str"
392 if ((total_thr * actual_rsz > max_buffer_mem)); then
393 print_summary "Too much buffer space"
398 for ((idx=0; idx < ndevs; idx++)); do
399 host=${host_names[$idx]}
400 devno=${devnos[$idx]}
401 client_name="${host}:${client_names[$idx]}"
402 echo "=============> Create $nobj on $client_name" >> $workf
403 first_obj=`create_objects $host $devno $nobj $tmpf`
406 if [ $first_obj = "ERROR" ]; then
407 print_summary "created object #s on $client_name not contiguous"
410 first_objs[$idx]=$first_obj
413 for test in ${tests[@]}; do
414 print_summary -n "$test "
415 # create per-host script files
416 for host in ${unique_hosts[@]}; do
417 echo -n > ${cmdsf}_${host}
419 for ((idx=0; idx < ndevs; idx++)); do
420 host=${host_names[$idx]}
421 devno=${devnos[$idx]}
423 first_obj=${first_objs[$idx]}
424 echo >> ${cmdsf}_${host} \
425 "$lctl > $tmpfi 2>&1 \\
426 --threads $thr -$snap $devno \\
427 test_brw $count `testname2type $test` q $pages ${thr}t${first_obj} &"
429 for host in ${unique_hosts[@]}; do
430 echo "wait" >> ${cmdsf}_${host}
432 # timed run of all the per-host script files
434 for host in ${unique_hosts[@]}; do
435 remote_shell $host bash ${cmdsf}_${host}&
439 # clean up per-host script files
440 for host in ${unique_hosts[@]}; do
443 # compute bandwidth from total data / elapsed time
444 str=`awk "BEGIN {printf \"%7.2f \",\
445 $total_size / (( $t1 - $t0 ) * 1024)}"`
446 print_summary -n "$str"
447 # collect/check individual OST stats
449 for ((idx=0; idx < ndevs; idx++)); do
450 client_name="${host_names[$idx]}:${client_names[$idx]}"
452 echo "=============> $test $client_name" >> $workf
454 get_stats $tmpfi >> $tmpf
457 # compute/display global min/max stats
458 echo "=============> $test global" >> $workf
460 stats=(`get_global_stats $tmpf`)
462 if ((stats[0] <= 0)); then
463 if ((stats[0] < 0)); then
464 str=`printf "%17s " ERROR`
466 str=`printf "%17s " SHORT`
469 str=`awk "BEGIN {printf \"[%7.2f,%7.2f] \",\
470 (${stats[1]} * $actual_rsz)/1024,\
471 (${stats[2]} * $actual_rsz)/1024; exit}"`
473 print_summary -n "$str"
476 # destroy objects we created
477 for ((idx=0; idx < ndevs; idx++)); do
478 host=${host_names[$idx]}
479 devno=${devnos[$idx]}
480 client_name="${host}:${client_names[$idx]}"
481 first_obj=${first_objs[$idx]}
482 echo "=============> Destroy $nobj on $client_name" >> $workf
483 destroy_objects $host $devno $first_obj $nobj $tmpf
491 # tear down any echo clients we created
492 for ((i=0; i<ndevs; i++)); do
493 host=${host_names[$i]}
494 if ((${do_teardown_ec[$i]})); then
495 teardown_ec_devno $host ${client_names[$i]}
499 # unload any obdecho modules we loaded
500 for host in ${unique_hosts[@]}; do
501 if ((${do_unload_obdecho[$host]})); then