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 # allow these to be passed in via string...
14 # one can specify only case=disk or case=network or case=netdisk through
17 # Perquisite: For "disk" case and "netdisk" case you need to have lustre setup
18 # with one or more ost's. For "network" case you need to have all
19 # modules (those llmount.sh loades) loaded in kernel. And the
20 # 'lctl dl' output must be blank.
23 # case 1 (local disk):
24 # $ nobjhi=2 thrhi=2 size=1024 case=disk sh obdfilter-survey
25 # one can also run test with user defined targets as follows,
26 # $ nobjhi=2 thrhi=2 size=1024 targets="lustre-OST0000 lustre-OST0001 ..." sh obdfilter-survey
28 # $ nobjhi=2 thrhi=2 size=1024 targets="<name/ip_of_server>" case=network sh obdfilter-survey
29 # where, targets is name or ip address of system, which you want to
31 # case 3 (network and disk):
32 # $ nobjhi=2 thrhi=2 size=1024 case=netdisk sh obdfilter-survey
33 # one can also run test with user defined targets as follows,
34 # $ nobjhi=2 thrhi=2 size=1024 targets="<osc_name> ..." sh obdfilter-survey
35 #[ NOTE: It is advised to have automated login (passwordless entry) between server and
36 # client systems on which this test runs.]
39 source $(dirname $0)/iokit-libecho
41 # The following variables can be set in the environment, or on the
43 # result file prefix (date/time + hostname makes unique)
44 # NB ensure path to it exists
45 rslt_loc=${rslt_loc:-"/tmp"}
46 rslt=${rslt:-"$rslt_loc/obdfilter_survey_`date +%F@%R`_`uname -n`"}
48 # Set this true to check file contents
52 targets=${targets:-""}
56 # total size (MBytes) per obd instance
57 # large enough to avoid cache effects
58 # and to make test startup/shutdown overhead insignificant
61 # record size (KBytes) ( 7168 max)
64 rszmax=${rszmax:-4096}
66 # number of objects per OST
68 #was nobjhi=${nobjhi:-512}
71 # threads per OST (1024 max)
79 # create a set of objects, check there are 'n' contiguous ones and
80 # echo out the first or 'ERROR'
81 # parameter: 1. hostname
83 # 3. number of object to be created (specified by user)
90 remote_shell $host $lctl --device $devno create $nobj > $rfile 2>&1
96 # Count number of objects (lines containing " is object id "), and
97 # ensure that the objects numbers are sequential.
100 while read -u3 line; do
102 ( *' is object id '* )
104 if test $(( count += 1 )) -gt 1 ; then
105 (( $6 != prev + 1 )) && error=1
115 if [ $nobj -ne $count ]; then
116 echo "ERROR: $nobj != $count" >&2
119 elif [ $error -ne 0 ]; then
120 echo "ERROR: non contiguous objs found" >&2
128 # destroys all objects created in create_objects routine
129 # parameter: 3. start obj id.
136 remote_shell $host $lctl --device $devno destroy $obj0 $nobj > $rfile 2>&1
142 '/^Selected device [0-9]+$/ {n = 0; next}\
143 /error/ {n = -1; exit}\
145 /^[0-9]+\/[0-9]+ Total: [0-9]+\.[0-9]+\/second$/ {n++; v=strtonum($3); \
146 if (n == 1 || v < min) min = v;\
147 if (n == 1 || v > max) max = v;\
149 {if (n != 0) {n = -1; exit}}\
150 END {printf "%d %f %f\n", n, min, max}'
153 get_global_stats () {
155 awk < $rfile 'BEGIN {n = 0;}\
156 {n++; if (n == 1) {err = $1; min = $2; max = $3} else\
157 {if ($1 < err) err = $1;\
158 if ($2 < min) min = $2;\
159 if ($3 > max) max = $3}}\
160 END {if (n == 0) err = 0;\
161 printf "%d %f %f\n", err, min, max}'
164 # enable or disable data check.
165 # parameter: 1. read/write
167 # 'x' disables data check
174 *write*) echo "w$x";;
179 # for "echo_client + obdfilter" case, "prep + commit" mode should be used
180 # for "echo_client + osc" case, "BRW" mode should be used
189 if [ "$1" = "-n" ]; then
194 echo $minusn "$*" >> $rsltf
199 # split arguments like "2.3.61" into "2", "3", "61"
200 eval set -- $(tr "[:punct:]" " " <<< $*)
201 echo -n "$((($1 << 16) | ($2 << 8) | $3))"
204 get_lustre_version() {
205 local host=${1:-${unique_hosts[0]}}
206 remote_shell $host $lctl get_param -n version |
207 awk '/^lustre:/ {print $2}'
210 # Check whether the record size (KBytes) exceeds the maximum bulk I/O RPC size
212 check_record_size() {
213 [ $(version_code $(get_lustre_version)) -lt $(version_code 2.3.61) ] &&
216 if [ "$rszhi" -gt "$rszmax" ]; then
217 echo "Test disk case support maximum ${rszmax}KB IO data" \
218 "(rszhi=$rszhi is too big), please use a smaller value."
224 # Customisation variables
225 #####################################################################
226 # One can change variable values in this section as per requirements
228 if [ -n "$targets" ]; then
230 declare -a client_names
232 for name in $targets; do
233 if [ $case == "disk" ]; then
234 ost_names[$count]=$name
236 client_names[$count]=$name
242 # what tests to run (first must be write)
243 tests_str=${tests_str:-""}
244 if [ -n "$tests_str" ]; then
247 for name in $tests_str; do
252 #tests=(write rewrite read reread rewrite_again)
253 tests=(write rewrite read)
256 # restart from here iff all are defined
261 # machine's page size (K)
262 if [ -z "$PAGE_SIZE" ]; then
263 if which python >/dev/null; then
264 PAGE_SIZE=`echo 'import resource; print resource.getpagesize()/1024;' |python`
267 PAGE_SIZE=${PAGE_SIZE:-4}
269 # max buffer_mem (total_threads * buffer size)
270 # (to avoid lctl ENOMEM problems)
271 max_buffer_mem=$((1024 * 1024))
274 # Customisation variables ends here.
275 #####################################################################
276 # leave the rest of this alone unless you know what you're doing...
278 # check and insert obdecho module
279 if ! lsmod | grep obdecho > /dev/null; then
282 if [ ${#tests[@]} -eq 0 -o "${tests[0]}" != "write" ]; then
283 echo "tests: ${tests[@]}"
284 echo "First test must be 'write'" 1>&2
288 rsltf="${rslt}.summary"
289 workf="${rslt}.detail"
290 cmdsf="${rslt}.script"
291 vmstatf="${rslt}.vmstat"
295 # hide a little trick to unset this from the command line
296 if [ "$lustre_root" == " " ]; then
300 if [ -z "$lustre_root" ]; then
303 lctl=${lustre_root}/utils/lctl
306 # split out hostnames from client/ost names
308 for trgt in $targets; do
309 str=(`split_hostname $trgt`)
310 host_names[$ndevs]=${str[0]}
311 client_names[$ndevs]=${str[1]}
314 if [ $case == "disk" ]; then
315 for ((i = 0; i < $ndevs; i++)); do
316 ost_names[$i]=${client_names[$i]}
319 if [ $case == "netdisk" ]; then
320 if [ "$targets" ]; then
321 for ((i = 0; i < $ndevs; i++)); do
322 setup_osc_for_remote_ost ${host_names[$i]} \
323 ${client_names[$i]} $i
324 osc_name=${client_names[$i]}_osc
325 ec_using_osc $osc_name
326 cleanup_oscs="$cleanup_oscs $osc_name"
329 client_names_str=$($lctl dl | grep -v mdt | \
330 awk '{if ($2 == "UP" && $3 == "osc") {print $4} }')
332 for name in $client_names_str; do
333 client_names[$count]=`echo $name | sed 's/-osc-.*$//'`
337 host_names_str=$($lctl dl -t | grep -v mdt | \
338 awk '{if ($2 == "UP" && $3 == "osc") {print $7} }')
340 for name in $host_names_str; do
341 host_names[$count]=`echo $name | sed 's/@.*$//'`
345 for (( i = 0; i < $count; i++ )) do
346 setup_osc_for_remote_ost ${host_names[$i]} \
347 ${client_names[$i]} $i
348 osc_name=${client_names[$i]}_osc
349 ec_using_osc $osc_name
350 cleanup_oscs="$cleanup_oscs $osc_name"
354 echo_clients=$($lctl dl | grep echo_client | awk "{if (\$2 == \"UP\" && \$3 == \"echo_client\") {print \$4} }")
356 for name in $echo_clients; do
357 client_names[$cnt]=$name
358 host_names[$cnt]=localhost
361 ndevs=${#client_names[@]}
363 if [ $case == "network" ]; then
365 if [ -z "$server_nid" ]; then
366 echo "Specify hostname or ip-address of server"
369 # check for obdecho module on server
370 if ! dsh $server_nid root "lsmod | grep obdecho > /dev/null"; then
371 dsh $server_nid root "modprobe obdecho"
373 # Now do the server setup
374 setup_srv_obd $server_nid "echo_srv"
375 oss_on_srv=`dsh $server_nid root "$lctl dl | grep OSS" | awk '{ print $4 }'`
376 if [ -z $oss_on_srv ]; then
377 setup_OSS $server_nid
380 if ! dsh $server_nid root "$lctl dl | grep obdecho > /dev/null 2>&1"; then
381 echo "obdecho not setup on server"
384 if ! dsh $server_nid root "$lctl dl | grep ost > /dev/null 2>&1"; then
385 echo "ost not setup on server"
388 # Now start client setup
389 osc_names_str=$($lctl dl| grep osc | grep -v mdt | grep UP)
390 if [ -n "$osc_names_str" ]; then
391 echo "The existing setup must be cleaned";
394 ec_using_srv_nid $server_nid "echotmp" "echotmp_UUID"
395 client_names[0]="echotmp_ecc"
397 if [ -z "$targets" ]; then
398 if [ $case == "disk" ]; then
400 ndevs=${#ost_names[@]}
404 # disable portals debug and get obdecho loaded on all relevant hosts
405 unique_hosts=(`unique ${host_names[@]}`)
408 if [ $case == "disk" ]; then
409 check_record_size || cleanup ${PIPESTATUS[0]}
413 for host in ${unique_hosts[@]}; do
414 host_vmstatf=${vmstatf}_${host}
415 echo -n > $host_vmstatf
416 remote_shell $host "vmstat 5 >> $host_vmstatf" &> /dev/null &
418 vmstatpids[$pidcount]=$pid
419 pidcount=$((pidcount+1))
421 # get all the echo_client device numbers and names
422 for ((i=0; i < $ndevs; i++)); do
423 host=${host_names[$i]}
424 devno=(`get_ec_devno $host "${client_names[$i]}" "${ost_names[$i]}"`)
425 if ((${#devno[@]} != 3)); then
428 devnos[$i]=${devno[0]}
429 client_names[$i]=${devno[1]}
430 do_teardown_ec[$i]=${devno[2]}
432 if (($ndevs <= 0 || ${#host_names[@]} <= 0)); then
433 echo "no devices or hosts specified"
434 cleanup 0 $clean_srv_OSS $cleanup_oscs
436 # Buffers will be spread out among all hosts, so allow for that
437 max_buffer_mem=$(( ${max_buffer_mem} * ${#unique_hosts[@]} ))
438 print_summary "$(date) Obdfilter-survey for case=$case from $(hostname)"
439 for ((rsz = $rszlo; rsz <= $rszhi; rsz*=2)); do
440 for ((nobj = $nobjlo; nobj <= $nobjhi; nobj*=2)); do
441 for ((thr = $thrlo; thr <= $thrhi; thr*=2)); do
442 if ((thr % nobj)); then
446 if [ -n "$restart_rsz" -a\
447 -n "$restart_nobj" -a\
448 -n "$restart_thr" ]; then
449 if ((rsz < restart_rsz ||\
450 (rsz == restart_rsz &&\
451 (nobj < restart_nobj ||\
452 (nobj == restart_nobj &&\
453 thr < restart_thr))))); then
458 total_thr=$((ndevs*thr))
459 total_nobj=$((ndevs*nobj))
460 pages=$((rsz/PAGE_SIZE))
461 actual_rsz=$((pages*PAGE_SIZE))
462 count=$((size*1024/(actual_rsz*thr)))
463 actual_size=$((actual_rsz*count*thr))
464 total_size=$((actual_size*ndevs))
465 # show computed parameters
466 str=`printf 'ost %2d sz %8dK rsz %4dK obj %4d thr %4d ' \
467 $ndevs $total_size $actual_rsz $total_nobj $total_thr`
468 echo "=======================> $str" >> $workf
469 print_summary -n "$str"
470 if ((total_thr * actual_rsz > max_buffer_mem)); then
471 print_summary "Too much buffer space"
476 for ((idx = 0; idx < $ndevs; idx++)); do
477 host=${host_names[$idx]}
478 devno=${devnos[$idx]}
479 client_name="${host}:${client_names[$idx]}"
480 echo "=============> Create $nobj on $client_name" >> $workf
481 first_obj=`create_objects $host $devno $nobj $tmpf`
484 if [ $first_obj = "ERROR" ]; then
485 print_summary "created object #s on $client_name not contiguous"
488 first_objs[$idx]=$first_obj
491 for test in ${tests[@]}; do
493 for host in ${unique_hosts[@]}; do
494 echo "starting run for test: $test rsz: $rsz threads: $thr objects: $nobj" >> ${vmstatf}_${host}
496 print_summary -n "$test "
497 # create per-host script files
498 for host in ${unique_hosts[@]}; do
499 echo -n > ${cmdsf}_${host}
501 for ((idx = 0; idx < $ndevs; idx++)); do
502 host=${host_names[$idx]}
503 devno=${devnos[$idx]}
505 first_obj=${first_objs[$idx]}
506 thr_per_obj=$((${thr}/${nobj}))
507 echo >> ${cmdsf}_${host} \
508 "$lctl > $tmpfi 2>&1 \\
509 --threads $thr -$snap $devno \\
510 test_brw $count `testname2type $test` q $pages \\
511 ${thr_per_obj}t${first_obj} `testcase2mode`$pages &"
514 for host in ${unique_hosts[@]}; do
515 echo "wait" >> ${cmdsf}_${host}
516 pidarray[$pidcount]=0
517 pidcount=$((pidcount+1))
519 # timed run of all the per-host script files
522 for host in ${unique_hosts[@]}; do
523 remote_shell $host bash < ${cmdsf}_${host} &
524 pidarray[$pidcount]=$!
525 pidcount=$((pidcount+1))
528 for host in ${unique_hosts[@]}; do
529 wait ${pidarray[$pidcount]}
530 pidcount=$((pidcount+1))
534 # clean up per-host script files
535 for host in ${unique_hosts[@]}; do
539 # compute bandwidth from total data / elapsed time
540 str=`awk "BEGIN {printf \"%7.2f \",\
541 $total_size / (( $t1 - $t0 ) * 1024)}"`
542 print_summary -n "$str"
543 # collect/check individual OST stats
545 for ((idx = 0; idx < $ndevs; idx++)); do
546 client_name="${host_names[$idx]}:${client_names[$idx]}"
548 echo "=============> $test $client_name" >> $workf
549 host="${host_names[$idx]}"
550 remote_shell $host cat $tmpfi > ${tmpfi}_local
551 cat ${tmpfi}_local >> $workf
552 get_stats ${tmpfi}_local >> $tmpf
553 rm -f $tmpfi ${tmpfi}_local
555 # compute/display global min/max stats
556 echo "=============> $test global" >> $workf
558 stats=(`get_global_stats $tmpf`)
560 if ((stats[0] <= 0)); then
561 if ((stats[0] < 0)); then
562 str=`printf "%17s " ERROR`
564 str=`printf "%17s " SHORT`
567 str=`awk "BEGIN {printf \"[%7.2f,%7.2f] \",\
568 (${stats[1]} * $actual_rsz)/1024,\
569 (${stats[2]} * $actual_rsz)/1024; exit}"`
571 print_summary -n "$str"
574 # destroy objects we created
575 for ((idx = 0; idx < $ndevs; idx++)); do
576 host=${host_names[$idx]}
577 devno=${devnos[$idx]}
578 client_name="${host}:${client_names[$idx]}"
579 first_obj=${first_objs[$idx]}
580 echo "=============> Destroy $nobj on $client_name" >> $workf
581 destroy_objects $host $devno $first_obj $nobj $tmpf
588 cleanup 0 $clean_srv_OSS $cleanup_oscs