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)
91 remote_shell $host $lctl --device $devno create $nobj > $rfile 2>&1
97 # Count number of objects (lines containing " is object id "), and
98 # ensure that the objects numbers are sequential.
101 while read -u3 line; do
103 ( *' is object id '* )
105 if test $(( count += 1 )) -gt 1 ; then
106 (( $6 != prev + 1 )) && error=1
116 if [ $nobj -ne $count ]; then
117 echo "ERROR: $nobj != $count" >&2
120 elif [ $error -ne 0 ]; then
121 echo "ERROR: non contiguous objs found" >&2
129 # destroys all objects created in create_objects routine
130 # parameter: 3. start obj id.
138 remote_shell $host $lctl --device $devno destroy $obj0 $nobj > $rfile 2>&1
145 '/^Selected device [0-9]+$/ { \
156 /^[0-9]+\/[0-9]+ Total: [0-9]+\.[0-9]+\/second$/ { \
159 if (n == 1 || v < min) \
161 if (n == 1 || v > max) \
172 printf "%d %f %f\n", n, min, max \
176 get_global_stats () {
201 printf "%d %f %f\n", err, min, max \
205 # enable or disable data check.
206 # parameter: 1. read/write
208 # 'x' disables data check
215 *write*) echo "w$x";;
220 # for "echo_client + obdfilter" case, "prep + commit" mode should be used
221 # for "echo_client + osc" case, "BRW" mode should be used
230 if [ "$1" = "-n" ]; then
235 echo $minusn "$*" >> $rsltf
240 # split arguments like "2.3.61" into "2", "3", "61"
241 eval set -- $(tr "[:punct:]" " " <<< $*)
242 echo -n "$((($1 << 16) | ($2 << 8) | $3))"
245 get_lustre_version() {
246 local host=${1:-${unique_hosts[0]}}
247 remote_shell $host $lctl get_param -n version |
248 awk '/^lustre:/ {print $2}'
251 # Check whether the record size (KBytes) exceeds the maximum bulk I/O RPC size
253 check_record_size() {
254 [ $(version_code $(get_lustre_version)) -lt $(version_code 2.3.61) ] &&
257 if [ "$rszhi" -gt "$rszmax" ]; then
258 echo "Test disk case support maximum ${rszmax}KB IO data" \
259 "(rszhi=$rszhi is too big), please use a smaller value."
265 # Customisation variables
266 #####################################################################
267 # One can change variable values in this section as per requirements
269 if [ -n "$targets" ]; then
271 declare -a client_names
273 for name in $targets; do
274 if [ $case == "disk" ]; then
275 ost_names[$count]=$name
277 client_names[$count]=$name
283 # what tests to run (first must be write)
284 tests_str=${tests_str:-""}
285 if [ -n "$tests_str" ]; then
288 for name in $tests_str; do
293 #tests=(write rewrite read reread rewrite_again)
294 tests=(write rewrite read)
297 # restart from here iff all are defined
302 # machine's page size (KB)
303 PAGE_SIZE=${PAGE_SIZE:-$(($(getconf PAGE_SIZE) / 1024))}
304 PAGE_SIZE=${PAGE_SIZE:-4}
308 # Customisation variables ends here.
309 #####################################################################
310 # leave the rest of this alone unless you know what you're doing...
312 # check and insert obdecho module
313 if ! lsmod | grep obdecho > /dev/null; then
316 if [ ${#tests[@]} -eq 0 -o "${tests[0]}" != "write" ]; then
317 echo "tests: ${tests[@]}"
318 echo "First test must be 'write'" 1>&2
322 rsltf="${rslt}.summary"
323 workf="${rslt}.detail"
324 cmdsf="${rslt}.script"
325 vmstatf="${rslt}.vmstat"
329 # hide a little trick to unset this from the command line
330 if [ "$lustre_root" == " " ]; then
334 if [ -z "$lustre_root" ]; then
337 lctl=${lustre_root}/utils/lctl
340 # split out hostnames from client/ost names
342 for trgt in $targets; do
343 str=($(split_hostname $trgt))
344 host_names[$ndevs]=${str[0]}
345 client_names[$ndevs]=${str[1]}
348 if [ $case == "disk" ]; then
349 for ((i = 0; i < $ndevs; i++)); do
350 ost_names[$i]=${client_names[$i]}
353 if [ $case == "netdisk" ]; then
354 if [ "$targets" ]; then
355 for ((i = 0; i < $ndevs; i++)); do
356 setup_osc_for_remote_ost ${host_names[$i]} \
357 ${client_names[$i]} $i
358 osc_name=${client_names[$i]}_osc
359 ec_using_osc $osc_name
360 cleanup_oscs="$cleanup_oscs $osc_name"
363 client_names_str=$($lctl dl | grep -v mdt |
364 awk '{if ($2 == "UP" && $3 == "osc") {print $4} }')
366 for name in $client_names_str; do
367 client_names[$count]=$(echo $name | sed 's/-osc-.*$//')
371 host_names_str=$($lctl dl -t | grep -v mdt |
372 awk '{if ($2 == "UP" && $3 == "osc") {print $7} }')
374 for name in $host_names_str; do
375 host_names[$count]=$(echo $name | sed 's/@.*$//')
379 for (( i = 0; i < $count; i++ )) do
380 setup_osc_for_remote_ost ${host_names[$i]} \
381 ${client_names[$i]} $i
382 osc_name=${client_names[$i]}_osc
383 ec_using_osc $osc_name
384 cleanup_oscs="$cleanup_oscs $osc_name"
388 echo_clients=$($lctl dl | grep echo_client |
389 awk "{if (\$2 == \"UP\" && \$3 == \"echo_client\") { \
392 for name in $echo_clients; do
393 client_names[$cnt]=$name
394 host_names[$cnt]=localhost
397 ndevs=${#client_names[@]}
399 if [ $case == "network" ]; then
401 if [ -z "$server_nid" ]; then
402 echo "Specify hostname or ip-address of server"
405 # check for obdecho module on server
406 if ! dsh $server_nid root "lsmod | grep obdecho > /dev/null"; then
407 dsh $server_nid root "modprobe obdecho"
409 # Now do the server setup
410 setup_srv_obd $server_nid "echo_srv"
411 oss_on_srv=$(dsh $server_nid root "$lctl dl | grep OSS" |
413 if [ -z $oss_on_srv ]; then
414 setup_OSS $server_nid
417 if ! dsh $server_nid root "$lctl dl | grep obdecho > /dev/null 2>&1"; then
418 echo "obdecho not setup on server"
421 if ! dsh $server_nid root "$lctl dl | grep ost > /dev/null 2>&1"; then
422 echo "ost not setup on server"
425 # Now start client setup
426 osc_names_str=$($lctl dl| grep osc | grep -v mdt | grep UP)
427 if [ -n "$osc_names_str" ]; then
428 echo "The existing setup must be cleaned";
431 ec_using_srv_nid $server_nid "echotmp" "echotmp_UUID"
432 client_names[0]="echotmp_ecc"
434 if [ -z "$targets" ]; then
435 if [ $case == "disk" ]; then
437 ndevs=${#ost_names[@]}
441 # disable portals debug and get obdecho loaded on all relevant hosts
442 unique_hosts=($(unique ${host_names[@]}))
445 if [ $case == "disk" ]; then
446 check_record_size || cleanup ${PIPESTATUS[0]}
450 for host in ${unique_hosts[@]}; do
451 host_vmstatf=${vmstatf}_${host}
452 echo -n > $host_vmstatf
453 remote_shell $host "vmstat 5 >> $host_vmstatf" &> /dev/null &
455 vmstatpids[$pidcount]=$pid
456 pidcount=$((pidcount + 1))
458 # get all the echo_client device numbers and names
459 for ((i=0; i < $ndevs; i++)); do
460 host=${host_names[$i]}
461 devno=($(get_ec_devno $host "${client_names[$i]}" "${ost_names[$i]}"))
462 if ((${#devno[@]} != 3)); then
465 devnos[$i]=${devno[0]}
466 client_names[$i]=${devno[1]}
467 do_teardown_ec[$i]=${devno[2]}
469 if (($ndevs <= 0 || ${#host_names[@]} <= 0)); then
470 echo "no devices or hosts specified"
471 cleanup 0 $clean_srv_OSS $cleanup_oscs
474 print_summary "$(date) Obdfilter-survey for case=$case from $(hostname)"
475 for ((rsz = $rszlo; rsz <= $rszhi; rsz*=2)); do
476 for ((nobj = $nobjlo; nobj <= $nobjhi; nobj*=2)); do
477 for ((thr = $thrlo; thr <= $thrhi; thr*=2)); do
478 if ((thr % nobj)); then
482 if [ -n "$restart_rsz" -a \
483 -n "$restart_nobj" -a \
484 -n "$restart_thr" ]; then
485 if ((rsz < restart_rsz ||
486 (rsz == restart_rsz &&
487 (nobj < restart_nobj ||
488 (nobj == restart_nobj &&
489 thr < restart_thr))))); then
495 total_thr=$((ndevs * thr))
496 total_nobj=$((ndevs * nobj))
497 pages=$((rsz / PAGE_SIZE))
498 actual_rsz=$((pages * PAGE_SIZE))
499 count=$((size * 1024 / (actual_rsz * thr)))
500 actual_size=$((actual_rsz * count * thr))
501 total_size=$((actual_size * ndevs))
503 # show computed parameters
504 str=$(printf 'ost %2d sz %8dK rsz %4dK obj %4d thr %4d ' \
505 $ndevs $total_size $actual_rsz $total_nobj $total_thr)
506 echo "=======================> $str" >> $workf
507 print_summary -n "$str"
511 for ((idx = 0; idx < $ndevs; idx++)); do
512 host=${host_names[$idx]}
513 devno=${devnos[$idx]}
514 client_name="${host}:${client_names[$idx]}"
515 echo "=============> Create $nobj on $client_name" >> $workf
516 first_obj=$(create_objects $host $devno $nobj $tmpf)
519 if [ $first_obj = "ERROR" ]; then
520 print_summary "created object #s on $client_name not contiguous"
523 first_objs[$idx]=$first_obj
527 for test in ${tests[@]}; do
529 for host in ${unique_hosts[@]}; do
531 "lctl set_param -n osd*.*OST*.force_sync 1"
532 echo "starting run for test: $test rsz: $rsz " \
533 "threads: $thr objects: $nobj" >> ${vmstatf}_${host}
535 print_summary -n "$test "
537 # create per-host script files
538 for host in ${unique_hosts[@]}; do
539 echo -n > ${cmdsf}_${host}
541 for ((idx = 0; idx < $ndevs; idx++)); do
542 host=${host_names[$idx]}
543 devno=${devnos[$idx]}
545 first_obj=${first_objs[$idx]}
546 thr_per_obj=$((${thr}/${nobj}))
547 echo >> ${cmdsf}_${host} \
548 "$lctl > $tmpfi 2>&1 \\
549 --threads $thr -$snap $devno \\
550 test_brw $count $(testname2type $test) q $pages \\
551 ${thr_per_obj}t${first_obj} $(testcase2mode)$pages &"
554 for host in ${unique_hosts[@]}; do
555 echo "wait" >> ${cmdsf}_${host}
556 pidarray[$pidcount]=0
557 pidcount=$((pidcount + 1))
559 # timed run of all the per-host script files
562 for host in ${unique_hosts[@]}; do
563 remote_shell $host bash < ${cmdsf}_${host} &
564 pidarray[$pidcount]=$!
565 pidcount=$((pidcount + 1))
568 for host in ${unique_hosts[@]}; do
569 wait ${pidarray[$pidcount]}
570 pidcount=$((pidcount + 1))
574 # clean up per-host script files
575 for host in ${unique_hosts[@]}; do
579 # compute bandwidth from total data / elapsed time
580 str=$(awk "BEGIN {printf \"%7.2f \",\
581 $total_size / (( $t1 - $t0 ) * 1024)}")
582 print_summary -n "$str"
583 # collect/check individual OST stats
585 for ((idx = 0; idx < $ndevs; idx++)); do
586 client_name="${host_names[$idx]}:${client_names[$idx]}"
588 echo "=============> $test $client_name" >> $workf
589 host="${host_names[$idx]}"
590 remote_shell $host cat $tmpfi > ${tmpfi}_local
591 cat ${tmpfi}_local >> $workf
592 get_stats ${tmpfi}_local >> $tmpf
593 rm -f $tmpfi ${tmpfi}_local
596 # compute/display global min/max stats
597 echo "=============> $test global" >> $workf
599 stats=($(get_global_stats $tmpf))
601 if ((stats[0] <= 0)); then
602 if ((stats[0] < 0)); then
603 str=$(printf "%17s " ERROR)
605 str=$(printf "%17s " SHORT)
608 str=$(awk "BEGIN {printf \"[%7.2f, %7.2f] \",\
609 (${stats[1]} * $actual_rsz)/1024,\
610 (${stats[2]} * $actual_rsz)/1024; exit}")
612 print_summary -n "$str"
616 # destroy objects we created
617 for ((idx = 0; idx < $ndevs; idx++)); do
618 host=${host_names[$idx]}
619 devno=${devnos[$idx]}
620 client_name="${host}:${client_names[$idx]}"
621 first_obj=${first_objs[$idx]}
622 echo "=============> Destroy $nobj on $client_name" >> $workf
623 destroy_objects $host $devno $first_obj $nobj $tmpf
630 cleanup 0 $clean_srv_OSS $cleanup_oscs